鸭子倒悬!

在 DuckDuckGo 的搜索结果中添加几个按钮,快速在其它搜索引擎重新搜索。

  1. // ==UserScript==
  2. // @name UnDuckButton
  3. // @name:zh-CN 鸭子倒悬!
  4. // @namespace Violentmonkey Scripts
  5. // @match https://duckduckgo.com/*
  6. // @grant none
  7. // @version 0.3.1
  8. // @author noarch
  9. // @description Buttons that redirect DuckDuckGo searches to other search engines
  10. // @description:zh-cn 在 DuckDuckGo 的搜索结果中添加几个按钮,快速在其它搜索引擎重新搜索。
  11. // @license WTFPL
  12. // ==/UserScript==
  13. // Searx instances from https://searx.neocities.org/nojs.html
  14. // Updated 2021-01-15
  15. var searxes = [
  16. "https://searx.ir/?q=",
  17. "https://search.stinpriza.org/?q=",
  18. "https://search.privacytools.io/searx/?q=",
  19. "https://search.azkware.net/?q=",
  20. "https://searx.openpandora.org/?q=",
  21. "https://trovu.komun.org/?q=",
  22. "https://searx.nakhan.net/?q=",
  23. "https://searx.nixnet.services/?q=",
  24. "https://searx.libmail.eu/?q=",
  25. "https://searx.elukerio.org/?q=",
  26. "https://searx.info/?q=",
  27. "https://searx.foo.li/?q="
  28. ];
  29. var randomSearx = searxes[Math.floor(Math.random() * searxes.length)];
  30. // Add more search engines here
  31. var searchEngines = {
  32. //"Bing": "https://www.bing.com/search?q=", // Bing sucks, disabled by default
  33. "Google": "https://www.google.com/search?q=",
  34. "Searx": randomSearx,
  35. "Startpage": "https://startpage.com/sp/search?query="
  36. };
  37. function getSearchQuery() {
  38. var input = document.getElementById("search_form_input").value;
  39. var inputEncoded = encodeURIComponent(input);
  40. return inputEncoded;
  41. }
  42. function newButton(text, href) {
  43. var a = document.createElement("a"); // allow opening in a new tab
  44. var btn = document.createElement("button");
  45.  
  46. a.href = href;
  47. btn.innerHTML = text;
  48. a.appendChild(btn);
  49.  
  50. return a;
  51. }
  52. function main() {
  53. searchQuery = getSearchQuery(); // Failing here is fine, just exit if we can't find the search terms
  54. // Create styles for the <div> containing the buttons
  55. var styles = ".redirectors {display: block; margin: 60px auto auto auto; right: 4px; position: absolute; bottom: 0; top: 0;}";
  56. var styleSheet = document.createElement("style");
  57. styleSheet.type = "text/css";
  58. styleSheet.innerText = styles;
  59. var div = document.createElement("div");
  60. div.classList.add("redirectors");
  61. for (var searchEngine in searchEngines) {
  62. href = searchEngines[searchEngine] + searchQuery;
  63. div.appendChild(newButton(searchEngine, href));
  64. }
  65. document.head.appendChild(styleSheet);
  66. document.getElementById("header_wrapper").appendChild(div);
  67. }
  68. main();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址