altsearch links

Adds search on other sites for google, bing, and yahoo

当前为 2020-01-16 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name altsearch links
  3. // @description Adds search on other sites for google, bing, and yahoo
  4. // @version 0.1.6.2
  5. // @include http://www.google.com*
  6. // @include https://*.google.com*
  7. // @include http://www.google.com*
  8. // @include https://www.google.com*
  9. // @include https://duckduckgo.com*
  10. // @include http://duckduckgo.com*
  11. // @include http://www.wolframalpha.com*
  12. // @include http://www3.wolframalpha.com*
  13. // @include http://yandex.ru*
  14. // @include http://nigma.ru*
  15. // @include http://www.bing.com*
  16. // @include http://www.bing.com/*
  17. // @include https://www.bing.com*
  18. // @include http://ru.wikipedia.org/w/*
  19. // @include http://nova.rambler.ru/*
  20. // @include http://rambler.ru/*
  21. // @include http://scholar.google.com*
  22. // @include http://search.yahoo.com*
  23. // @include https://search.yahoo.com*
  24. // @include http://academic.research.microsoft.com/*
  25. // @grant none
  26. // @namespace https://greasyfork.org/users/9631
  27. // ==/UserScript==
  28.  
  29. var SEARCH_ON = 'Search on:';
  30. var POSITION = 'left';
  31.  
  32.  
  33.  
  34. var PLACEHOLDER_SELECTORS = '#resultStats, #b_results, .b-wordstat__text, .searchresults b, #ext_link, #sidebar, .b-global-wrapper, #gs_ab, #left, #zero_click_wrapper, bing-summary, .bing-summary, #bing-summary';
  35. var results = document.querySelector(PLACEHOLDER_SELECTORS);
  36. var other = document.createElement('div');
  37.  
  38. other.setAttribute("id", "altsearch");
  39. other.setAttribute("style", "width: 1000px; font-size: small; margin: 10px 10px 5px 159px;");
  40.  
  41. if (window.location.href.indexOf("?query=") > -1) {
  42. query = window.location.href.match(/\?query=[^&]*/gi)[0].substr(7);
  43. } else if (window.location.href.indexOf("?q=") > -1) {
  44. query = window.location.href.match(/\?q=[^&]*/gi)[0].substr(3);
  45. } else {
  46. query = window.location.href.match(/\?p=[^&]*/gi)[0].substr(3);}
  47. query = query.replace(/\+filterui%3[^&^+]*/gi,"");
  48. links = "Try this search on " +
  49. "<a href =\"https://www.google.com/search?q=" + query + "\">Google</a>, " +
  50. "<a href =\"http://www.bing.com/search?q=" + query + "\">Bing</a>, " +
  51. "<a href =\"http://search.yahoo.com/search?p=" + query + "\">Yahoo</a>, " +
  52. "<a href =\"http://www.swagbucks.com/?f=51&t=w&p=1&q=" + query + "\">Swagbucks</a>. " +
  53. "<a href =\"https://duckduckgo.com/?q=" + query + "\">DuckDuckGo</a>, " +
  54. "<a href =\"http://www.wolframalpha.com/input/?i=" + query + "\">WolframAlpha</a>, " +
  55. "<a href =\"http://twitter.com/search?q=" + query + "\">Twitter</a>, " +
  56. "<a href =\"http://scholar.google.com/scholar?q=" + query + "\">Google Scholar</a>, " +
  57. "<a href =\"http://academic.research.microsoft.com/Search?query=" + query + "\">MS Academic</a>";
  58. other.innerHTML = links;
  59.  
  60. if (window.location.host == "www.bing.com") {
  61. console.log("bing baby!");
  62. var bingBottomResults = document.querySelector(".b_pag");
  63. var other2 = other.cloneNode(true);
  64. bingBottomResults.parentNode.insertBefore(other2, bingBottomResults);
  65. }
  66.  
  67. results.parentNode.insertBefore(other, results);