搜索引擎切换器2(侧栏版)

搜索引擎切换小助手,支持百度(Baidu)、谷歌(Google)、必应(Bing)、360/360AI、神马/夸克、搜狗、f搜、头条、Yandex、Duckgo、雅虎(Yahoo)、Qwant、SwissCows、秘塔AI、天工AI等28个站点,支持更改排序和显示(在代码中)

  1. // ==UserScript==
  2. // @name 搜索引擎切换器2(侧栏版)
  3. // @namespace https://github.com/qq943260285
  4. // @version 2.0.3
  5. // @description 搜索引擎切换小助手,支持百度(Baidu)、谷歌(Google)、必应(Bing)、360/360AI、神马/夸克、搜狗、f搜、头条、Yandex、Duckgo、雅虎(Yahoo)、Qwant、SwissCows、秘塔AI、天工AI等28个站点,支持更改排序和显示(在代码中)
  6. // @author 小宇专属
  7. // @license GPL-3.0-only
  8. // @include *keyword=*
  9. // @include *query=*
  10. // @include *word=*
  11. // @include *text=*
  12. // @include *key=*
  13. // @include *web=*
  14. // @include *wd=*
  15. // @include *kw=*
  16. // @include *q=*
  17. // @include *p=*
  18. // @include *.tiangong.com/*
  19. // @include *.sou.com/*
  20. // @exclude *image*
  21. // @exclude *video*
  22. // @grant GM_addStyle
  23. // ==/UserScript==
  24. "use strict";
  25.  
  26. (function() {
  27. window.WeltTool = function(config) {
  28. if (!config) config = {};
  29. if (!config.id) config.id = "xyzs-welt-tool";
  30. if (!config.itemList || !config.itemList.length) config.itemList = [];
  31. var mainDivDom, titleDiv = document.createElement("style"), bodyDom = document.getElementsByTagName("body")[0];
  32. if (titleDiv.innerHTML = ".xyzs-welt-tool{position:fixed;width:124px !important;height:200px;display:flex;background-color:#C1FFFB;opacity:.3;border-radius:10px;padding:5px 40px 5px 5px;flex-direction:column;bottom:200px;left:-148px;z-index:99999;transition:all .4s;overflow:hidden;}.xyzs-welt-tool:hover{opacity:1;background-color:hsla(200, 40%, 96%,.9);left:5px;overflow-y:scroll;padding:5px 10px;transition:all .4s;height:300px;}.xyzs-welt-tool .xyzs-title-div{font-size:6px;padding:0 0 2px;margin:0 5px 5px;text-align: center;color:#067;border-bottom:1px solid currentColor;line-height: 7px;}.xyzs-welt-tool .xyzs-item-list-div{margin:0;display:flex;justify-content:center;align-items:center;flex-direction:row;flex-wrap:wrap;}.xyzs-welt-tool .xyzs-item-list-div .xyzs-item-div{display:flex;width:max-content !important;margin:2px 2px;padding:4px;color:#222;font-size:13px !important;cursor:pointer;white-space:nowrap;box-sizing:border-box;}.xyzs-welt-tool .xyzs-item-list-div .xyzs-item-div:hover{color:#067;transition:all .4s;}", bodyDom.appendChild(titleDiv), (mainDivDom = document.createElement("div")).id = config.id,
  33. mainDivDom.className = "xyzs-welt-tool", config.color) mainDivDom.style.backgroundColor = config.color;
  34. if (mainDivDom.onmouseout = function(e) {
  35. }, mainDivDom.onmouseover = function(e) {
  36. }, void 0 !== config.title) {
  37. titleDiv = document.createElement("div");
  38. titleDiv.className = "xyzs-title-div", titleDiv.innerHTML = decodeURI(config.title),
  39. mainDivDom.appendChild(titleDiv);
  40. }
  41. var listDivDom = document.createElement("div");
  42. listDivDom.className = "xyzs-item-list-div";
  43. for (var i = 0; i < config.itemList.length; i++) (function(itemDiv) {
  44. var item = config.itemList[itemDiv];
  45. if (item.show(item.data)) {
  46. if (item.onload) item.onload(item.data);
  47. itemDiv = document.createElement("div");
  48. itemDiv.className = "xyzs-item-div", itemDiv.title = item.title, itemDiv.onclick = function(e) {
  49. if (item.onclick) item.onclick(e, item.data);
  50. }, itemDiv.onmouseout = function(e) {
  51. if (item.onmouseout) item.onmouseout(e, item.data);
  52. }, itemDiv.onmouseover = function(e) {
  53. if (item.onmouseover) item.onmouseover(e, item.data);
  54. }, itemDiv.innerHTML = item.name, listDivDom.appendChild(itemDiv);
  55. }
  56. })(i);
  57. mainDivDom.appendChild(listDivDom), bodyDom.appendChild(mainDivDom)
  58. };
  59. })(), function() {
  60. function getKeywordString() {
  61. for (var i = 0; i < searchList.length; i++) {
  62. var urlParam = searchList[i];
  63. if (matchItemHost(urlParam)) {
  64. urlParam = function(url) {
  65. for (var pList = url.substring(url.indexOf("?") + 1).split("&"), i = 0; i < pList.length; i++) {
  66. var pair = pList[i].split("=");
  67. if (pair[1] === CONFIG.KeywordSymbol) return pair[0];
  68. }
  69. return !1;
  70. }(urlParam.searchUrl), urlParam = function(url, name) {
  71. for (var pList = url.substring(url.indexOf("?") + 1).split("&"), i = 0; i < pList.length; i++) {
  72. var pair = pList[i].split("=");
  73. if (pair[0] === name) return pair[1];
  74. }
  75. return !1;
  76. }(window.location.href, urlParam);
  77. return urlParam;
  78. }
  79. }
  80. return "";
  81. }
  82. function createDiv() {
  83. for (var itemList = [], _loop = function(i) {
  84. var search = searchList[i];
  85. itemList.push({
  86. name: search.name,
  87. title: search.host,
  88. onclick: function(e, data) {
  89. window.open(function(search) {
  90. var keywordString = getKeywordString();
  91. return search.searchUrl.replaceAll(CONFIG.KeywordSymbol, keywordString);
  92. }
  93. /*将_blank改为_self即可在当前标签页切换搜索引擎*/
  94. (search), "_blank");
  95. },
  96. show: function(data) {
  97. return search.show && !matchItemHost(search);
  98. },
  99. data: search
  100. });
  101. }, i = 0; i < searchList.length; i++) _loop(i);
  102. new WeltTool({
  103. title: "“"+getKeywordString()+"”",
  104. itemList: itemList
  105. });
  106. }
  107. function matchItemHost(item) {
  108. if (item.host === window.location.host) return 1;
  109. var countryHost = item.countryHost;
  110. if (countryHost && 0 < countryHost.length) for (var j = 0; j < countryHost.length; j++) if (countryHost[j] === window.location.host) return 1;
  111. return;
  112. }
  113. var SEARCH_TYPE_RequestParam = 0, CONFIG = {
  114. KeywordSymbol: "%s",
  115. DivId: "xyzs-search",
  116. defaultSearchType: SEARCH_TYPE_RequestParam,
  117. defaultCustomize: !1
  118. }, searchList = [ {
  119. index: 1,
  120. name: "百度",
  121. host: "www.baidu.com",
  122. searchUrl: "https://www.baidu.com/s?word=%s",
  123. searchType: SEARCH_TYPE_RequestParam,
  124. show: !0,
  125. countryHost: [ "m.baidu.com","wap.baidu.com" ]
  126. }, {
  127. index: 2,
  128. name: "Bing",
  129. host: "bing.com",
  130. searchUrl: "https://bing.com/search?q=%s",
  131. searchType: SEARCH_TYPE_RequestParam,
  132. show: !0,
  133. countryHost: ["cn.bing.com","www.bing.com"]
  134. },{
  135. index: 3,
  136. name: "Google",
  137. host: "www.google.com",
  138. searchUrl: "https://www.google.com/search?q=%s",
  139. searchType: SEARCH_TYPE_RequestParam,
  140. show: !0,
  141. countryHost: [ "www.goo.gl", "www.google.com.af", "www.google.com.ag", "www.google.com.ai", "www.google.com.ar", "www.google.com.au", "www.google.com.bd", "www.google.com.bh", "www.google.com.bn", "www.google.com.bo", "www.google.com.br", "www.google.com.by", "www.google.com.bz", "www.google.com.co", "www.google.com.co.jp", "www.google.com.cu", "www.google.com.cy", "www.google.com.do", "www.google.com.ec", "www.google.com.eg", "www.google.com.et", "www.google.com.fj", "www.google.com.ge", "www.google.com.gh", "www.google.com.gi", "www.google.com.gr", "www.google.com.gt", "www.google.com.hk", "www.google.com.iq", "www.google.com.jm", "www.google.com.jo", "www.google.com.kh", "www.google.com.kw", "www.google.com.lb", "www.google.com.ly", "www.google.com.mm", "www.google.com.mt", "www.google.com.mx", "www.google.com.my", "www.google.com.na", "www.google.com.nf", "www.google.com.ng", "www.google.com.ni", "www.google.com.np", "www.google.com.nr", "www.google.com.om", "www.google.com.pa", "www.google.com.pe", "www.google.com.pg", "www.google.com.ph", "www.google.com.pk", "www.google.com.pr", "www.google.com.py", "www.google.com.qa", "www.google.com.ru", "www.google.com.sa", "www.google.com.sb", "www.google.com.sg", "www.google.com.sl", "www.google.com.sv", "www.google.com.tj", "www.google.com.tr", "www.google.com.tw", "www.google.com.ua", "www.google.com.uy", "www.google.com.vc", "www.google.com.vn", "www.google.ac", "www.google.ad", "www.google.ae", "www.google.af", "www.google.ag", "www.google.al", "www.google.am", "www.google.as", "www.google.at", "www.google.az", "www.google.ba", "www.google.be", "www.google.bf", "www.google.bg", "www.google.bi", "www.google.bj", "www.google.bs", "www.google.bt", "www.google.by", "www.google.bo", "www.google.ca", "www.google.cat", "www.google.cc", "www.google.cd", "www.google.cf", "www.google.cg", "www.google.ch", "www.google.ci", "www.google.cl", "www.google.cm", "www.google.co", "www.google.cv", "www.google.cz", "www.google.co.ao", "www.google.co.bw", "www.google.co.ck", "www.google.co.cr", "www.google.co.hu", "www.google.co.id", "www.google.co.il", "www.google.co.im", "www.google.co.in", "www.google.co.je", "www.google.co.jp", "www.google.co.ke", "www.google.co.kr", "www.google.co.ls", "www.google.co.ma", "www.google.co.mz", "www.google.co.nz", "www.google.co.th", "www.google.co.tz", "www.google.co.ug", "www.google.co.uk", "www.google.co.uz", "www.google.co.ve", "www.google.co.vi", "www.google.co.za", "www.google.co.zm", "www.google.co.zw", "www.google.de", "www.google.dj", "www.google.dk", "www.google.dm", "www.google.do", "www.google.dz", "www.google.ec", "www.google.ee", "www.google.es", "www.google.hk", "www.google.mx", "www.google.ng", "www.google.ph", "www.google.pk", "www.google.pl", "www.google.pn", "www.google.ps", "www.google.pt", "www.google.qa", "www.google.ro", "www.google.rs", "www.google.ru", "www.google.rw", "www.google.sc", "www.google.se", "www.google.sh", "www.google.si", "www.google.sk", "www.google.sm", "www.google.sn", "www.google.so", "www.google.st", "www.google.sg", "www.google.sl", "www.google.td", "www.google.tg", "www.google.tw", "www.google.tk", "www.google.tl", "www.google.tm", "www.google.tn", "www.google.to", "www.google.tt", "www.google.ua", "www.google.vg", "www.google.vn", "www.google.vu", "www.google.ws" ]
  142. }, {
  143. index: 4,
  144. name: "360搜索",
  145. host: "www.so.com",
  146. searchUrl: "https://www.so.com/s?q=%s",
  147. searchType: SEARCH_TYPE_RequestParam,
  148. show: !0,
  149. countryHost: [ "m.so.com" ]
  150. }, {
  151. index: 5,
  152. name: "神马",
  153. host: "yz.m.sm.cn",
  154. searchUrl: "https://yz.m.sm.cn/s?q=%s",
  155. searchType: SEARCH_TYPE_RequestParam,
  156. show: !0,
  157. countryHost: [ ]
  158. },{
  159. index: 6,
  160. name: "搜狗",
  161. host: "wap.sogou.com",
  162. searchUrl: "https://wap.sogou.com/web/sl?keyword=%s",
  163. searchType: SEARCH_TYPE_RequestParam,
  164. show: !1,/*默认隐藏,将1改为0显示*/
  165. countryHost: [ "www.sogou.com","m.sogou.com" ]
  166. },{
  167. index: 7,
  168. name: "f搜",
  169. host: "fsoufsou.com",
  170. searchUrl: "https://fsoufsou.com/search?q=%s",
  171. searchType: SEARCH_TYPE_RequestParam,
  172. show: !1,/*默认隐藏,将1改为0显示*/
  173. },
  174. {
  175. index: 8,
  176. name: "头条搜索",
  177. host: "so.toutiao.com",
  178. searchUrl: "https://so.toutiao.com/search?keyword=%s",
  179. searchType: SEARCH_TYPE_RequestParam,
  180. show: !0,
  181. countryHost:["tsearch.toutiaoapi.com"]
  182. },{
  183. index: 9,
  184. name: "Duckgo",
  185. host: "duckduckgo.com",
  186. searchUrl: "https://duckduckgo.com/?q=%s",
  187. searchType: SEARCH_TYPE_RequestParam,
  188. show: !1,/*默认隐藏,将1改为0显示*/
  189. countryHost: [ ]
  190. },{
  191. index: 10,
  192. name: "Yandex",
  193. host: "www.yandex.com",
  194. searchUrl: "https://www.yandex.com/search/touch/?text=%s",
  195. searchType: SEARCH_TYPE_RequestParam,
  196. show: !0,
  197. countryHost: [ "yandex.ru" ]
  198. },{
  199. index: 11,
  200. name: "Yahoo",
  201. host: "search.yahoo.com",
  202. searchUrl: "https://search.yahoo.com/search?p=%s",
  203. searchType: SEARCH_TYPE_RequestParam,
  204. show: !1,/*默认隐藏,将1改为0显示*/
  205. },{
  206. index: 12,
  207. name: "Brave",
  208. host: "search.brave.com",
  209. searchUrl: "https://search.brave.com/search?q=%s",
  210. searchType: SEARCH_TYPE_RequestParam,
  211. show: !1,/*默认隐藏,将1改为0显示*/
  212. },{
  213. index: 13,
  214. name: "Ecosia",
  215. host: "www.ecosia.org",
  216. searchUrl: "https://www.ecosia.org/search?q=%s",
  217. searchType: SEARCH_TYPE_RequestParam,
  218. show: !1,/*默认隐藏,将1改为0显示*/
  219. },{
  220. index: 14,
  221. name: "Qwant",
  222. host: "www.qwant.com",
  223. searchUrl: "https://www.qwant.com/?q=%s",
  224. searchType: SEARCH_TYPE_RequestParam,
  225. show: !0,
  226. countryHost: [ "lite.qwant.com" ]
  227. },{
  228. index: 15,
  229. name: "SwissCows",
  230. host: "swisscows.com",
  231. searchUrl: "https://swisscows.com/en/web?query=%s",
  232. searchType: SEARCH_TYPE_RequestParam,
  233. show: !0
  234. },{
  235. index: 16,
  236. name: "Yep",
  237. host: "yep.com",
  238. searchUrl: "https://yep.com/web?q=%s",
  239. searchType: SEARCH_TYPE_RequestParam,
  240. show: !1,/*默认隐藏,将1改为0显示*/
  241. },{
  242. index: 17,
  243. name: "夸克",
  244. host: "quark.sm.cn",
  245. searchUrl: "https://quark.sm.cn/s?q=%s",
  246. searchType: SEARCH_TYPE_RequestParam,
  247. show: !1,/*默认隐藏,将1改为0显示*/
  248. },{
  249. index: 18,
  250. name: "秘塔AI",
  251. host: "metaso.cn",
  252. searchUrl: "https://metaso.cn/?q=%s",
  253. searchType: SEARCH_TYPE_RequestParam,
  254. show: !0,
  255. countryHost: [ ]
  256. },{
  257. index: 19,
  258. name: "天工AI",
  259. host: "www.tiangong.com",
  260. searchUrl: "https://www.tiangong.cn/result?q=%s",
  261. searchType: SEARCH_TYPE_RequestParam,
  262. show: !0,
  263. countryHost: [ "m.tiangong.com" ]
  264. },{
  265. index: 20,
  266. name: "ThinkanyAI",
  267. host: "thinkany.so",
  268. searchUrl: "https://thinkany.so/zh/search?source=all&q=%s",
  269. searchType: SEARCH_TYPE_RequestParam,
  270. show: !0,
  271. countryHost: [ ]
  272. },{
  273. index: 21,
  274. name: "十号AI",
  275. host: "retardphobia.moebh.org",
  276. searchUrl: "https://retardphobia.moebh.org/ui/search?mode=1&q=%s",
  277. searchType: SEARCH_TYPE_RequestParam,
  278. show: !0,
  279. countryHost: [ ]
  280. },{
  281. index: 22,
  282. name: "360AI",
  283. host: "www.sou.com",
  284. searchUrl: "https://www.sou.com/?q=%s",
  285. searchType: SEARCH_TYPE_RequestParam,
  286. show: !0,
  287. countryHost: [ "m.sou.com" ]
  288. },{
  289. index: 23,
  290. name: "知乎搜索",
  291. host: "www.zhihu.com",
  292. searchUrl: "https://www.zhihu.com/search?q=%s&type=content",
  293. searchType: SEARCH_TYPE_RequestParam,
  294. show: !0,
  295. countryHost: [ "m.zhihu.com" ]
  296. },{
  297. index: 24,
  298. name: "微博",
  299. host: "m.weibo.cn",
  300. searchUrl: "https://m.weibo.cn/search?containerid=100103type=1&q=%s",
  301. searchType: SEARCH_TYPE_RequestParam,
  302. show: !0,
  303. countryHost: [ "www.weibo.com" ]
  304. },{
  305. index: 25,
  306. name: "B站",
  307. host: "m.bilibili.com",
  308. searchUrl: "https://m.bilibili.com/search?keyword=%s",
  309. searchType: SEARCH_TYPE_RequestParam,
  310. show: !0,
  311. countryHost: ["search.bilibili.com"]
  312. },{
  313. index: 26,
  314. name: "微信文章",
  315. host: "weixin.sogou.com",
  316. searchUrl: "https://weixin.sogou.com/weixinwap?type=2&query=%s",
  317. searchType: SEARCH_TYPE_RequestParam,
  318. show: !0,
  319. },{
  320. index: 27,
  321. name: "GitHub",
  322. host: "github.com",
  323. searchUrl: "https://github.com/search?o=desc&q=%s&s=stars&type=Repositories",
  324. searchType: SEARCH_TYPE_RequestParam,
  325. show: !1,/*默认隐藏,将1改为0显示*/
  326. },{
  327. index: 28,
  328. name: "Gitee",
  329. host: "search.gitee.com",
  330. searchUrl: "https://search.gitee.com/?q=%s",
  331. searchType: SEARCH_TYPE_RequestParam,
  332. show: !1,/*默认隐藏,将1改为0显示*/
  333. },{
  334. index: 29,/*序号,用来排序的*/
  335. name: "GreasyFork",/*名字,用来显示的*/
  336. host: "greasyfork.org",/*应用到此域名*/
  337. searchUrl: "https://greasyfork.org/zh-CN/scripts?q=%s",
  338. searchType: SEARCH_TYPE_RequestParam,
  339. show: !0,/*默认显示,将0改为1隐藏*/
  340. countryHost: [ "sleazyfork.org" ],/*相似域名*/
  341. },
  342. ];
  343. (function() {
  344. if (top !== window) return;
  345. for (var i = 0; i < searchList.length; i++) if (matchItemHost(searchList[i])) return createDiv();
  346. })();
  347. }();