Alternative search engines 2

Adds search on other sites for google, bing, yandex, nigma, wolfram-alpha and ru-wiki

目前为 2015-04-02 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Alternative search engines 2
  3. // @description Adds search on other sites for google, bing, yandex, nigma, wolfram-alpha and ru-wiki
  4. // @namespace 2k1dmg@userscript
  5. // @license GPL version 3 or any later version; http://www.gnu.org/copyleft/gpl.html
  6. // @version 0.0.1
  7. // @grant none
  8. // @match *://www.google.ru/*
  9. // @match *://www.google.com/*
  10. // @match *://www.google.by/*
  11. // @match *://www.google.kz/*
  12. // @match *://www.google.com.ua/*
  13. // @match *://www.google.com.tr/*
  14. // @match *://www.google.am/*
  15. // @match *://www.google.az/*
  16. // @match *://www.google.ee/*
  17. // @match *://www.google.fi/*
  18. // @match *://www.google.ge/*
  19. // @match *://www.google.kg/*
  20. // @match *://www.google.lt/*
  21. // @match *://www.google.lv/*
  22. // @match *://www.google.md/*
  23. // @match *://www.google.tm/*
  24. // @match *://www.google.co.uz/*
  25. // @match *://www.google.de/*
  26. // @match *://www.wolframalpha.com/*
  27. // @match *://www3.wolframalpha.com/*
  28. // @match *://yandex.ru/*
  29. // @match *://nigma.ru/*
  30. // @match *://www.bing.com/*
  31. // @match *://ru.wikipedia.org/w/*
  32. // @match *://nova.rambler.ru/*
  33. // @match *://rambler.ru/*
  34. // ==/UserScript==
  35.  
  36. // 2015-04-02
  37.  
  38. var onDOMLoad = function() {
  39. var SEARCH_ON = '\u0418\u0441\u043a\u0430\u0442\u044c \u043d\u0430:';
  40. var POSITION = 'left'; //'left','right'
  41.  
  42. var ENGINES = {
  43. //Yahoo: 'http://search.yahoo.com/search?p=',
  44. //Baidu: 'http://www.baidu.com/s?wd=',
  45. \u042f\u043d\u0434\u0435\u043a\u0441: 'https://yandex.ru/yandsearch?text=',
  46. Google: 'https://www.google.com/search?q=',
  47. Bing: 'https://www.bing.com/search?q=',
  48. WolframAlpha: 'http://www3.wolframalpha.com/input/?i=',
  49. //Rambler: 'http://nova.rambler.ru/search?query=',
  50. Nigma: 'http://nigma.ru/?s=',
  51. //Twitter: 'http://www.twitter.com/search?q=',
  52. Wikipedia: 'http://ru.wikipedia.org/w/index.php?search=',
  53. };
  54.  
  55. var PLACEHOLDER_SELECTORS = [
  56. '#resultStats', // google
  57. '.sb_count', // bing
  58. '.b-wordstat__text',
  59. '.searchresults b',
  60. '#ext_link',
  61. '.b-global-wrapper',
  62. '.content__left' // yandex
  63. ].join(',');
  64.  
  65. var INPUT_FIELD_SELECTORS = [
  66. '.lst',
  67. '.b-form-checkbox__checkbox',
  68. '#searchText',
  69. '#gbqfq',
  70. '#query',
  71. '#i',
  72. '#sb_form_q', // bing
  73. '.b-search-block__form_left_input',
  74. '#lst-ib', // google
  75. '.input__control' // yandex
  76. ].join(',');
  77.  
  78. var results = document.querySelector(PLACEHOLDER_SELECTORS);
  79. if (!results) {
  80. return;
  81. }
  82.  
  83. var div = document.getElementById('oeid');
  84. if (!div) {
  85. div = document.createElement('div');
  86. div.id = 'oeid';
  87. div.style.display = 'inline-block'
  88. div.style.paddingRight = '10px';
  89. div.style.paddingBottom = '3px';
  90. div.style.color = '#737373';
  91. div.style.fontFamily = 'Calibri, Sans-serif';
  92. div.style.fontSize = '11px';
  93. div.style.textAlign = POSITION;
  94. div.style.zIndex = '10000';
  95. results.insertBefore(div, results.firstChild);
  96. }
  97.  
  98. var links = '';
  99. for (var engine in ENGINES) {
  100. links = links + ", <a href=\'javascript:void(0)\' onclick=\"javascript:var q;if((q=document.querySelector(\'" + INPUT_FIELD_SELECTORS + "\')).value.length>0){;window.open(\'" + ENGINES[engine] + "\'+encodeURIComponent(q.value))};\">" + engine + "</a>";
  101. }
  102.  
  103. div.innerHTML = '<b>' + SEARCH_ON + '</b> ' + links.slice(3);
  104. };
  105.  
  106. document.addEventListener("DOMContentLoaded", function() {
  107. onDOMLoad();
  108. }, false);
  109.  
  110. document.addEventListener("DOMNodeInserted", function(event) {
  111. var node = event.target;
  112. if (node.querySelector && node.querySelector('#resultStats'))
  113. onDOMLoad();
  114. }, false);
  115.