altsearch links

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

  1. // ==UserScript==
  2. // @name altsearch links
  3. // @description Adds search on other sites for google, bing, and yahoo
  4. // @version 2020.02.20
  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 https://www.bing.com*
  17. // @include http://ru.wikipedia.org/w/*
  18. // @include http://nova.rambler.ru/*
  19. // @include http://rambler.ru/*
  20. // @include http://scholar.google.com*
  21. // @include http://search.yahoo.com*
  22. // @include https://search.yahoo.com*
  23. // @include http://academic.research.microsoft.com/*
  24. // @grant none
  25. // @namespace https://greasyfork.org/users/9631
  26. // ==/UserScript==
  27.  
  28. //var SEARCH_ON = 'Search on:';
  29. //var POSITION = 'left';
  30.  
  31.  
  32.  
  33. 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, #ucs';
  34. var results = document.querySelector(PLACEHOLDER_SELECTORS);
  35. var other = document.createElement('div');
  36.  
  37. other.setAttribute("id", "altsearch");
  38. other.setAttribute("style", "width: 1000px; font-size: small; margin: 10px 10px 5px 159px;");
  39.  
  40. if (window.location.href.indexOf("?query=") > -1) {
  41. query = window.location.href.match(/\?query=[^&]*/gi)[0].substr(7);
  42. } else if (window.location.href.indexOf("?q=") > -1) {
  43. query = window.location.href.match(/\?q=[^&]*/gi)[0].substr(3);
  44. } else if (window.location.href.indexOf("&q=") > -1 ) {
  45. query = window.location.href.match(/\&q=[^&]*/gi)[0].substr(3);
  46.  
  47. } else {
  48. query = window.location.href.match(/\?p=[^&]*/gi)[0].substr(3);
  49. }
  50.  
  51. query = query.replace(/\+filterui%3[^&^+]*/gi,"");
  52. links = "Try this search on " +
  53. "<a href =\"https://www.google.com/search?q=" + query + "\">Google</a>, " +
  54. "<a href =\"http://www.bing.com/search?q=" + query + "\">Bing</a>, " +
  55. "<a href =\"http://search.yahoo.com/search?p=" + query + "\">Yahoo</a>, " +
  56. "<a href =\"http://www.swagbucks.com/?f=51&t=w&p=1&q=" + query + "\">Swagbucks</a>, " +
  57. "<a href =\"https://duckduckgo.com/?q=" + query + "\">DuckDuckGo</a>, " +
  58. "<a href =\"http://www.wolframalpha.com/input/?i=" + query + "\">WolframAlpha</a>, " +
  59. "<a href =\"http://twitter.com/search?q=" + query + "\">Twitter</a>, " +
  60. "<a href =\"http://scholar.google.com/scholar?q=" + query + "\">Google Scholar</a>, " +
  61. "<a href =\"http://academic.research.microsoft.com/Search?query=" + query + "\">MS Academic</a>";
  62. other.innerHTML = links;
  63.  
  64. if (window.location.host == "www.bing.com") {
  65. console.log("bing baby!");
  66. var bingBottomResults = document.querySelector(".b_pag");
  67. var other2 = other.cloneNode(true);
  68. //bingBottomResults.parentNode.insertBefore(other2, bingBottomResults);
  69. bingBottomResults.before(other2);
  70. }
  71.  
  72. //results.parentNode.insertBefore(other, results); //this is old way next line is new way https://gomakethings.com/how-to-insert-an-element-before-another-one-in-the-dom-with-vanilla-javascript/
  73. results.before(other);