Userscript Sidebar for Google Search

Userscript Sidebar for Google.com. You easy edit this script for himself.Example: change lang_ru to lang_tr if your want turkey languadge.

  1. // ==UserScript==
  2. // @name Userscript Sidebar for Google Search
  3. // @author ras5566
  4. // @version 1.0
  5. // @description Userscript Sidebar for Google.com. You easy edit this script for himself.Example: change lang_ru to lang_tr if your want turkey languadge.
  6. // @include https://stackoverflow.com/questions/14722302/*
  7. // @include https://www.google.com/search?*
  8. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
  9. // @grant GM_addStyle
  10. /* global $ */
  11. // @namespace https://greatest.deepsurf.us/users/746376
  12. // ==/UserScript==
  13.  
  14. $("body").append ( ' \
  15. <div id="gmRightSideBar"> \
  16. <p>F9 toggles visibility</p> \
  17. <ul> \
  18. <li><input id="yearrr" type="button" value="2Year!"></li> \
  19. <li><input id="hourss" type="button" value="4Year!"></li> \
  20. <li><input id="alltimee" type="button" value="alltime"></li> \
  21. <li><input id="langruu" type="button" value="lang_ru"></li> \
  22. <li><input id="langenn" type="button" value="lang_en!"></li> \
  23. <li><input id="allintitlee" type="button" value="allintitle!"></li> \
  24. <li><input id="filetypedocc" type="button" value="filetype DOC!"></li> \
  25. <li><input id="githubb" type="button" value="github.com"></li> \
  26. <li><input id="habrrr" type="button" value="habr.com"></li> \
  27. <li><input id="youtubee" type="button" value="youtube.com"></li> \
  28. <li><input id="durvideoo" type="button" value="DurVideo_M"></li> \
  29. </ul> \
  30. </div> \
  31. ' );
  32.  
  33.  
  34. var currentLocation = window.location;
  35. var currentsearchhh = window.location.search;
  36. var currenturl= document.URL
  37. filetypedocc.onclick = function() {
  38. var namme=document.getElementsByName('q')[0].value;
  39. // document.location.href = currenturl+namme+"&q=filetype:DOC";
  40. document.location.href = currentLocation+"&q=filetype:DOC";
  41. alert(namme);
  42. };
  43.  
  44. durvideoo.onclick = function() {
  45. // var classnameee=document.getElementsByClassName('gLFyf gsfi')[0].value;
  46. // var namme=document.getElementsByName('q')[0].value;
  47. // var selectoree=document.querySelector('#tsf > div:nth-child(2) > div.A8SBwf > div.RNNXgb.lsbb > div.SDkEP > div.a4bIc > input').value;
  48. document.location.href = currentLocation+"&&tbs=dur:m";
  49. };
  50.  
  51. ////////////////
  52. hourss.onclick = function() {
  53. // var classnameee=document.getElementsByClassName('gLFyf gsfi')[0].value;
  54. // var namme=document.getElementsByName('q')[0].value;
  55. // var selectoree=document.querySelector('#tsf > div:nth-child(2) > div.A8SBwf > div.RNNXgb.lsbb > div.SDkEP > div.a4bIc > input').value;
  56. document.location.href = currentLocation+"&&tbs=qdr:y4";
  57. };
  58.  
  59. ////////////////
  60. alltimee.onclick = function(){
  61. //var classnameee=document.getElementsByClassName('znKVS tnhqA')[0].value;
  62. //document.getElementsByClassName("znKVS tnhqA")[0].click();
  63. //var currentLocation = window.location;
  64. //document.location.href = currentLocation+classnameee+"&lr=lang_ru";
  65. document.location.href = currentLocation+"&&tbs=qdr:all";
  66. };
  67. ////////////
  68. allintitlee.onclick = function(){
  69. document.location.href = currentLocation+"&as_occt=title";
  70. //alert(window.location.href);
  71. };
  72. ////////////
  73.  
  74. langruu.onclick = function(){
  75. document.location.href = currentLocation+"&lr=lang_ru";
  76. };
  77. ////////////
  78. langenn.onclick = function(){
  79. document.location.href = currentLocation+"&lr=lang_en";
  80. };
  81. ////////////
  82.  
  83. yearrr.onclick = function(){
  84. //var gg =window.location.search
  85. document.location.href = currentLocation+"&&tbs=qdr:m24";
  86. //alert(document.querySelector("#tsf").value);
  87. };
  88.  
  89. ////////////////
  90. githubb.onclick = function() {
  91. var namme=document.getElementsByName('q')[0].value;
  92. document.location.href = currentLocation+"&&as_sitesearch=github.com";
  93. alert(namme);
  94. };
  95. ////////////////
  96. youtubee.onclick = function() {
  97. // var namme=document.getElementsByName('q')[0].value;
  98. document.location.href = currentLocation+"&as_sitesearch=youtube.com";
  99. // alert(namme);
  100. };
  101. ////////////////
  102. habrrr.onclick = function() {
  103. // var namme=document.getElementsByName('q')[0].value;
  104. document.location.href = currentLocation+"&as_sitesearch=habr.com";
  105. // alert(namme);
  106. };
  107.  
  108.  
  109. //youtube.onclick = function(){
  110. //var gg =window.location.search
  111. // var classnameee=document.getElementsByClassName('gsfi ytd-searchbox')[0].value;
  112. // document.location.href = "http://www.youtube.com/results?"+classnameee+"&sp=CAM%253D";
  113. // alert(classnameee);
  114.  
  115. //alert(document.querySelector("#tsf").value);
  116. //};
  117.  
  118. //<li><button id="goto">Empty</button></li> \
  119. //document.getElementById("goto").addEventListener("click", goTo);
  120. //function goTo() {
  121. // alert(window.find("better"))
  122. // window.find("better")
  123. // var result = document.getElementById("searchbar").value;
  124. // window.location.href = '/user/'+result;
  125. // }
  126.  
  127. //-- Fade panel when not in use
  128. var kbShortcutFired = false;
  129. var rightSideBar = $('#gmRightSideBar');
  130. rightSideBar.hover (
  131. function () {
  132. $(this).stop (true, false).fadeTo (80, 1 );
  133. kbShortcutFired = false;
  134. },
  135. function () {
  136. if ( ! kbShortcutFired ) {
  137. $(this).stop (true, false).fadeTo (900, 2.1);
  138. }
  139. kbShortcutFired = false;
  140. }
  141. );
  142. rightSideBar.fadeTo (2900, 1.1);//off fade
  143.  
  144. //-- Keyboard shortcut to show/hide our sidebar
  145. $(window).keydown (keyboardShortcutHandler);
  146.  
  147. function keyboardShortcutHandler (zEvent) {
  148. //--- On F9, Toggle our panel's visibility
  149. if (zEvent.which == 120) { // F9
  150. kbShortcutFired = true;
  151.  
  152. if (rightSideBar.is (":visible") ) {
  153. rightSideBar.stop (true, false).hide ();
  154. }
  155. else {
  156. //-- Reappear opaque to start
  157. rightSideBar.stop (true, false).show ();
  158. rightSideBar.fadeTo (1, 1);
  159. rightSideBar.fadeTo (290, 0.1);
  160. }
  161.  
  162. zEvent.preventDefault ();
  163. zEvent.stopPropagation ();
  164. return false;
  165. }
  166. }
  167.  
  168. GM_addStyle ( " \
  169. #gmRightSideBar { \
  170. position: fixed; \
  171. top: 135px; \
  172. left: 0; \
  173. margin: 1ex; \
  174. padding: 1em; \
  175. background: orange; \
  176. width: 130px; \
  177. z-index: 6666; \
  178. opacity: 1.9; \
  179. } \
  180. #gmRightSideBar p { \
  181. font-size: 80%; \
  182. } \
  183. #gmRightSideBar ul { \
  184. margin: 0ex; \
  185. } \
  186. #gmRightSideBar a { \
  187. color: blue; \
  188. } \
  189. " );