优雅的搜索引擎助手

“优雅的搜索引擎助手”方便用户在不同的搜索引擎之间跳转;支持自定义常用搜索引擎、关键词高亮渲染;还提供去除搜索链接重定向、屏蔽搜索结果广告、使用关键词过滤搜索结果、和自动更新检测等高级功能;兼容如Baidu、Google、Bing、Duckduckgo、Yandex、Sogou、Qwant、Ecosia、You、Startpage、Brave、Yahoo、Yep、Swisscows、searXNG等多个搜索引擎。

当前为 2025-05-03 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Google & baidu Switcher (ALL in One)
  3. // @name:en Search Engine Assistant
  4. // @name:zh-CN 优雅的搜索引擎助手
  5. // @name:zh-TW 優雅的搜尋引擎助手
  6. // @name:ru помощник поисковых систем
  7. // @name:ja 優雅な検索エンジン助手
  8. // @version 2025.05.03.1
  9. // @author F9y4ng
  10. // @description “Elegant Search Engine Assistant” facilite la navigation entre moteurs de recherche, personnalise les préférences, met en évidence les mots-clés, élimine les redirections et publicités, et filtre les résultats. Compatible avec divers moteurs tels que Baidu, Google, Bing, Duckduckgo, Yandex, Sogou, Qwant, Ecosia, You, Startpage, Brave, etc.
  11. // @description:en "Elegant search engine assistant" allows switching between engines; supports custom engines, keyword highlighting; offers redirect removal, ad blocking, keyword filtering, and auto-updates; compatible with Baidu, Google, Bing, Duckduckgo, Yandex, Sogou, Qwant, Ecosia, You, Startpage, Brave, Yahoo, Yep, Swisscows, searXNG and more.
  12. // @description:zh-CN “优雅的搜索引擎助手”方便用户在不同的搜索引擎之间跳转;支持自定义常用搜索引擎、关键词高亮渲染;还提供去除搜索链接重定向、屏蔽搜索结果广告、使用关键词过滤搜索结果、和自动更新检测等高级功能;兼容如Baidu、Google、Bing、Duckduckgo、Yandex、Sogou、Qwant、Ecosia、You、Startpage、Brave、Yahoo、Yep、Swisscows、searXNG等多个搜索引擎。
  13. // @description:zh-TW 「優雅的搜尋引擎助手」方便使用者在不同的搜尋引擎之間跳轉;支援自定義常用搜尋引擎、關鍵詞高亮渲染;還提供去除搜尋連結重定向、遮蔽搜尋結果廣告、使用關鍵詞過濾搜尋結果、和自動更新檢測等高階功能;相容如Baidu、Google、Bing、Duckduckgo、Yandex、Sogou、Qwant、Ecosia、You、Startpage、Brave、Yahoo、Yep、Swisscows、searXNG等多個搜尋引擎。
  14. // @description:ru “Элегантный помощник поисковых систем” обеспечивает удобное переключение между поисковыми системами, поддерживает настройку, выделение ключевых слов и продвинутые функции. совместим с Baidu, Google, Bing, Duckduckgo, Yandex, Sogou, Qwant, Ecosia, You, Startpage, Brave, Yahoo, Yep, Swisscows, searXNG и другими поисковыми системами.
  15. // @description:ja 「優雅な検索エンジン助手」は、検索エンジン間の切り替えを容易にし、カスタムエンジン、キーワードハイライト、リダイレクト削除、広告ブロック、キーワードフィルタリング、自動更新をサポートし、Baidu、Google、Bing、Duckduckgo、Yandex、Sogou、Qwant、Ecosia、You、Startpage、Brave、Yahoo、Yep、Swisscows、searXNGなどと互換性があります。
  16. // @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAAsTAAALEwEAmpwYAAAFC0lEQVR4nO2WbUxTVxjHj8IMWZbt05Yt28y2D3yQRN0++MVsmXFbNjBixbFpkSGvXUt5GRpkgOCgIsgqOANUQCXYOQUKCMqrtDAmiorSwioIytsoIL3ce1olQ+W/3KsFlYov8yUmPsn/w725J//fec7zPPcQ8jJexoscABwsFosLpfRTq9W6CIDTMzFmWfYjSmkux3EWSilsYll2YnBwsNxsNi99auaUUn+O48ZZlkODrgW7lAVIjM9DWuohHD3yF8xmBhzHTXZ2du4B4PhEzVmWDeZ32nq+AxvESfDekIbwHbUIV51F+E4dAuTZEK2IQU3VKSEjBoNBQwiZ80TMx8bGPuY4buLsGSPc3WIQvKcVYVrMUPChAXh4JKC0uEGAKCsri/pfxgCcKKULKKXVfHo9RfGQ5Brtmk9BFJux0jUGl7r7MTAwMLR48eI3H9nYarW+c7vQrtqKTFOgxXrZ3lnNbfJNqEJq8kFhnVKplD+q+SKO40x8ofHn+dvOQuxIUsPPJwUbdttP/b2Sakbh6ZEgAJSUlPxOCJn7UOYMw7xBKb1sMo1AFrgTP/imI0ypw0+7GhG4+Q/Ij12dMgmpnoC02Axp0RUEl1sQVjc5DVE3iS8/3ygA9PT09HV3dwdbLJa3HghAKY3lF23eqIJ/bKn9HdZNIuhAH2S5fyNNewWqE2OIK+6Fb1Yb5Eett+BqJvDVsk3o7zdhdNRsmxPXurq6tswKwLKs0aC/iFWiBITV3bQLEJB3CcmVJuhHgA5mWkc7JhCkaoO8YhySQyYsWxqG1e5xcP0iEnJJOppPtgkger1+/wxjAPMopdH8ECk6rIXXpsP2K7zcgo3qi2g3321uU2HbOPxyO4VvQ6v/vZ2xm5Bnt0K0Mg5VFSeFQaVWq/3vNH+FUlrJ07WcNWJLVA7WRtgHCFL3ocAwbtec1wUzIM1pR2jtjRlrZQVDcHeNBl9fRqPRQAh5zXbuUbz5vpxyrFn9C8JTqhB8eNAugP++LtRcun5fAF7RBZeFY7C33jtcLbQzy7I35s+f/4kAwLfcuZYLELlvhbzi2qztFXigD0Xts2SAAWR8Bmqu213vta0e6cpCoRbEYvFavuff5h/2ZpfDO77igf0tO8Ih8mA3jKP2AUrPU/jsbkXocfsF/H1sJbIyjwgAy5cv/46f8R/wD9lZ5VgXV/1QQyZgfzeUx0fQdg9E7fkxRCY2Iij1DPyyO2bUQejxSazw2I7Tze0YGhoyOzo6fiZcKhiGYfifjJu7YrpyZ1PdTQTm9yBkvxGZjQz2NVMoyv6BX3oLQuL/RFiMDpLkU/DbY5w+irpJeEaWQiLPEnZfWVlZSghxFmqgv78/lX+5XVkC11VJ8EpqgM+ucw+Ut7IZXtsaIFbo4JVyAusSdfCM0EC2ueYWRMpprE9pgjhRCzfPX+ErycDw8ChMJtOos7OzFyFknq0NnXp7e/U8RK1Oj58TixAQkvNYEvumw+2bGIREVQsQPpIcfLtGgYrac3z/86lnRCJROCHkvbsGUX5+/utNTU0FDMOM33nNehztTiuEx8otiIg+BtmPGVBszRPe19fXV7u4uHgTQt6/3ySes2TJkgURERGBCoUi5nGk1+ubeDNVRilErtEI9EmZuhc4ODh8PZX2pxVardbJYDAcuzMjw8PDY1KpNJYQ8i55RjE3MzPTR6PRqFUqVebChQv5tH9InkPMIYS8+jyMyQsT/wHRI0Gp4kJwPQAAAABJRU5ErkJggg==
  17. // @namespace https://github.com/F9y4ng/GreasyFork-Scripts/
  18. // @homepage https://f9y4ng.github.io/GreasyFork-Scripts/
  19. // @homepageURL https://f9y4ng.github.io/GreasyFork-Scripts/
  20. // @supportURL https://github.com/F9y4ng/GreasyFork-Scripts/issues
  21. // @match *://www.baidu.com/*
  22. // @match *://ipv6.baidu.com/*
  23. // @match *://image.baidu.com/search*
  24. // @match *://kaifa.baidu.com/searchPage*
  25. // @match *://*.bing.com/*search*
  26. // @match *://duckduckgo.com/*
  27. // @match *://*.sogou.com/*
  28. // @match *://www.qwant.com/?*
  29. // @match *://www.so.com/s*
  30. // @match *://image.so.com/*
  31. // @match *://so.toutiao.com/search*
  32. // @match *://yandex.com/*search*
  33. // @match *://yandex.ru/*search*
  34. // @match *://yandex.eu/*search*
  35. // @match *://www.ecosia.org/*
  36. // @match *://*.search.yahoo.com/search*
  37. // @match *://*.images.search.yahoo.com/search*
  38. // @match *://you.com/*
  39. // @match *://www.startpage.com/*
  40. // @match *://search.brave.com/*
  41. // @match *://yep.com/*
  42. // @match *://swisscows.com/*
  43. // @match *://search.inetol.net/search*
  44. // @match *://*.google.com/search*
  45. // @match *://*.google.ad/search*
  46. // @match *://*.google.ae/search*
  47. // @match *://*.google.com.af/search*
  48. // @match *://*.google.com.ag/search*
  49. // @match *://*.google.com.ai/search*
  50. // @match *://*.google.al/search*
  51. // @match *://*.google.am/search*
  52. // @match *://*.google.co.ao/search*
  53. // @match *://*.google.com.ar/search*
  54. // @match *://*.google.as/search*
  55. // @match *://*.google.at/search*
  56. // @match *://*.google.com.au/search*
  57. // @match *://*.google.az/search*
  58. // @match *://*.google.ba/search*
  59. // @match *://*.google.com.bd/search*
  60. // @match *://*.google.be/search*
  61. // @match *://*.google.bf/search*
  62. // @match *://*.google.bg/search*
  63. // @match *://*.google.com.bh/search*
  64. // @match *://*.google.bi/search*
  65. // @match *://*.google.bj/search*
  66. // @match *://*.google.com.bn/search*
  67. // @match *://*.google.com.bo/search*
  68. // @match *://*.google.com.br/search*
  69. // @match *://*.google.bs/search*
  70. // @match *://*.google.bt/search*
  71. // @match *://*.google.co.bw/search*
  72. // @match *://*.google.by/search*
  73. // @match *://*.google.com.bz/search*
  74. // @match *://*.google.ca/search*
  75. // @match *://*.google.cd/search*
  76. // @match *://*.google.cf/search*
  77. // @match *://*.google.cg/search*
  78. // @match *://*.google.ch/search*
  79. // @match *://*.google.ci/search*
  80. // @match *://*.google.co.ck/search*
  81. // @match *://*.google.cl/search*
  82. // @match *://*.google.cm/search*
  83. // @match *://*.google.cn/search*
  84. // @match *://*.google.com.co/search*
  85. // @match *://*.google.co.cr/search*
  86. // @match *://*.google.com.cu/search*
  87. // @match *://*.google.cv/search*
  88. // @match *://*.google.com.cy/search*
  89. // @match *://*.google.cz/search*
  90. // @match *://*.google.de/search*
  91. // @match *://*.google.dj/search*
  92. // @match *://*.google.dk/search*
  93. // @match *://*.google.dm/search*
  94. // @match *://*.google.com.do/search*
  95. // @match *://*.google.dz/search*
  96. // @match *://*.google.com.ec/search*
  97. // @match *://*.google.ee/search*
  98. // @match *://*.google.com.eg/search*
  99. // @match *://*.google.es/search*
  100. // @match *://*.google.com.et/search*
  101. // @match *://*.google.fi/search*
  102. // @match *://*.google.com.fj/search*
  103. // @match *://*.google.fm/search*
  104. // @match *://*.google.fr/search*
  105. // @match *://*.google.ga/search*
  106. // @match *://*.google.ge/search*
  107. // @match *://*.google.gg/search*
  108. // @match *://*.google.com.gh/search*
  109. // @match *://*.google.com.gi/search*
  110. // @match *://*.google.gl/search*
  111. // @match *://*.google.gm/search*
  112. // @match *://*.google.gr/search*
  113. // @match *://*.google.com.gt/search*
  114. // @match *://*.google.gy/search*
  115. // @match *://*.google.hk/search*
  116. // @match *://*.google.com.hk/search*
  117. // @match *://*.google.hn/search*
  118. // @match *://*.google.hr/search*
  119. // @match *://*.google.ht/search*
  120. // @match *://*.google.hu/search*
  121. // @match *://*.google.co.id/search*
  122. // @match *://*.google.ie/search*
  123. // @match *://*.google.co.il/search*
  124. // @match *://*.google.im/search*
  125. // @match *://*.google.co.in/search*
  126. // @match *://*.google.iq/search*
  127. // @match *://*.google.is/search*
  128. // @match *://*.google.it/search*
  129. // @match *://*.google.je/search*
  130. // @match *://*.google.com.jm/search*
  131. // @match *://*.google.jo/search*
  132. // @match *://*.google.jp/search*
  133. // @match *://*.google.co.jp/search*
  134. // @match *://*.google.co.ke/search*
  135. // @match *://*.google.com.kh/search*
  136. // @match *://*.google.ki/search*
  137. // @match *://*.google.kg/search*
  138. // @match *://*.google.co.kr/search*
  139. // @match *://*.google.com.kw/search*
  140. // @match *://*.google.kz/search*
  141. // @match *://*.google.la/search*
  142. // @match *://*.google.com.lb/search*
  143. // @match *://*.google.li/search*
  144. // @match *://*.google.lk/search*
  145. // @match *://*.google.co.ls/search*
  146. // @match *://*.google.lt/search*
  147. // @match *://*.google.lu/search*
  148. // @match *://*.google.lv/search*
  149. // @match *://*.google.com.ly/search*
  150. // @match *://*.google.co.ma/search*
  151. // @match *://*.google.md/search*
  152. // @match *://*.google.me/search*
  153. // @match *://*.google.mg/search*
  154. // @match *://*.google.mk/search*
  155. // @match *://*.google.ml/search*
  156. // @match *://*.google.com.mm/search*
  157. // @match *://*.google.mn/search*
  158. // @match *://*.google.ms/search*
  159. // @match *://*.google.com.mt/search*
  160. // @match *://*.google.mu/search*
  161. // @match *://*.google.mv/search*
  162. // @match *://*.google.mw/search*
  163. // @match *://*.google.com.mx/search*
  164. // @match *://*.google.com.my/search*
  165. // @match *://*.google.co.mz/search*
  166. // @match *://*.google.com.na/search*
  167. // @match *://*.google.com.ng/search*
  168. // @match *://*.google.com.ni/search*
  169. // @match *://*.google.ne/search*
  170. // @match *://*.google.nl/search*
  171. // @match *://*.google.no/search*
  172. // @match *://*.google.com.np/search*
  173. // @match *://*.google.nr/search*
  174. // @match *://*.google.nu/search*
  175. // @match *://*.google.co.nz/search*
  176. // @match *://*.google.com.om/search*
  177. // @match *://*.google.com.pa/search*
  178. // @match *://*.google.com.pe/search*
  179. // @match *://*.google.com.pg/search*
  180. // @match *://*.google.com.ph/search*
  181. // @match *://*.google.com.pk/search*
  182. // @match *://*.google.pl/search*
  183. // @match *://*.google.pn/search*
  184. // @match *://*.google.com.pr/search*
  185. // @match *://*.google.ps/search*
  186. // @match *://*.google.pt/search*
  187. // @match *://*.google.com.py/search*
  188. // @match *://*.google.com.qa/search*
  189. // @match *://*.google.ro/search*
  190. // @match *://*.google.ru/search*
  191. // @match *://*.google.rw/search*
  192. // @match *://*.google.com.sa/search*
  193. // @match *://*.google.com.sb/search*
  194. // @match *://*.google.sc/search*
  195. // @match *://*.google.se/search*
  196. // @match *://*.google.com.sg/search*
  197. // @match *://*.google.sh/search*
  198. // @match *://*.google.si/search*
  199. // @match *://*.google.sk/search*
  200. // @match *://*.google.com.sl/search*
  201. // @match *://*.google.sn/search*
  202. // @match *://*.google.so/search*
  203. // @match *://*.google.sm/search*
  204. // @match *://*.google.sr/search*
  205. // @match *://*.google.st/search*
  206. // @match *://*.google.com.sv/search*
  207. // @match *://*.google.td/search*
  208. // @match *://*.google.tg/search*
  209. // @match *://*.google.co.th/search*
  210. // @match *://*.google.com.tj/search*
  211. // @match *://*.google.tl/search*
  212. // @match *://*.google.tm/search*
  213. // @match *://*.google.tn/search*
  214. // @match *://*.google.to/search*
  215. // @match *://*.google.com.tr/search*
  216. // @match *://*.google.tt/search*
  217. // @match *://*.google.com.tw/search*
  218. // @match *://*.google.co.tz/search*
  219. // @match *://*.google.com.ua/search*
  220. // @match *://*.google.co.ug/search*
  221. // @match *://*.google.co.uk/search*
  222. // @match *://*.google.com.uy/search*
  223. // @match *://*.google.co.uz/search*
  224. // @match *://*.google.com.vc/search*
  225. // @match *://*.google.co.ve/search*
  226. // @match *://*.google.vg/search*
  227. // @match *://*.google.co.vi/search*
  228. // @match *://*.google.com.vn/search*
  229. // @match *://*.google.vu/search*
  230. // @match *://*.google.ws/search*
  231. // @match *://*.google.rs/search*
  232. // @match *://*.google.co.za/search*
  233. // @match *://*.google.co.zm/search*
  234. // @match *://*.google.co.zw/search*
  235. // @match *://*.google.cat/search*
  236. // @exclude *://www.google.com/sorry*
  237. // @exclude *://www.baidu.com/link*
  238. // @exclude *://www.sogou.com/link*
  239. // @exclude *://www.so.com/link*
  240. // @exclude *://so.toutiao.com/search/jump*
  241. // @connect baidu.com
  242. // @connect sogou.com
  243. // @connect so.com
  244. // @connect greasyfork.org
  245. // @connect openuserjs.org
  246. // @connect githubusercontent.com
  247. // @connect favicon.yandex.net
  248. // @grant GM_getValue
  249. // @grant GM.getValue
  250. // @grant GM_setValue
  251. // @grant GM.setValue
  252. // @grant GM_listValues
  253. // @grant GM.listValues
  254. // @grant GM_deleteValue
  255. // @grant GM.deleteValue
  256. // @grant GM_openInTab
  257. // @grant GM.openInTab
  258. // @grant GM_addElement
  259. // @grant GM_registerMenuCommand
  260. // @grant GM.registerMenuCommand
  261. // @grant GM_xmlhttpRequest
  262. // @grant GM.xmlHttpRequest
  263. // @note {"CN":"优化 baidu.com 跳转按钮样式。","EN":"Optimized the style of baidu.com jump button."}
  264. // @note {"CN":"优化 bing.com 搜索框的样式。","EN":"Optimized the style of bing.com search box."}
  265. // @note {"CN":"优化 You.com 跳转按钮的加载逻辑。","EN":"Improved loading logic of You.com jump button."}
  266. // @note {"CN":"修正一些已知问题,优化代码,优化样式。","EN":"Fixed some known issues, optimized code & style."}
  267. // @compatible edge version≥88 (Compatible Tampermonkey, Violentmonkey)
  268. // @compatible Chrome version≥88 (Compatible Tampermonkey, Violentmonkey)
  269. // @compatible Firefox version≥78 (Compatible Greasemonkey, Tampermonkey, Violentmonkey)
  270. // @compatible Opera version≥75 (Compatible Tampermonkey, Violentmonkey)
  271. // @compatible Safari version≥14 (Compatible Tampermonkey, Userscripts)
  272. // @license GPL-3.0-only
  273. // @create 2015-10-07
  274. // @copyright 2015-2025, F9y4ng
  275. // @run-at document-start
  276. // ==/UserScript==
  277.  
  278. /* jshint esversion: 11 */
  279.  
  280. void (function (ctx, sctx, SearchEngineAssistant, arrayProxy, customFns) {
  281. "use strict";
  282.  
  283. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  284. * CUSTOM SCRIPT DEBUGGING, DO NOT TURN ON FOR DAILY USE. *
  285. * SET TO "TRUE" FOR SCRIPT DEBUGGING, MAY CAUSE THE SCRIPT TO RUN SLOWLY. *
  286. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  287.  
  288. const IS_OPEN_DEBUG = false;
  289.  
  290. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  291. * LICENSE FOR OPEN SOURCE USE: `GPLv3 ONLY`. *
  292. * THE CODE IS COMPLETELY OPEN AND FREE, AND DOES NOT ACCEPT UNAUTHORIZED *
  293. * DISTRIBUTION AS THIRD-PARTY STANDALONE SCRIPTS. IN CASE OF ERRORS, USAGE *
  294. * PROBLEMS OR NEW FEATURES, PLEASE FEEDBACK IN GITHUB ISSUES, THANK YOU! *
  295. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  296.  
  297. const toolkit = {
  298. debugging: IS_OPEN_DEBUG,
  299. info: GM?.info ?? GM_info,
  300. atob: sctx.atob.bind(sctx),
  301. btoa: sctx.btoa.bind(sctx),
  302. alert: ctx.alert.bind(ctx),
  303. prompt: ctx.prompt.bind(ctx),
  304. confirm: ctx.confirm.bind(ctx),
  305. console: sctx.Object.assign({}, ctx.console),
  306. };
  307. const wrappedFrom = ctx.wrappedJSObject ? Array.from : sctx.Array.from;
  308. const orginalFns = { oS: sctx.Object.prototype.toString, hP: sctx.Object.prototype.hasOwnProperty, aF: (...args) => arrayProxy(wrappedFrom(...args)) };
  309. if (!ctx.navigation) ["pushState", "replaceState"].forEach(m => void (ctx.history[m] = customFns.eH(m)));
  310. SearchEngineAssistant(ctx, sctx, toolkit, { ...orginalFns, ...customFns, cS: customFns.mS.filter(isNaN) });
  311. })(
  312. typeof window !== "undefined" ? window : this ?? globalThis,
  313. ((originalWindow, iframe) => {
  314. if (typeof GM_addElement === "undefined") return originalWindow;
  315. try {
  316. const { contentWindow } = (iframe = GM_addElement("iframe", { id: "𝚜𝚊𝚏e.w𝚒𝚗𝚍𝚘𝚠", style: "display:none" }));
  317. if (!originalWindow.wrappedJSObject) iframe.remove();
  318. return contentWindow;
  319. } catch (e) {
  320. return iframe?.remove(), originalWindow;
  321. }
  322. })(typeof window !== "undefined" ? window : this ?? globalThis, null),
  323. function (global, safeWindow, secureVars, customFuntions) {
  324. "use strict";
  325.  
  326. /* PERFECTLY COMPATIBLE FOR GREASEMONKEY, TAMPERMONKEY, VIOLENTMONKEY, USERSCRIPTS 2024-03-15 F9Y4NG */
  327.  
  328. const { atob, btoa, alert, prompt, confirm, console, debugging, info: GMinfo } = secureVars;
  329. const { mS, cS, aF: asArray, oS: getObjectType, hP: hasOwnProperty, lS: localStorages, oC: object } = customFuntions;
  330. const GMversion = GMinfo.version ?? GMinfo.scriptHandlerVersion ?? "unknown";
  331. const GMscriptHandler = GMinfo.scriptHandler;
  332. const GMsetValue = gmSelector("setValue");
  333. const GMgetValue = gmSelector("getValue");
  334. const GMdeleteValue = gmSelector("deleteValue");
  335. const GMlistValues = gmSelector("listValues");
  336. const GMopenInTab = gmSelector("openInTab");
  337. const GMregisterMenuCommand = gmSelector("registerMenuCommand");
  338. const GMxmlhttpRequest = gmSelector("xmlhttpRequest");
  339. const GMunsafeWindow = gmSelector("unsafeWindow");
  340. const GMcontentMode = gmSelector("contentMode");
  341.  
  342. /* INITIALIZE_DEBUG_FUNCTIONS */
  343.  
  344. const IS_CHN = checkLocalChineseLanguage();
  345. const IS_DEBUG = setDebuggerMode() || debugging;
  346. const DEBUG = IS_DEBUG ? __console.bind(console, "log") : () => {};
  347. const ERROR = IS_DEBUG ? __console.bind(console, "error") : () => {};
  348. const COUNT = IS_DEBUG ? __console.bind(console, "count") : () => {};
  349.  
  350. /* INITIALIZE_COMMON_CONSTANTS */
  351.  
  352. const { pT: CUR_PROTOCOL, hN: CUR_HOST_NAME, pN: CUR_PATH_NAME, iT: CUR_WINDOW_TOP } = getLocationInfo();
  353. const def = {
  354. count: { clickTimer: 0, duplicate: 0 },
  355. const: {
  356. raf: Symbol(`פֿ${generateRandomString(8, "hex")}`),
  357. caf: Symbol(`פֿ${generateRandomString(8, "hex")}`),
  358. loading: generateRandomString(6, "char"),
  359. cssAttrName: `gb-css-${generateRandomString(8, "hex")}`,
  360. rndButtonID: generateRandomString(12, "char"),
  361. rndclassName: `SC${generateRandomString(8, "number")}`,
  362. rndstyleName: `SS${generateRandomString(8, "number")}`,
  363. rndadvName: `SA${generateRandomString(8, "number")}`,
  364. leftButton: generateRandomString(6, "mix"),
  365. rightButton: generateRandomString(6, "mix"),
  366. scrollspan: generateRandomString(8, "char"),
  367. scrollspan2: generateRandomString(8, "char"),
  368. scrollbars: generateRandomString(8, "char"),
  369. scrollbars2: generateRandomString(8, "char"),
  370. searchbox: generateRandomString(7, "mix"),
  371. },
  372. var: {
  373. disappear: ${generateRandomString(10, "date")}ͼ`,
  374. translucent: ${generateRandomString(10, "date")}ͽ`,
  375. curVersion: getMetaValue("version") ?? GMinfo.script.version ?? "2025.05.03.0",
  376. scriptName: getMetaValue(`name:${getLocalLanguages()}`) ?? decrypt("U2VhcmNoJTIwRW5naW5lJTIwQXNzaXN0YW50"),
  377. },
  378. url: {
  379. yandexIcon: decrypt("aHR0cHMlM0ElMkYlMkZmYXZpY29uLnlhbmRleC5uZXQlMkZmYXZpY29uJTJGdjI="),
  380. backupIcon: decrypt("aHR0cHMlM0ElMkYlMkZzMjEuYXgxeC5jb20lMkYyMDI0JTJGMDYlMkYzMCUyRnBrY1VWbWoucG5n"),
  381. feedback: getMetaValue("supportURL") ?? GMinfo.script.supportURL ?? decrypt("aHR0cHMlM0ElMkYlMkZnaXRodWIuY29tJTJGRjl5NG5nJTJGR3JlYXN5Rm9yay1TY3JpcHRzJTJGaXNzdWVz"),
  382. homepage: getMetaValue("homepageURL") ?? GMinfo.script.homepage ?? decrypt("aHR0cHMlM0ElMkYlMkZmOXk0bmcuZ2l0aHViLmlvJTJGR3JlYXN5Rm9yay1TY3JpcHRzJTJG"),
  383. },
  384. notice: {
  385. rName: generateRandomString(8, "char"),
  386. random: generateRandomString(5, "char"),
  387. noticeX: generateRandomString(7, "char"),
  388. appear: generateRandomString(6, "char"),
  389. gberror: generateRandomString(6, "mix"),
  390. linkerror: generateRandomString(7, "mix"),
  391. item: generateRandomString(6, "mix"),
  392. close: generateRandomString(6, "mix"),
  393. center: generateRandomString(6, "mix"),
  394. success: generateRandomString(7, "char"),
  395. warning: generateRandomString(7, "char"),
  396. info: generateRandomString(7, "char"),
  397. error: generateRandomString(7, "char"),
  398. checkbox: generateRandomString(6, "char"),
  399. configuration: generateRandomString(7, "char"),
  400. animated: generateRandomString(7, "char"),
  401. stopUpdate: generateRandomString(6, "mix"),
  402. searchButton: generateRandomString(6, "mix"),
  403. favicon: generateRandomString(6, "mix"),
  404. favicons: generateRandomString(6, "mix"),
  405. searchList: generateRandomString(7, "mix"),
  406. fieldset: generateRandomString(6, "char"),
  407. legend: generateRandomString(6, "char"),
  408. settingList: generateRandomString(7, "mix"),
  409. readonly: generateRandomString(8, "mix"),
  410. hk: generateRandomString(5, "mix"),
  411. gj: generateRandomString(5, "mix"),
  412. lw: generateRandomString(5, "mix"),
  413. kh: generateRandomString(5, "mix"),
  414. ar: generateRandomString(5, "mix"),
  415. aa: generateRandomString(5, "mix"),
  416. au: generateRandomString(5, "mix"),
  417. grid: generateRandomString(7, "char"),
  418. card: generateRandomString(7, "char"),
  419. },
  420. };
  421.  
  422. if (checkRedundantScript(GMunsafeWindow)) return;
  423.  
  424. /* INITIALIZE_SETTIMEOUT_AND_SETINTERVAL_FUNCTION_CLASSES */
  425.  
  426. class RAF {
  427. constructor(context) {
  428. if (RAF.instance) return RAF.instance;
  429. safeWindow.Object.assign(this, { context, timerMap: { timeout: {}, interval: {} } });
  430. this._registerAnimationFrame(context);
  431. ["setTimeout", "setInterval", "clearTimeout", "clearInterval"].forEach(method => (this[method] = this[method].bind(this)));
  432. RAF.instance = this;
  433. }
  434. _registerAnimationFrame(scope) {
  435. const vendor = asArray(["ms", "moz", "webkit", "o"]).Find(vendor => scope[`${vendor}RequestAnimationFrame`]);
  436. const raf = scope.requestAnimationFrame ?? scope[`${vendor}RequestAnimationFrame`];
  437. const caf = scope.cancelAnimationFrame ?? (scope[`${vendor}CancelAnimationFrame`] || scope[`${vendor}CancelRequestAnimationFrame`]);
  438. safeWindow.Object.assign(scope, { [def.const.raf]: raf, [def.const.caf]: caf });
  439. }
  440. _ticking(fn, type, interval, ...args) {
  441. let lastTime = performance.now();
  442. const timerSymbol = Symbol(type);
  443. const step = () => {
  444. const currentTime = performance.now();
  445. this._setTimerMap(timerSymbol, type, step);
  446. if (currentTime - lastTime < (Number(interval) || 0)) return;
  447. if (typeof fn === "function") fn(...args);
  448. if (type === "interval") lastTime = currentTime;
  449. else this.clearTimeout(timerSymbol);
  450. };
  451. this._setTimerMap(timerSymbol, type, step);
  452. return timerSymbol;
  453. }
  454. _setTimerMap(timerSymbol, type, step) {
  455. this.timerMap[type][timerSymbol] = this.context[def.const.raf](step);
  456. }
  457. _clearTimerMap(timer, type) {
  458. this.context[def.const.caf](this.timerMap[type][timer]);
  459. delete this.timerMap[type][timer];
  460. }
  461. setTimeout(fn, interval, ...args) {
  462. return this._ticking(fn, "timeout", interval, ...args);
  463. }
  464. clearTimeout(timer) {
  465. this._clearTimerMap(timer, "timeout");
  466. }
  467. setInterval(fn, interval, ...args) {
  468. return this._ticking(fn, "interval", interval, ...args);
  469. }
  470. clearInterval(timer) {
  471. this._clearTimerMap(timer, "interval");
  472. }
  473. }
  474.  
  475. const raf = new RAF(global);
  476.  
  477. /* GLOBAL_GENERAL_FUNCTIONS */
  478.  
  479. function gmSelector(rec) {
  480. const gmFunctions = {
  481. setValue: typeof GM_setValue !== "undefined" ? GM_setValue : GM?.setValue ?? localStorages?.setItem.bind(localStorages),
  482. getValue: typeof GM_getValue !== "undefined" ? GM_getValue : GM?.getValue ?? localStorages?.getItem.bind(localStorages),
  483. deleteValue: typeof GM_deleteValue !== "undefined" ? GM_deleteValue : GM?.deleteValue ?? localStorages?.removeItem.bind(localStorages),
  484. listValues: typeof GM_listValues !== "undefined" ? GM_listValues : GM?.listValues ?? (() => []),
  485. openInTab: typeof GM_openInTab !== "undefined" ? GM_openInTab : GM?.openInTab ?? open.bind(global),
  486. registerMenuCommand: typeof GM_registerMenuCommand !== "undefined" ? GM_registerMenuCommand : GM?.registerMenuCommand,
  487. xmlhttpRequest: typeof GM_xmlhttpRequest !== "undefined" ? GM_xmlhttpRequest : GM?.xmlHttpRequest,
  488. unsafeWindow: typeof unsafeWindow !== "undefined" ? unsafeWindow : global,
  489. contentMode: GMinfo.injectInto === "content" || GMinfo.script["inject-into"] === "content" || ["dom", "js"].includes(GMinfo.sandboxMode),
  490. };
  491. return gmFunctions[rec] ?? __console("warn", `Grant 'GM.${rec}' is not available.`) ?? (() => {});
  492. }
  493.  
  494. function __console(action, message, ...args) {
  495. const consoleMethods = {
  496. log: ["log", "%c\ud83d\udd33 %c", "display:inline-block", "font-family:ui-monospace,monospace"],
  497. error: ["error", "%c\ud83d\udea9 ", "display:inline-block;font-family:ui-monospace,monospace"],
  498. warn: ["warn", "%c\ud83d\udea9 ", "display:inline-block;font-family:ui-monospace,monospace"],
  499. count: ["count", "\ud83d\udd33 "],
  500. };
  501. const [_, msg, consoleMethod] = [this ?? console, message ?? "", consoleMethods[action]];
  502. if (!consoleMethod) return _.log(msg, ...args);
  503. const [method, prefix, ...surfix] = consoleMethod;
  504. return _[method](prefix + msg, ...surfix, ...args);
  505. }
  506.  
  507. function checkLocalChineseLanguage() {
  508. const lang = navigator.language || Intl.DateTimeFormat().resolvedOptions().locale || "en-US";
  509. return lang.startsWith("zh");
  510. }
  511.  
  512. function qS(expr, target = document) {
  513. try {
  514. if (/^#[\w:.-]+$/.test(expr)) return target.getElementById(expr.slice(1));
  515. return target.querySelector(expr);
  516. } catch (e) {
  517. return null;
  518. }
  519. }
  520.  
  521. function qA(expr, target = document) {
  522. try {
  523. return asArray(target.querySelectorAll(expr));
  524. } catch (e) {
  525. return asArray([]);
  526. }
  527. }
  528.  
  529. function toString(value) {
  530. if (typeof value === "symbol") return value.description;
  531. return String(value);
  532. }
  533.  
  534. function cE(nodeName, attributes) {
  535. const el = document.createElement(nodeName);
  536. if (getObjectType.call(attributes) !== "[object Object]") return el;
  537. for (const [key, value] of Object.entries(attributes)) {
  538. if (key === "class") Array.isArray(value) ? el.classList.add(...value) : el.classList.add(value);
  539. else if (["innerHTML", "textContent"].includes(key)) el[key] = value;
  540. else el.setAttribute(key, value);
  541. }
  542. return el;
  543. }
  544.  
  545. function random({ range, length = 1, type = "round" }) {
  546. const typedArray = global.crypto.getRandomValues(new Uint32Array(Number(length) || 1));
  547. return asArray(typedArray, a => (Math[type] ?? Math.round)((a / 0xffffffff) * (Number(range) || 10)));
  548. }
  549.  
  550. function gCS(node, opt = null) {
  551. if (node?.nodeType !== Node.ELEMENT_NODE) return new Proxy(object(), { get: () => NaN });
  552. return global.getComputedStyle(node, opt);
  553. }
  554.  
  555. function capitalize(string) {
  556. string = String(string ?? "").toLowerCase();
  557. return string.replace(/\b[a-z]|\s[a-z]/g, str => str.toUpperCase());
  558. }
  559.  
  560. function encrypt(string, encode = true) {
  561. if (typeof string !== "string") string = toString(string);
  562. try {
  563. const req = encode ? encodeURIComponent(string) : string;
  564. return btoa(req);
  565. } catch (e) {
  566. return "";
  567. }
  568. }
  569.  
  570. function decrypt(string, decode = true) {
  571. if (typeof string !== "string") return "";
  572. try {
  573. const rst = atob(string.replace(/[^A-Za-z0-9+/=]/g, ""));
  574. return decode ? decodeURIComponent(rst) : rst;
  575. } catch (e) {
  576. return "";
  577. }
  578. }
  579.  
  580. function generateRandomString(length, type, p, m = mS, c = cS) {
  581. if (type === "date") return (p = new Date().setHours(20, 30, 40, 50).toString(16)), p.padEnd(length, p);
  582. if (type === "hex" || type === "number") return (p = type === "hex" ? 16 : 10), asArray(random({ range: p, length, type: "floor" }), v => v.toString(p)).join("");
  583. return (p = type === "mix" ? m : c), asArray(random({ range: p.length, length }), (v, i) => (p === m && !i ? c[random({ range: 70 })] : p[v])).join("");
  584. }
  585.  
  586. function reload() {
  587. return sleep(5e2, { useCachedSetTimeout: true }).then(() => global.location.reload(true));
  588. }
  589.  
  590. function escapeHTML(string) {
  591. if (typeof string !== "string") return "";
  592. const element = cE("gb-escape-html", { textContent: string });
  593. return element.innerHTML;
  594. }
  595.  
  596. function createTrustedTypePolicy() {
  597. const policyOptions = { createHTML: s => s, createScript: s => s, createScriptURL: u => u };
  598. if (!global.trustedTypes?.createPolicy) return policyOptions;
  599. const originalCreatePolicy = global.trustedTypes.createPolicy.bind(global.trustedTypes);
  600. const whitelist = [{ host: "bing.com", policy: "rwflyoutDefault" }];
  601. const policyName = global.trustedTypes.defaultPolicy?.name ?? asArray(whitelist).Find(entry => location.hostname.endsWith(entry.host))?.policy ?? "default";
  602. const defaultPolicy = global.trustedTypes.defaultPolicy ?? originalCreatePolicy(policyName, policyOptions);
  603. global.trustedTypes.createPolicy = (name, options) => (name === policyName ? defaultPolicy : originalCreatePolicy(name, options));
  604. return defaultPolicy;
  605. }
  606.  
  607. function checkRedundantScript(global) {
  608. const redundancyWarning = () => {
  609. const redundanceText = `\ud83d\udea9 [Redundant Scripts]:\r\nFound redundant-installed scripts: ${def.var.scriptName}. please reload to troubleshoot the issue.`;
  610. const troubleshoot = `\ufff8\ud83d\uded1 ${IS_CHN ? "发现冗余安装的脚本,点击排查!" : "Troubleshoot Redundant"}`;
  611. return CUR_WINDOW_TOP && GMregisterMenuCommand(troubleshoot, () => void GMopenInTab(`${def.url.feedback}/117`, false)) && __console("error", redundanceText), true;
  612. };
  613. if (global["gb-init-once"] === true) return redundancyWarning();
  614. if (GMcontentMode && document.documentElement?.hasAttribute("gb-init-once")) return redundancyWarning();
  615. (global["gb-init-once"] = true) && safeWindow.Object.freeze(def.const) && document.documentElement?.setAttribute("gb-init-once", "");
  616. }
  617.  
  618. async function getNavigatorInfo() {
  619. const creditEngine = getRealBrowserEngine(global);
  620. const userAgentData = await getUserAgentDataFromExtension(`${GMscriptHandler} ${GMversion}`);
  621. return userAgentData ? getGlobalInfoFromUAD(userAgentData) : getGlobalInfoFromUA(navigator.userAgent);
  622.  
  623. function getGlobalInfoFromUAD(uad) {
  624. const platform = getFullPlatformName(uad.platform);
  625. const mapBrandPath = ({ brand: b, version: v }) => `${/Not[^a-z]*A[^a-z]*Brand/i.test(b) ? 9 : /^Chrom(?:e|ium)|Firefox|Safari$/i.test(b) ? 5 : 1}${b}\r${v}`;
  626. const [brand, brandVersion] = uad.brands?.map(mapBrandPath).sort()[0]?.slice(1).split("\r") ?? [];
  627. const engineMap = { Chrome: "Blink", Chromium: "Blink", Firefox: "Gecko", Safari: "WebKit" };
  628. const mapEnginePath = ({ brand, version }) => /^(Chrom(?:e|ium)|Firefox|Safari)$/i.test(brand) && `${brand}\r${version}`;
  629. const [engine, engineVersion] = uad.brands?.map(mapEnginePath).filter(Boolean)[0]?.split("\r") ?? [brand, brandVersion];
  630. const engineInfo = { engine: engineMap[capitalize(engine)] ?? getEngineFromUA(navigator.userAgent), engineVersion: parseFloat(engineVersion) || 99, creditEngine };
  631. const browserInfo = { brand: (brand?.split(/\s/) ?? []).slice(-1)[0] ?? "Unknown", brandVersion: formatVersion(brandVersion), platform };
  632. return { ...engineInfo, ...browserInfo, source: uad.source ?? "uad", voucher: uad.voucher ?? null };
  633. }
  634.  
  635. function getGlobalInfoFromUA(ua) {
  636. const checkString = (str, exp = "") => new RegExp(str, exp).test(ua);
  637. const getVersion = (str, offset) => checkString(str) && ua.slice(ua.indexOf(str) + offset).match(/\d+(\.\d+)*/)?.[0];
  638. const { brand, brandVersion, engine, engineVersion } = getBrowserInfoFromUA(ua, checkString, getVersion);
  639. const platform = getOSInfoFromUA(checkString);
  640. return { engine, engineVersion, creditEngine, brand, brandVersion, platform, source: "ua", voucher: null };
  641. }
  642.  
  643. async function getUserAgentDataFromExtension(voucher) {
  644. const getVMUserAgentData = ({ browserName, browserVersion, os, arch }) => {
  645. const [architecture, bitness] = arch?.split("-") ?? [];
  646. let brands = [{ brand: capitalize(browserName), version: browserVersion }];
  647. if (parseFloat(browserVersion) < 78.0 && GMinfo.userAgent) {
  648. const [, brand, version] = GMinfo.userAgent.match(/\s(Chrom(?:e|ium)|Firefox)\/(\d+[.0-9]*)/i) ?? [];
  649. if (brand) brands = [{ brand: capitalize(brand), version }, ...brands];
  650. }
  651. return { bitness, architecture, brands, platform: capitalize(os), source: "ext", voucher };
  652. };
  653. if (voucher.startsWith("Violentmonkey") && GMinfo.platform) return getVMUserAgentData(GMinfo.platform);
  654. const getTMUserAgentData = uad => {
  655. if (creditEngine === "Gecko" && parseFloat(uad.brands[0].version) < 78.0) {
  656. const [, brand, version] = navigator.userAgent.match(/\s(Firefox)\/(\d+[.0-9]*)/i) ?? [];
  657. if (brand) return { ...uad, brands: [{ brand: capitalize(brand), version }, ...uad.brands], source: "ua" };
  658. }
  659. return { ...uad, source: "ext", voucher };
  660. };
  661. if (voucher.startsWith("Tampermonkey") && GMinfo.userAgentData) return getTMUserAgentData(GMinfo.userAgentData);
  662. const getUADHighEntropyValues = async uad =>
  663. await uad.getHighEntropyValues(["bitness", "architecture", "fullVersionList"]).then(rst => {
  664. rst.brands = rst.fullVersionList;
  665. delete rst.fullVersionList;
  666. return rst;
  667. });
  668. if (navigator.userAgentData?.brands?.[0]) return await getUADHighEntropyValues(navigator.userAgentData);
  669. return null;
  670. }
  671.  
  672. function getBrowserInfoFromUA(ua, checkString, getVersion) {
  673. const engine = getEngineFromUA(ua);
  674. const brandMap = {
  675. OPR: { brand: "Opera", engine: "Blink", as: "Chrome" },
  676. YaBrowser: { brand: "Yandex", engine: "Blink", as: "Chrome" },
  677. Edg: { brand: "Edge", engine: "Blink", as: "Chrome" },
  678. Chromium: { brand: "Chromium", engine: "Blink" },
  679. Chrome: { brand: "Chrome", engine: "Blink" },
  680. LibreWolf: { brand: "LibreWolf", engine: "Gecko", as: "Firefox" },
  681. SeaMonkey: { brand: "SeaMonkey", engine: "Gecko", as: "Firefox" },
  682. PaleMoon: { brand: "PaleMoon", engine: "Gecko", as: "Firefox" },
  683. Waterfox: { brand: "Waterfox", engine: "Gecko", as: "Firefox" },
  684. Firefox: { brand: "Firefox", engine: "Gecko" },
  685. Konqueror: { brand: "Konqueror", engine: "webkit" },
  686. Kindle: { brand: "Kindle", engine: "WebKit", as: "Version" },
  687. Safari: { brand: "Safari", engine: "WebKit", as: "Version", verset: ["Version"] },
  688. Trident: { brand: "IE", engine: "Trident", verset: ["MSIE", "rv"] },
  689. Presto: { brand: "Opera", engine: "Presto" },
  690. };
  691. for (const [key, { brand, engine, verset, as }] of Object.entries(brandMap)) {
  692. if (!checkString(key)) continue;
  693. const versionKey = asArray(verset ?? []).Find(k => checkString(k)) || key;
  694. let brandVersion = getVersion(versionKey, versionKey.length + 1);
  695. if (!brandVersion) continue;
  696. const enVersionKey = as || key;
  697. const engineVersion = parseFloat(getVersion(enVersionKey, enVersionKey.length + 1) || 99);
  698. return { brand, brandVersion: formatVersion(brandVersion), engine, engineVersion };
  699. }
  700. const { b: brand, bv: brandVersion, ev: engineVersion } = getUnregisteredBrandAndVersionFromUA(ua);
  701. return { brand, brandVersion, engine, engineVersion };
  702. }
  703.  
  704. function formatVersion(version) {
  705. if (!version) return "0.0.0.0";
  706. const numbers = version.split(".").map(num => parseInt(num) || 0);
  707. while (numbers.length < 4) numbers.push(0);
  708. return numbers.join(".");
  709. }
  710.  
  711. function getFullPlatformName(platform) {
  712. if (!platform) return "Unknown";
  713. const os = capitalize(platform);
  714. return /^(Like Mac|Ios)$/.test(os) ? "iOS" : os === "Cros" ? "Chrome OS" : os.startsWith("Win") ? "Windows" : os.startsWith("Mac") ? "MacOS" : os === "X11" ? "Linux" : os;
  715. }
  716.  
  717. function getRealBrowserEngine(w) {
  718. return w.GestureEvent ? "WebKit" : w.scrollByLines || w.getDefaultComputedStyle ? "Gecko" : w.webkitRequestFileSystem || w.queryLocalFonts ? "Blink" : "Unknown";
  719. }
  720.  
  721. function getEngineFromUA(ua) {
  722. return /Gecko\/|Firefox\/|FxiOS/.test(ua) ? "Gecko" : /Chrom(?:e|ium)\/|CriOS/.test(ua) ? "Blink" : /AppleWebKit\/|Version\//.test(ua) ? "WebKit" : "Unknown";
  723. }
  724.  
  725. function getUnregisteredBrandAndVersionFromUA(ua) {
  726. const [nameOffset, verOffset] = [ua.lastIndexOf(" ") + 1, ua.lastIndexOf("/")];
  727. if (nameOffset === 0 || verOffset === -1 || verOffset < nameOffset) return { b: "Unknown", bv: "0.0.0.0", ev: 99 };
  728. const brand = ua.slice(nameOffset, verOffset).trim();
  729. const brandVersion = formatVersion(ua.slice(verOffset + 1).match(/\d*\.?\d+/)?.[0]);
  730. const engineVersion = parseFloat(ua.match(/(?:Chrom(?:e|ium)|Firefox|Version)\/(\d+[.0-9]*)/i)?.[1] || brandVersion || 99);
  731. const validVersion = (!/version|\/|\(|\)|;/i.test(brand) && brandVersion) || "0.0.0.0";
  732. return { b: brand, bv: validVersion, ev: engineVersion };
  733. }
  734.  
  735. function getOSInfoFromUA(checkString) {
  736. const platforms = ["like Mac", "Mac", "Android", "Debian", "Ubuntu", "Linux", "Win", "CrOS", "X11"];
  737. const platform = asArray(platforms).Find(p => checkString(p, "i")) || "Unknown";
  738. return getFullPlatformName(platform);
  739. }
  740. }
  741.  
  742. function getLocationInfo() {
  743. const { host: h, hostname: hN, pathname: pN, protocol: pT } = global.location;
  744. const iT = global.self === global.top;
  745. return { h, hN, pN, pT, iT };
  746. }
  747.  
  748. function getMetaValue(str) {
  749. const queryReg = new RegExp(`//\\s+@${str}\\s+(.+)`);
  750. const metaValue = (GMinfo.scriptMetaStr || GMinfo.scriptSource)?.match(queryReg);
  751. return metaValue?.[1];
  752. }
  753.  
  754. function getLocalLanguages(lang = navigator.language) {
  755. const languages = new Set(["zh-CN", "zh-TW", "en", "ja", "ko"]);
  756. return languages.has(lang) ? lang : lang.startsWith("zh") ? "zh-CN" : "en";
  757. }
  758.  
  759. function setDebuggerMode() {
  760. const key = decrypt("\u0052\u006a\u006c\u0035\u004e\u0047\u0035\u006e");
  761. const value = new URLSearchParams(global.location.search).get("whoami");
  762. return Object.is(key, value);
  763. }
  764.  
  765. function sleep(delay, { useCachedSetTimeout, instant } = {}) {
  766. const timeoutFunction = useCachedSetTimeout ? setTimeout : raf.setTimeout;
  767. const sleepPromise = new Promise(resolve => {
  768. timeoutFunction(resolve, delay);
  769. });
  770. const promiseFunction = value => sleepPromise.then(() => value);
  771. promiseFunction.then = sleepPromise.then.bind(sleepPromise);
  772. promiseFunction.catch = sleepPromise.catch.bind(sleepPromise);
  773. return instant ? sleepPromise : promiseFunction;
  774. }
  775.  
  776. function deBounce({ fn, timer, delay, immed = false, once = false } = {}) {
  777. if (typeof fn !== "function" || !timer) return () => {};
  778. return function (...args) {
  779. const [name, context] = [Symbol.for(toString(timer)), this];
  780. if (immed === true && typeof def.count[name] === "undefined") {
  781. fn.apply(context, args);
  782. if (once === true) return (def.count[name] = true);
  783. } else if (def.count[name]) {
  784. if (def.count[name] === true) return true;
  785. raf.clearTimeout(def.count[name]);
  786. }
  787. def.count[name] = raf.setTimeout(() => {
  788. fn.apply(context, args);
  789. if (once === true) return (def.count[name] = true);
  790. delete def.count[name];
  791. }, Number(delay) || 0);
  792. };
  793. }
  794.  
  795. function safeRemoveNode(expression, scope) {
  796. if (!expression) return false;
  797. const pendingNodes = Array.isArray(expression) ? expression : typeof expression === "string" ? qA(expression, scope) : expression?.nodeType ? [expression] : [];
  798. return pendingNodes.every(el => el.remove() || el.parentNode === null);
  799. }
  800.  
  801. void (async function (tTP) {
  802. const [CONFIGURE, VERSION, AUTOCHECK, RESULTFILTER, REMOTEICONS] = ["_configures_", "_version_", "_autoupdate_", "_resultFilter_", "_remoteicons_"];
  803. const { engine, creditEngine, brand, voucher } = await getNavigatorInfo();
  804. const [IS_REAL_BLINK, IS_REAL_GECKO, IS_REAL_WEBKIT] = ["Blink", "Gecko", "WebKit"].map(cE => cE === creditEngine);
  805. const IS_CHEAT_UA = voucher === null && (engine !== creditEngine || checkBlinkCheatingUA(navigator.userAgentData));
  806. const IS_GREASEMONKEY = ["Greasemonkey", "Userscripts"].includes(GMscriptHandler);
  807. const createNoticeHTML = html => `<div class="${def.notice.rName}"><dl>${html}</dl></div>`;
  808.  
  809. const cache = {
  810. value: (data, eT = 6048e5) => ({ data, expired: Date.now() + eT }),
  811. set: (key, ...options) => void GMsetValue(key, encrypt(JSON.stringify(cache.value(...options)))),
  812. get: async key => {
  813. try {
  814. const encryptedValue = await GMgetValue(key);
  815. if (!encryptedValue) return;
  816. const current = Date.now();
  817. const { data, expired } = JSON.parse(decrypt(encryptedValue));
  818. if (data && expired > current) return data;
  819. else cache.remove(key);
  820. } catch (e) {
  821. cache.remove(key);
  822. }
  823. },
  824. remove: key => GMdeleteValue(key),
  825. };
  826.  
  827. class NoticeX {
  828. constructor(options = {}) {
  829. const defaultOptions = {
  830. title: "",
  831. text: "",
  832. type: def.notice.success,
  833. position: "bottomRight",
  834. newestOnTop: false,
  835. timeout: 2e3,
  836. progressBar: true,
  837. closeWith: ["button"],
  838. animation: { open: `${def.notice.animated} ${def.notice.random}_fadeIn`, close: `${def.notice.animated} ${def.notice.random}_fadeOut` },
  839. width: 400,
  840. scroll: { maxHeight: 400, showOnHover: false },
  841. callbacks: { beforeShow: [], onShow: [], afterShow: [], beforeClose: [], onClose: [], afterClose: [], onClick: [], onHover: [] },
  842. };
  843. this.options = { ...defaultOptions, ...options };
  844. this._registerCallbacks();
  845. }
  846. static close(item) {
  847. if (!item) return true;
  848. item.classList.add(def.notice.animated, `${def.notice.random}_fadeOut`);
  849. const closetNode = item.closest(`.${def.notice.noticeX}`);
  850. const position = closetNode?.className.match(/\b(\w+-\w+)\b/)?.[1] || `${def.notice.noticeX}-topRight`;
  851. return sleep(3e2)
  852. .then(() => safeRemoveNode(item))
  853. .then(() => qA(`.${position} .${def.notice.item}`).length === 0 && safeRemoveNode(`.${position}`));
  854. }
  855. show() {
  856. this._createContainer();
  857. return this._appendNoticeX(this._createHeader(), this._createBody(), this._createProgressBar());
  858. }
  859. _createContainer() {
  860. const position = `${def.notice.noticeX}-${this.options.position}`;
  861. if (qS(`gb-notice.${position}`)) return;
  862. const container = cE("gb-notice", { class: [def.notice.noticeX, position, def.notice.appear] });
  863. document.documentElement?.appendChild(container);
  864. }
  865. _createHeader() {
  866. if (!this.options.title && !this.options.closeWith.includes("button")) return null;
  867. const header = cE("div", { class: `${def.notice.noticeX}-heading` });
  868. if (this.options.title) header.innerHTML += tTP.createHTML(`<span class="${def.notice.noticeX}-heading-title" title="${this.options.title}">${this.options.title}</span>`);
  869. if (this.options.closeWith.includes("button")) {
  870. const close = cE("div", { class: def.notice.close, innerHTML: tTP.createHTML("&times;") });
  871. header.appendChild(close);
  872. }
  873. return header;
  874. }
  875. _createBody() {
  876. const body = cE("div", { class: `${def.notice.noticeX}-body` });
  877. const content = cE("div", { class: `${def.notice.noticeX}-content`, innerHTML: tTP.createHTML(this.options.text) });
  878. body.appendChild(content);
  879. if (this.options.scroll?.maxHeight) {
  880. body.style.overflowY = "auto";
  881. body.style.maxHeight = `min(calc(92vh - 50px), ${this.options.scroll.maxHeight}px)`;
  882. if (this.options.scroll?.showOnHover) body.style.visibility = "hidden";
  883. }
  884. return body;
  885. }
  886. _createProgressBar() {
  887. const progressBar = cE("div", { class: `${def.notice.noticeX}-progressbar` });
  888. const bar = cE("div", { class: `${def.notice.noticeX}-bar` });
  889. progressBar.appendChild(bar);
  890. if (this.options.progressBar && typeof this.options.timeout === "number") {
  891. progressBar.style.animation = `${def.notice.noticeX}-progress ${this.options.timeout / 1e3}s linear forwards`;
  892. sleep(this.options.timeout, { useCachedSetTimeout: true }).then(() => {
  893. const item = progressBar.closest(`div.${def.notice.item}`);
  894. if (item) this._closeWithAnimation(item);
  895. });
  896. }
  897. return progressBar;
  898. }
  899. _appendNoticeX(header, body, progressBar) {
  900. const targetClass = `.${def.notice.noticeX}-${this.options.position}`;
  901. const noticeItem = cE("div", { class: [def.notice.item, this.options.type] });
  902. if (this.options.width && Number.isInteger(this.options.width)) noticeItem.style.width = `${this.options.width}px`;
  903. [header, body, progressBar].forEach(el => el && noticeItem.appendChild(el));
  904. if (["top", "bottom"].includes(this.options.position)) qS(targetClass).textContent = "";
  905. if (this.options?.animation?.open) noticeItem.className += ` ${this.options.animation.open}`;
  906. this._executeCallbacks("beforeShow");
  907. this._addListeners(noticeItem);
  908. const target = qS(targetClass);
  909. this._executeCallbacks("onShow");
  910. this.options.newestOnTop && target ? target.insertAdjacentElement("afterbegin", noticeItem) : target.appendChild(noticeItem);
  911. this._executeCallbacks("afterShow");
  912. return noticeItem;
  913. }
  914. _closeWithAnimation(item) {
  915. if (this.options.animation?.close) {
  916. item.className += ` ${this.options.animation.close}`;
  917. sleep(5e2).then(() => this._closeItem(item));
  918. } else this._closeItem(item);
  919. }
  920. _addListeners(item) {
  921. const closeBtn = qS(`.${def.notice.close}`, item);
  922. const handleClick = () => this._closeItem(item);
  923. if (this.options.closeWith.includes("button")) closeBtn?.addEventListener("click", handleClick);
  924. if (this.options.closeWith.includes("click")) {
  925. item.style.cursor = "pointer";
  926. item.addEventListener("click", e => {
  927. if (e.target.className === def.notice.close) return;
  928. this._executeCallbacks("onClick");
  929. handleClick();
  930. });
  931. } else item.addEventListener("click", e => e.target.className !== def.notice.close && this._executeCallbacks("onClick"));
  932. item.addEventListener("mouseover", () => this._executeCallbacks("onHover"));
  933. }
  934. _closeItem(item) {
  935. const closetNode = item.closest(`.${def.notice.noticeX}`);
  936. const position = closetNode?.className.match(/\b(\w+-\w+)\b/)?.[1] || `${def.notice.noticeX}-bottomRight`;
  937. this._executeCallbacks("beforeClose");
  938. sleep(3e2)
  939. .then(() => this._executeCallbacks("onClose"))
  940. .then(() => safeRemoveNode(item))
  941. .then(() => qA(`.${position} .${def.notice.item}`).length === 0 && safeRemoveNode(`.${position}`))
  942. .then(() => this._executeCallbacks("afterClose"));
  943. }
  944. _executeCallbacks(eventName) {
  945. this.options.callbacks[eventName]?.forEach(cb => cb?.call(this));
  946. }
  947. _registerCallbacks() {
  948. Object.keys(this.options.callbacks).forEach(eventName => {
  949. const cb = this.options.callbacks[eventName];
  950. if (typeof cb === "function") this._on(eventName, cb);
  951. });
  952. }
  953. _on(eventName, cb = () => {}) {
  954. if (typeof cb === "function" && this.options.callbacks[eventName]) this.options.callbacks[eventName].push(cb);
  955. return this;
  956. }
  957. }
  958.  
  959. function checkBlinkCheatingUA(uad) {
  960. if (!IS_REAL_BLINK) return false;
  961. return (global.isSecureContext && !uad) || (uad && toString(uad) !== "[object NavigatorUAData]");
  962. }
  963.  
  964. function insertAfter(newEl, target) {
  965. if (!newEl || !target) return;
  966. const parent = target.parentNode || document.head;
  967. parent.insertBefore(newEl, target.nextElementSibling);
  968. }
  969.  
  970. function addStyle({ target, styleId, styleContent, media, isOverwrite }) {
  971. if (!target || !styleId || !styleContent || !media) return;
  972. let existingStyles = qA(`#${styleId}`, target);
  973. if (isOverwrite) existingStyles.forEach(style => (style.dataset.frRemoved = true) && safeRemoveNode(style));
  974. else if (existingStyles.length > 0) return true;
  975. try {
  976. const styleElement = cE("style", { id: styleId, media, type: "text/css", textContent: styleContent ?? "", [def.const.cssAttrName]: isOverwrite ?? false });
  977. return target.appendChild(styleElement) && true;
  978. } catch (e) {
  979. ERROR("addStyle:", e.message);
  980. }
  981. }
  982.  
  983. function getUrlParam(parameter) {
  984. try {
  985. switch (getObjectType.call(parameter)) {
  986. case "[object Object]": {
  987. const { split, index } = parameter;
  988. const keyArray = global.location.pathname.split(split);
  989. return keyArray[index] ?? "";
  990. }
  991. case "[object Array]":
  992. for (const para of parameter) {
  993. const value = getUrlParam(para);
  994. if (value) return value;
  995. }
  996. return "";
  997. case "[object Number]":
  998. case "[object String]":
  999. if (!parameter && parameter !== 0) return "";
  1000. return new URLSearchParams(global.location.search).get(parameter) ?? "";
  1001. case "[object Function]":
  1002. return parameter() ?? "";
  1003. default:
  1004. return "";
  1005. }
  1006. } catch (e) {
  1007. ERROR("getUrlParam:", e.message);
  1008. return "";
  1009. }
  1010. }
  1011.  
  1012. function versionCompare(current, compare) {
  1013. const [currentVersion, compareVersion] = [current.split(".").map(Number), compare.split(".").map(Number)];
  1014. if (compareVersion.length !== currentVersion.length) return true;
  1015. for (let i = 0; i < currentVersion.length; i++) if (compareVersion[i] !== currentVersion[i]) return compareVersion[i] > currentVersion[i];
  1016. return false;
  1017. }
  1018.  
  1019. function manageCookies() {
  1020. return {
  1021. getItem: sKey => decodeURIComponent(document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*" + sKey?.replace(/[-.+*]/g, "\\$&") + "\\s*\\=\\s*([^;]*).*$)|^.*$"), "$1")) || null,
  1022. setItem: function ({ sKey, sValue, sEnd, sPath, sDomain, sSameSite, sSecure }) {
  1023. if (!sKey || /^(?:expires|max-age|path|domain|samesite|secure)$/i.test(sKey)) return false;
  1024. [sDomain, sPath, sSameSite, sSecure] = [sDomain ? `;domain=${sDomain}` : "", sPath ? `;path=${sPath}` : "", sSameSite ? `;SameSite=${sSameSite}` : "", sSecure ? ";secure" : ""];
  1025. const sExpires = typeof sEnd === "number" && sEnd !== Infinity ? `;expires=${new Date(Date.now() + sEnd).toUTCString()}` : `;expires=Fri, 31 Dec 3999 23:59:59 GMT`;
  1026. document.cookie = `${sKey}=${sValue}${sExpires}${sDomain}${sPath}${sSameSite}${sSecure}`;
  1027. return true;
  1028. },
  1029. removeItem: function ({ sKey, sPath, sDomain }) {
  1030. if (!sKey || !new RegExp("(?:^|;\\s*)" + sKey.replace(/[-.+*]/g, "\\$&") + "\\s*\\=").test(document.cookie)) return false;
  1031. document.cookie = `${sKey}=;expires=Thu, 01 Jan 1970 00:00:00 GMT${sDomain ? `;domain=${sDomain}` : ""}${sPath ? `;path=${sPath}` : ""}`;
  1032. return true;
  1033. },
  1034. };
  1035. }
  1036.  
  1037. void (async function (getConfigureData, getResultFilterData, requestRemoteIcon, GMnotification) {
  1038. let [_config_date_, _filter_Data_] = await Promise.all([getConfigureData(), getResultFilterData()]);
  1039. const { trigger: antiResultsFilter, filter: resultFilters } = _filter_Data_;
  1040. const { isAutoUpdate, keywordHighlight, isHotkey, selectedEngine, localWindow, googleJump, antiLinkRedirect, antiAds, customColor } = _config_date_;
  1041. const [gbCookies, cachedRequestLinks, usedFilterWords, selectedSite] = [manageCookies(), antiLinkRedirect ? new Map() : null, antiResultsFilter ? new Set() : null, []];
  1042.  
  1043. /* ANTIREDIRECT_FUNCTIONS */
  1044.  
  1045. function validateOptions(options) {
  1046. return {
  1047. useNewTab: options.useNewTab || false,
  1048. forceSelf: options.forceSelf || false,
  1049. forceNewTab: options.forceNewTab || false,
  1050. cleanAttr: options.cleanAttr || [],
  1051. removeDataSet: options.removeDataSet || false,
  1052. advancedAnti: options.advancedAnti || false,
  1053. };
  1054. }
  1055.  
  1056. function updateNodeAttributes(options, node) {
  1057. if (options.useNewTab) node.setAttribute("target", "_blank");
  1058. if (options.forceSelf) node.setAttribute("target", "_self");
  1059. if (Array.isArray(options.cleanAttr) && options.cleanAttr.length > 0) options.cleanAttr.forEach(item => node.removeAttribute(item));
  1060. if (options.removeDataSet) Object.keys(node.dataset).forEach(ds => delete node.dataset[ds]);
  1061. node.setAttribute("gd-depurate-status", true);
  1062. }
  1063.  
  1064. function stopEventPropagation(event) {
  1065. event.preventDefault();
  1066. event.stopImmediatePropagation();
  1067. }
  1068.  
  1069. function setForceNewTab(options, node) {
  1070. if (!options.forceNewTab) return;
  1071. node.addEventListener("click", e => {
  1072. stopEventPropagation(e);
  1073. GMopenInTab(node.href, false);
  1074. });
  1075. }
  1076.  
  1077. function setAdvancedAntiRedirect(options, node, tasks, siteName) {
  1078. if (!options.advancedAnti) return;
  1079. node.setAttribute("gd-antiredirect-status", "pending");
  1080. const task = advancedAntiRedirection(siteName, node, () => Promise.resolve(NaN));
  1081. if (typeof task === "function") tasks.push(task);
  1082. }
  1083.  
  1084. function parsingAntiRedirect(selectors, siteName, options) {
  1085. if (typeof selectors !== "string" || selectors.trim() === "") return;
  1086. options = validateOptions(options);
  1087. const selectorArray = selectors.split(/,(?![^()]*\))/g);
  1088. const queryString = selectorArray.map(item => `${item}:not([href^='javascript:' i]):not([href^='#']):not([gd-depurate-status],[gd-antiredirect-status])`).join(",");
  1089. const aNodes = qA(queryString);
  1090. if (aNodes.length === 0) return;
  1091. COUNT(`[${siteName}-Anti-Redirect]`);
  1092. const taskList = aNodes.reduce((tasks, node) => {
  1093. updateNodeAttributes(options, node);
  1094. setForceNewTab(options, node);
  1095. setAdvancedAntiRedirect(options, node, tasks, siteName);
  1096. return tasks;
  1097. }, []);
  1098. parallelTasks(taskList, 10);
  1099. }
  1100.  
  1101. function fetchData(url, resolve, reject, readystate, error, timeout) {
  1102. const headers = { Accept: "*/*", Referer: global.location.origin.replace(/^http:/i, "https:") };
  1103. const [onload, onerror, ontimeout] = [readystate(resolve, reject), error(reject, resolve), timeout(reject)];
  1104. GMxmlhttpRequest({ url, headers, method: "GET", timeout: 25e3, onload, onerror, ontimeout });
  1105. }
  1106.  
  1107. async function getRealUrl(url, node, name, { onloadFunc, onerrorFunc, ontimeoutFunc }) {
  1108. try {
  1109. const res = await new Promise((resolve, reject) => {
  1110. if (!cachedRequestLinks.has(url)) {
  1111. cachedRequestLinks.set(url, null);
  1112. fetchData(url, resolve, reject, onloadFunc, onerrorFunc, ontimeoutFunc);
  1113. } else reject(new RangeError("DuplicateLinksError"));
  1114. });
  1115. return handleSuccess(res, url, node);
  1116. } catch (e) {
  1117. return handleError(e, url, node, name);
  1118. }
  1119. }
  1120.  
  1121. function handleSuccess(res, url, node) {
  1122. cachedRequestLinks.set(url, res);
  1123. setRealLink(node, res);
  1124. toggleLoadClass(node)?.remove();
  1125. DEBUG("Parsed link:", { node, parsed: res, origin: url });
  1126. }
  1127.  
  1128. function handleError(e, url, node, name) {
  1129. if (["URLBrokenError", "TimeoutError", "URLNotExistError", "ResponseError"].includes(e?.message)) cachedRequestLinks.set(url, url);
  1130. if (e?.message === "DuplicateLinksError") handleDuplicateLinksError(url, node);
  1131. else {
  1132. setErrorLink(node);
  1133. toggleLoadClass(node)?.remove();
  1134. ERROR("antiRedirect_%s: %s %O", name, e?.message, { Node: node, Text: node.textContent, URL: node.href });
  1135. }
  1136. }
  1137.  
  1138. function handleDuplicateLinksError(url, node) {
  1139. def.count.duplicate++;
  1140. const attemptToFindCacheLink = raf.setInterval(() => {
  1141. const cachedRealLinks = cachedRequestLinks.get(url);
  1142. if (!cachedRealLinks) return;
  1143. if (cachedRealLinks === url) setErrorLink(node);
  1144. else {
  1145. DEBUG("Duplicate link:", { node, url: cachedRealLinks });
  1146. setRealLink(node, cachedRealLinks);
  1147. }
  1148. def.count.duplicate--;
  1149. toggleLoadClass(node)?.remove();
  1150. raf.clearInterval(attemptToFindCacheLink);
  1151. }, 5e2);
  1152. }
  1153.  
  1154. function toggleLoadClass(node) {
  1155. if (node && IS_DEBUG) return { remove: () => node.classList.remove(def.const.loading), add: () => node.classList.add(def.const.loading) };
  1156. }
  1157.  
  1158. function setRealLink(node, url) {
  1159. node.href = url;
  1160. IS_REAL_WEBKIT && node.setAttribute("title", url);
  1161. node.setAttribute("gd-antiredirect-status", "success");
  1162. }
  1163.  
  1164. function setErrorLink(node) {
  1165. node.classList.add(def.notice.linkerror);
  1166. node.setAttribute("gd-antiredirect-status", "failed");
  1167. node.setAttribute("title", `${IS_CHN ? "该链接目前无法正常访问。" : "This link is currently not accessible."}`);
  1168. }
  1169.  
  1170. function handlePageCheck(count) {
  1171. DEBUG(`(${count ?? cachedRequestLinks.size}) Task Done! (${def.count.duplicate}) Dup.Task!`);
  1172. if (antiLinkRedirect && cachedRequestLinks.size > 0 && def.count.duplicate === 0) {
  1173. !cachedRequestLinks.clear() && DEBUG("Task Clear!");
  1174. }
  1175. if (antiResultsFilter && usedFilterWords.size > 0) {
  1176. !usedFilterWords.clear() && DEBUG("Filter Clear!");
  1177. }
  1178. }
  1179.  
  1180. function parallelTasks(tasks, maxCount = 3) {
  1181. const taskLength = tasks.length;
  1182. if (taskLength === 0) return;
  1183. let [currentIndex, finishedCount] = [0, 0];
  1184. const taskCount = Math.min(maxCount, taskLength);
  1185. function nextTask() {
  1186. if (currentIndex >= taskLength) return;
  1187. const task = tasks[currentIndex];
  1188. currentIndex++;
  1189. task().then(result => {
  1190. finishedCount++;
  1191. if (finishedCount === taskLength) deBounce({ fn: handlePageCheck, delay: 1e3, timer: "doTask" })(result);
  1192. else nextTask();
  1193. });
  1194. }
  1195. for (let i = 0; i < taskCount; i++) nextTask();
  1196. }
  1197.  
  1198. function reportIDMHijacking() {
  1199. const IDMText = IS_CHN
  1200. ? "PDF文件下载警告:\r\nInternet Download Manager (IDM) 等下载器的劫持可能会造成文件被直接下载。"
  1201. : "PDF File Download Warning:\r\nHijacking of downloaders such as Internet Download Manager (IDM) may cause files to be downloaded directly.";
  1202. __console("warn", IDMText);
  1203. }
  1204.  
  1205. function rejectResponse(response, resolve, reject, url) {
  1206. const resUrl = response.finalUrl || response.responseURL || url;
  1207. if (/^2\d\d$/.test(response.status)) {
  1208. if (response.statusText === "Intercepted by the IDM Advanced Integration") reportIDMHijacking();
  1209. resolve(resUrl);
  1210. } else if (response.status !== 0) resUrl === url ? reject(new Error("ResponseError")) : resolve(resUrl);
  1211. }
  1212.  
  1213. function getBingDecodeURI(url) {
  1214. const uParam = new URL(url).searchParams.get("u");
  1215. return uParam ? decrypt(uParam.slice(2).replace(/[-_]/g, v => (v === "-" ? "+" : "/"))) : url;
  1216. }
  1217.  
  1218. function getToutiaoDecodeURI(url) {
  1219. return decodeURIComponent(new URL(url).searchParams.get("url") ?? "");
  1220. }
  1221.  
  1222. function getYahooDecodeURI(url) {
  1223. const res = url.match(/\/RU=([^/]+)\//)?.[1];
  1224. return decodeURIComponent(res ?? "");
  1225. }
  1226.  
  1227. async function getNoneXHRDecodeURI(url, node, siteName, decodeUrl) {
  1228. try {
  1229. const d = await new Promise((resolve, reject) => {
  1230. if (!cachedRequestLinks.has(url)) {
  1231. cachedRequestLinks.set(url, null);
  1232. resolve(decodeUrl || url);
  1233. } else reject(new RangeError("DuplicateLinksError"));
  1234. });
  1235. return handleSuccess(d, url, node);
  1236. } catch (e) {
  1237. return handleError(e, url, node, siteName);
  1238. }
  1239. }
  1240.  
  1241. function getXHRDecodeURI(url, node, siteName) {
  1242. return getRealUrl(url, node, siteName, {
  1243. onloadFunc: (resolve, reject) => response => {
  1244. if (response.readyState !== 4) return;
  1245. if (response.status === 200) {
  1246. let resUrl = response.finalUrl || response.responseURL || url;
  1247. if (resUrl === url) {
  1248. const resText = response.responseText || response.response || "";
  1249. const res = resText.match(/URL\s*=\s*'([^']+)'/);
  1250. if (res) resUrl = res[1];
  1251. else reject(new Error("URLNotExistError"));
  1252. }
  1253. resolve(resUrl);
  1254. } else rejectResponse(response, resolve, reject, url);
  1255. },
  1256. onerrorFunc: reject => () => reject(new Error("URLBrokenError")),
  1257. ontimeoutFunc: reject => () => reject(new Error("TimeoutError")),
  1258. });
  1259. }
  1260.  
  1261. function advancedAntiRedirection(siteName, node, task) {
  1262. const url = node?.href?.replace(/^http:/i, "https:");
  1263. if (!url) return;
  1264. const tasks = {
  1265. Baidu: () =>
  1266. getRealUrl(url, node, siteName, {
  1267. onloadFunc: (resolve, reject) => response => {
  1268. if (response.readyState !== 4) return;
  1269. if (response.status === 200 || response.status === 301) {
  1270. let resUrl = response.finalUrl || response.responseURL || url;
  1271. if (resUrl === url) {
  1272. const responseHeader = response.responseHeaders?.match(/Location:\s*([\S]+)/i);
  1273. if (responseHeader) resUrl = responseHeader[1];
  1274. else reject(new Error("URLNotExistError"));
  1275. }
  1276. resolve(resUrl);
  1277. } else rejectResponse(response, resolve, reject, url);
  1278. },
  1279. onerrorFunc: (reject, resolve) => e => {
  1280. if (e.error?.includes("Request was redirected to a not whitelisted URL") || e.error?.includes("This domain is not a part of the @connect list")) {
  1281. const realUrl = e.error?.toString().match(/Refused to connect to "([^"]+)"/)?.[1];
  1282. if (!realUrl || realUrl.includes("/search/error") || realUrl.includes("/static/captcha")) reject(new Error("URLNotExistError"));
  1283. resolve(realUrl);
  1284. } else reject(new Error("URLBrokenError"));
  1285. },
  1286. ontimeoutFunc: reject => () => reject(new Error("TimeoutError")),
  1287. }),
  1288. So360: () => getXHRDecodeURI(url, node, siteName),
  1289. Sogou: () => getXHRDecodeURI(url, node, siteName),
  1290. Bing: () => getNoneXHRDecodeURI(url, node, siteName, getBingDecodeURI(url)),
  1291. Toutiao: () => getNoneXHRDecodeURI(url, node, siteName, getToutiaoDecodeURI(url)),
  1292. Yahoo: () => getNoneXHRDecodeURI(url, node, siteName, getYahooDecodeURI(url)),
  1293. };
  1294. toggleLoadClass(node)?.add();
  1295. return tasks[siteName] ?? task;
  1296. }
  1297.  
  1298. /* ANTIADS_FUNCTIONS */
  1299.  
  1300. const siteAdblockHandlers = {
  1301. Bing: (siteName, clean) => {
  1302. if (!CUR_HOST_NAME.startsWith("cn") || !qA(`:is(#b_results,#b_topw)>li:not(.${def.var.disappear})>div.b_caption>p[class*='b_lineclamp']`).length) return;
  1303. qA(`:is(#b_results,#b_topw)>li:not(.${def.var.disappear})`).forEach(node => {
  1304. const adv = qS("div.b_caption>p[class*='b_lineclamp']", node);
  1305. if (adv && (adv.className.includes("b_lineclamp2") || gCS(adv).getPropertyValue("-webkit-line-clamp") === "2")) {
  1306. COUNT(`[${siteName}-Anti-Ads-Deep-exp]`);
  1307. node.classList.add(def.var.disappear);
  1308. clean === true && safeRemoveNode(node);
  1309. }
  1310. });
  1311. },
  1312. Yandex: (siteName, clean) => {
  1313. const querystring = `.AliceFabPromo-Close,.PopupDesktop-Buttons button.PopupDesktop-Button_type_close`;
  1314. qA(querystring).forEach(item => item.click());
  1315. if (qA("li.serp-item.serp-item_card div.Organic-Subtitle span.organic__advLabel,li[data-cid][class*='_card'] .Organic-Subtitle>.Organic-Path~span").length === 0) return;
  1316. COUNT(`[${siteName}-Anti-Ads-Deep-exp]`);
  1317. qA("li.serp-item.serp-item_card,li[data-cid][class*='_card']").forEach(node => {
  1318. const adsTxtNode = qS(".Organic-Subtitle span.organic__advLabel", node);
  1319. const _moz_adsTxtNode = qS(".Organic-Subtitle>.Organic-Path~span", node);
  1320. if (/^(ad|[РекламPeknam]{7})$/i.test(_moz_adsTxtNode?.textContent || adsTxtNode?.textContent)) {
  1321. node.classList.add(def.var.disappear);
  1322. clean === true && safeRemoveNode(node);
  1323. }
  1324. });
  1325. },
  1326. So360: (siteName, clean) => {
  1327. if (qA("ul.section>li span.txt>s, ul.result>li>div.res-recommend-tag").length === 0) return;
  1328. COUNT(`[${siteName}-Anti-Ads-Deep-exp]`);
  1329. qA("ul.section>li,ul.result>li").forEach(node => {
  1330. const ads = qS("span[class='txt']>s", node);
  1331. if (!ads?.textContent?.includes("\u5e7f\u544a") && !qS("div.res-recommend-tag", node)) return;
  1332. node.classList.add(def.var.disappear);
  1333. clean === true && safeRemoveNode(node);
  1334. });
  1335. },
  1336. Ecosia: () => qS(`button.banner__close[data-test-id="banner-close"][aria-label="Close"]`)?.click(),
  1337. Qwant: () => qS(`button[class][aria-label="close"]:has(svg)`)?.click(),
  1338. Brave: () => qS(`.promo-tooltip>button.btn--icon[aria-label="Close"]`)?.click(),
  1339. Duckduckgo: () => qS(`button[data-testid="serp-popover-promo-close"]`)?.click(),
  1340. Yahoo: () => qS("button.refresh-soft-intro-dismiss-button")?.click(),
  1341. Swisscows: siteName => {
  1342. qS(`.dialog-content[id^="radix-"][role="dialog"][data-state="open"]>.buttons>button.button.button-link`)?.click();
  1343. if (qA(".web-results>article:not([data-ads]) .site>a:is(.policy,.ad)").length === 0) return;
  1344. qA(".web-results>article").forEach(node => {
  1345. if (qS(".site>a:is(.policy,.ad)", node)) {
  1346. node.style.cssText = "height:0;min-height:0;overflow:hidden;margin:0;padding:0";
  1347. node.dataset.ads = COUNT(`[${siteName}-Anti-Ads-Deep-exp]`) || "";
  1348. }
  1349. });
  1350. },
  1351. };
  1352.  
  1353. function parseAntiAdvertising({ selectors, siteName, isRemoveNodes }) {
  1354. if (selectors && typeof selectors === "string") {
  1355. if (!qS(`#${def.const.rndadvName}`)) {
  1356. COUNT(`[${siteName}-Anti-Ads]`);
  1357. const cssText = `:root :is(${selectors}){display:none!important}`;
  1358. addStyle({ target: document.head, styleId: def.const.rndadvName, media: "all", styleContent: cssText });
  1359. }
  1360. isRemoveNodes === true && safeRemoveNode(selectors);
  1361. }
  1362. AdvancedAntiAdvertising(siteName, isRemoveNodes);
  1363. }
  1364.  
  1365. function AdvancedAntiAdvertising(siteName, clean) {
  1366. const AdblockHandler = siteAdblockHandlers[siteName];
  1367. if (typeof AdblockHandler !== "function") return;
  1368. try {
  1369. AdblockHandler.length > 0 ? AdblockHandler(siteName, clean) : AdblockHandler();
  1370. } catch (e) {
  1371. ERROR("AdvancedAntiAdvertising:", e.message);
  1372. }
  1373. }
  1374.  
  1375. /* PRELOAD_FUNCTIONS */
  1376.  
  1377. async function fetchUpdateResponse(url, timeout = 1e4) {
  1378. try {
  1379. return await new Promise((resolve, reject) => {
  1380. const headers = { Accept: "*/*", Referer: url };
  1381. const onload = response => {
  1382. if (response.readyState !== 4) return;
  1383. if (response.status === 200) resolve({ res: response.responseText || response.response, url });
  1384. else if (response.status !== 0) reject(new Error("NoAccessError"));
  1385. };
  1386. const onerror = () => reject(new Error("NetworkError"));
  1387. const ontimeout = () => reject(new Error("TimeoutError"));
  1388. GMxmlhttpRequest({ url, headers, method: "GET", nocache: true, timeout, onload, onerror, ontimeout });
  1389. });
  1390. } catch (e) {
  1391. throw new Error(`fetchUpdateResponse: ${e.message}`);
  1392. }
  1393. }
  1394.  
  1395. async function fetchAndCacheRemoteIcons(remoteURL) {
  1396. if (!CUR_WINDOW_TOP) return;
  1397. let iconDataURL = null;
  1398. try {
  1399. const iconBase64Data = await cache.get(REMOTEICONS);
  1400. if (!iconBase64Data || setDebuggerMode()) {
  1401. DEBUG("%cRequest remote icon data...", "color:#25f");
  1402. iconDataURL = await requestRemoteIcon(remoteURL);
  1403. if (iconDataURL) cache.set(REMOTEICONS, iconDataURL, 2592e6) ?? DEBUG("%cRemote icon data parsed successfully.", "color:#006400");
  1404. else DEBUG("%cRemote icon data parsing failed.", "color:#ff0000");
  1405. } else {
  1406. DEBUG("%cGet local cached icon data.", "color:#006400");
  1407. iconDataURL = iconBase64Data;
  1408. }
  1409. } catch (e) {
  1410. ERROR(`fetchAndCacheRemoteIcons: Can't request the icon data.`, e?.message);
  1411. }
  1412. return iconDataURL;
  1413. }
  1414.  
  1415. void (async function (getUpdateAddress) {
  1416. const listSite = {
  1417. baidu: {
  1418. siteTypeID: 1,
  1419. siteButtonName: IS_CHN ? "百度一下" : "𝐁𝐚𝐢𝐝𝐮",
  1420. siteNickName: IS_CHN ? "百度 搜索" : "𝐁𝐚𝐢𝐝𝐮.𝐜𝐨𝐦",
  1421. siteHostName: "www.baidu.com",
  1422. webURL: "https://www.baidu.com/s?ie=utf-8&rqlang=cn&wd=",
  1423. imageURL: "https://image.baidu.com/search/index?tn=baiduimage&ps=1&ie=utf-8&word=",
  1424. imageType: ["baiduimage", "baiduimagedetail"],
  1425. splitTypeName: "tn",
  1426. mainSelector: ".s_btn_wr,#sugOut,span[class^='submit-btn']",
  1427. buttonCssText: `a,a em{text-decoration:none!important}:not([class^="page-inner"])>a:not(.${def.notice.linkerror}):hover{text-decoration:underline!important}#form{white-space:nowrap}#u{z-index:1!important}#${def.const.rndButtonID}{position:absolute;z-index:1999999995;display:inline-block;margin:0;padding:0;height:40px;vertical-align:top;line-height:40px;right:-210px}#${def.const.rndButtonID} *{-webkit-text-stroke:0 transparent!important}#${def.const.rndButtonID} #${def.const.leftButton}{display:inline-block;margin-left:2px;height:40px}#${def.const.rndButtonID} #${def.const.rightButton}{display:inline-block;margin-left:-1px;height:40px}#${def.const.leftButton} input{margin:0;padding:0 12px 0 18px!important;height:40px;min-width:100px;border:0;border-bottom-left-radius:10px;border-top-left-radius:10px;background:#4e6ef2;color:#fff;vertical-align:top;font-weight:500;font-size:16px!important;line-height:100%;cursor:pointer}#${def.const.rightButton} input{margin:0;padding:0 18px 0 12px!important;height:40px;min-width:100px;border:0;border-top-right-radius:10px;border-bottom-right-radius:10px;background:#4e6ef2;color:#fff;vertical-align:top;font-weight:500;font-size:16px!important;line-height:100%;cursor:pointer}#${def.const.leftButton} input:hover,#${def.const.rightButton} input:hover{background:#4662d9;border:1px solid transparent;}`,
  1428. resultListProp: { qs: `#content_left>div.c-container[tpl]:not([tpl='recommend_list'],[tpl^="rel-"])`, delay: 10 },
  1429. keywords: "#wrapper_wrapper em,.c-gap-top-small b",
  1430. antiRedirectFn: () =>
  1431. deBounce({ fn: parsingAntiRedirect, delay: 20, timer: "baidu_ar" })(".c-container a[href*='//www.baidu.com/link?url=']", "Baidu", {
  1432. useNewTab: true,
  1433. removeDataSet: true,
  1434. advancedAnti: true,
  1435. }),
  1436. antiAdsFn: () =>
  1437. deBounce({ fn: parseAntiAdvertising, delay: 20, timer: "baidu_ad", immed: true })({
  1438. selectors: `#s-hotsearch-wrapper,.result-op[tpl='sp_hot_sale'],.result-op[tpl='b2b_prod'],#content_left>div:not([class]):not([style]),div[data-placeid],[id$='_canvas'],div.result.c-container:not([class~='xpath-log']),.imgpage .imglist>li.newfcImgli,.ec_wise_ad,div[class^='result-op'][tpl='right_tabs'][data-click],div[class^='result-op'][tpl='right_links'][data-click],#searchTag,#content_left>div.c-container[tpl="recommend_list"],#con-ar div[tpl="right_recommends_merge"]`,
  1439. siteName: "Baidu",
  1440. isRemoveNodes: true,
  1441. }),
  1442. },
  1443. google: {
  1444. siteTypeID: 2,
  1445. siteButtonName: "𝐆𝐨𝐨𝐠𝐥𝐞",
  1446. siteNickName: IS_CHN ? "𝐆𝐨𝐨𝐠𝐥𝐞 搜索" : "𝐆𝐨𝐨𝐠𝐥𝐞.𝐜𝐨𝐦",
  1447. siteHostName: "www.google.com",
  1448. webURL: "https://www.google.com/search?newwindow=1&sca_upv=1&source=hp&q=",
  1449. imageURL: "https://www.google.com/search?newwindow=1&sca_upv=1&source=lnms&udm=2&sa=X&q=",
  1450. imageType: ["isch", "2"],
  1451. splitTypeName: ["tbm", "udm"],
  1452. mainSelector: "form button[type='submit']",
  1453. buttonCssText: `#pnnext>span:nth-child(2){clear:left}#${def.const.rndButtonID}{position:relative;z-index:100;display:flex;margin:0 4px 0 -5px;justify-content:center;align-items:center}#${def.const.rndButtonID} *{text-shadow:none!important;-webkit-text-stroke:0 transparent!important}#${def.const.rndButtonID} #${def.const.leftButton}{padding:0 2px 0 8px}.${def.const.scrollspan}{min-height:26px;margin-right:3px!important}.${def.const.scrollbars}{display:inline-block;margin:0;height:26px!important;font-weight:400!important;font-size:13px!important}#${def.const.leftButton} input{margin:0;padding:0 12px 0 18px!important;height:38px;min-width:90px;border:0;border-bottom-left-radius:24px;border-top-left-radius:24px;background:#1a73e8;box-shadow:none;color:#fff;vertical-align:top;font-weight:500;font-size:16px;line-height:100%;cursor:pointer}#${def.const.rightButton} input{margin:0;padding:0 18px 0 12px!important;height:38px;min-width:90px;border:0;border-top-right-radius:24px;border-bottom-right-radius:24px;background:#1a73e8;box-shadow:none;color:#fff;vertical-align:top;font-weight:500;font-size:16px;line-height:100%;cursor:pointer}#${def.const.leftButton} input:hover,#${def.const.rightButton} input:hover{background:#1b66c9;}@media (prefers-color-scheme: dark){#${def.const.leftButton} input,#${def.const.rightButton} input{background:#8ab4f8;box-shadow:0 1px 3px 1px rgba(0, 0, 0, 0.15),0 1px 2px rgba(0, 0, 0, 0.3);color:#202124}#${def.const.leftButton} input:hover,#${def.const.rightButton} input:hover{background:#93baf9}}`,
  1454. resultListProp: { qs: `div.MjjYud div.Ww4FFb.vt6azd[data-hveid^="C"][data-hveid$="AA"]:not(:has(div[jscontroller="TvBckd"]))`, delay: 10 },
  1455. keywords: ".aCOpRe em,.aCOpRe a em,.yXK7lf em,.yXK7lf a em,.st em,.st a em,.c2xzTb b,em.qkunPe",
  1456. antiRedirectFn: () =>
  1457. deBounce({ fn: parsingAntiRedirect, delay: 20, timer: "google_ar" })(
  1458. "#rcnt div[data-hveid^='C'][data-hveid$='AA'] :not(h3.ob5Hkd,.d0fCJc)>a:not(.ngTNl,.oRJe3d,.k8XOCe,[jsname='ZWuC2'],.fl,#pnprev,#pnnext)",
  1459. "Google",
  1460. { useNewTab: true, cleanAttr: ["ping"], removeDataSet: true }
  1461. ),
  1462. antiAdsFn: () =>
  1463. deBounce({ fn: parseAntiAdvertising, delay: 20, timer: "google_ad", immed: true })({
  1464. selectors: `div[aria-label='\u5e7f\u544a'],div[aria-label='Ads' i],#bottomads,#tvcap`,
  1465. siteName: "Google",
  1466. }),
  1467. },
  1468. bing: {
  1469. siteTypeID: 3,
  1470. siteButtonName: "𝐁𝐢𝐧𝐠 ®",
  1471. siteNickName: IS_CHN ? "𝐁𝐢𝐧𝐠 搜索" : "𝐁𝐢𝐧𝐠.𝐜𝐨𝐦",
  1472. siteHostName: "www.bing.com",
  1473. webURL: "https://www.bing.com/search?go=Search&qs=ds&form=QBRE&rdr=1&hta=off&q=",
  1474. imageURL: "https://www.bing.com/images/search?qs=ds&form=QBIR&first=1&q=",
  1475. imageType: ["images"],
  1476. splitTypeName: { split: "/", index: 1 },
  1477. mainSelector: `.b_searchboxForm>input[type="hidden"][name="form"]`,
  1478. buttonCssText: `html{overflow-x:hidden}#sb_form .inline_sb{border-radius:24px}.${def.const.searchbox}{border-radius:8px!important}a,#b_results>li[class] a:not(.wiki_seemore),#b_results .b_no a,#b_context .mediumCardTitle{color:#001ba0}#${def.const.rndButtonID}{position:relative;z-index:0;display:inline-flex;margin:0;padding:0 6px 0 0;width:auto;height:38px;min-width:180px;vertical-align:middle;justify-content:center;flex-wrap:nowrap}#${def.const.rndButtonID} *{text-shadow:none!important;-webkit-text-stroke:0 transparent!important}#${def.const.leftButton},#${def.const.rightButton}{margin:0;padding:0;width:auto}#${def.const.rndButtonID} input{box-sizing:border-box;height:38px;min-width:90px;border:1px solid #174ae4;background-color:#f7faff;color:#174ae4;font-weight:600;font-size:16px;line-height:100%;cursor:pointer}#${def.const.leftButton} input{margin:0;padding:0 12px 0 18px;border-bottom-left-radius:24px;border-top-left-radius:24px}#${def.const.rightButton} input{margin:0 0 0 2px;padding:0 18px 0 12px;border-top-right-radius:24px;border-bottom-right-radius:24px}.${def.const.scrollspan}{/*margin:-14px -3px 0 0!important;max-height:28px*/}.${def.const.scrollbars}{/*max-height:28px;font-size:14px!important*/}.${def.const.scrollspan2}{margin:0!important;padding:4px 4px 0 8px!important;max-height:30px;vertical-align:top!important}.${def.const.scrollbars2}{margin-right:0!important;padding:0 12px!important;max-height:30px;border-radius:4px!important;vertical-align:top!important}#${def.const.leftButton} input:hover,#${def.const.rightButton} input:hover{background-color:#fff;background-color:#f0f3f6;box-shadow:0 0 4px #174ae4;color:#174ae4;transition:border .1s linear,box-shadow .3s linear}.${def.notice.random}_input{width:300px!important}@media (prefers-color-scheme: dark){.b_dark #b_results>li[class] a{color:#7aabeb}#${def.const.leftButton} input,#${def.const.rightButton} input{border:1px solid #a2b7f4;background:transparent;color:#a2b7f4}#${def.const.leftButton} input:hover,#${def.const.rightButton} input:hover{background:#a2b7f4;color:#333}}`,
  1479. resultListProp: {
  1480. qs: `#b_results>li.b_algo:not(.b_algoBorder,.b_topborder),#b_results>li.b_vidAns .mmlist>div[id],#b_results>li.b_mop .b_slidebar>div.slide,#b_topw>li.b_ans,aside>ol#b_context>li.b_algo`,
  1481. delay: 10,
  1482. },
  1483. keywords:
  1484. Number(getUrlParam("ensearch")) || Number(gbCookies.getItem("ENSEARCH")?.match(/[=](\d)/)?.[1])
  1485. ? "strong,.b_no h4,.b_strong,.b_ad .b_adlabel strong,.cbl"
  1486. : "#sp_requery strong,#sp_recourse strong,.sb_adTA_title_link_cn strong,.b_ad .ad_esltitle~div strong,h2 strong,#b_results .b_algo p strong,.b_caption p strong,.b_snippetBigText strong,.recommendationsTableTitle+.b_slideexp strong,.recommendationsTableTitle+table strong,.recommendationsTableTitle+ul strong,.pageRecoContainer .b_module_expansion_control strong,.pageRecoContainer .b_title>strong,.b_rs strong,.b_rrsr strong,.richrswrapper strong,#dict_ans strong,.b_listnav>.b_ans_stamp>strong,#b_content #ans_nws .na_cnt strong,.b_vidAns strong,.adltwrnmsg strong",
  1487. antiRedirectFn: function () {
  1488. safeWindow.Object.assign(GMunsafeWindow, { AwayTimeScrollTopPoleRS: false, AwayTimeThreshold: 864e3 });
  1489. const antiRedirect = () => {
  1490. parsingAntiRedirect("#b_results>li:not(.b_pag,#mfa_root) a:not([role='button']):not([href*='.bing.com/ck/a?'])", "Bing", { useNewTab: true, cleanAttr: ["h"] });
  1491. parsingAntiRedirect("#b_results a.b_widePag:not([href*='.bing.com/ck/a?'])", "Bing", { forceSelf: true, cleanAttr: ["h"] });
  1492. parsingAntiRedirect("#b_content a[href*='.bing.com/ck/a?']:not([role='button'],.b_widePag)", "Bing", { useNewTab: true, cleanAttr: ["h"], advancedAnti: true });
  1493. parsingAntiRedirect("#b_content a.b_widePag[href*='.bing.com/ck/a?']", "Bing", { forceSelf: true, cleanAttr: ["h"], advancedAnti: true });
  1494. };
  1495. deBounce({ fn: antiRedirect, delay: 20, timer: "bing_ar" })();
  1496. },
  1497. antiAdsFn: () =>
  1498. deBounce({ fn: parseAntiAdvertising, delay: 20, timer: "bing_ad", immed: true })({
  1499. selectors: `li.b_ans>div.wpt_bc_container,li.b_ans>#relatedSearchesLGWContainer,li.b_ans>.b_rs,li.b_ad,#b_pole,#b_content .b_underSearchbox,#b_header>div[id^="bnp."][data-vertical],#b_context li.b_ans .b_spa_adblock,.ad_sc,.b_adBottom,.b_adLastChild,.b_adPATitleBlock,.b_spa_adblock,.mapsTextAds,.pa_sb,.productAd,[id$="adsMvCarousel"],a[href*="/aclick?ld="],div.pagereco_anim,#inline_rs,#ev_talkbox_wrapper,#b_content>main[aria-label]>#b_ims_bza_pole,.shop_page .br-poleoffcarousel,#b_content>div#pole>div[class="ra_car_block ra_pole"]>div.ra_car_container,#pole>.productAd[data-ad-carousel],.b_adPATitleBlock+div,a.sb_meta[href^="http://advertise.bingads.microsoft.com"],.promotion-panel-inner,.ins_exp.vsp,li[class="b_algo"]:has(.b_attribution[data-partnertag] + p[class]),.b_ans:has([class^="xm_"][class*="_ansCont"])`,
  1500. siteName: "Bing",
  1501. }),
  1502. },
  1503. duckduckgo: {
  1504. siteTypeID: 4,
  1505. siteButtonName: "𝐃𝐮𝐜𝐤𝐝𝐮𝐜𝐤𝐠𝐨",
  1506. siteNickName: IS_CHN ? "𝐃𝐮𝐜𝐤𝐝𝐮𝐜𝐤𝐠𝐨 搜索" : "𝐃𝐮𝐜𝐤𝐝𝐮𝐜𝐤𝐠𝐨",
  1507. siteHostName: "duckduckgo.com",
  1508. webURL: "https://duckduckgo.com/?k1=-1&kl=wt-wt&kd=-1&ko=1&kn=1&kp=-2&t=h_&ia=web&q=",
  1509. imageURL: "https://duckduckgo.com/?k1=-1&kl=wt-wt&kd=-1&ko=s&kn=1&kp=-2&t=h_&iax=images&ia=images&q=",
  1510. imageType: ["images"],
  1511. splitTypeName: "ia",
  1512. mainSelector: "#search_form",
  1513. buttonCssText: `#${def.const.rndButtonID}{position:absolute;top:0;right:-188px;z-index:1999999995;display:block;height:44px}#${def.const.leftButton}{display:inline-block;height:44px}#${def.const.rightButton}{display:inline-block;margin:0 0 0 -2px;height:44px}#${def.const.leftButton} input{margin:0;padding:1px 10px 1px 15px!important;height:44px;min-width:100px;border:1px solid var(--theme-col-bg-button-secondary-hover);border-bottom-left-radius:var(--default-border-radius);border-top-left-radius:var(--default-border-radius);background:transparent;box-shadow:0 2px 3px rgba(0, 0, 0, 0.06);color:var(--theme-col-txt-button-secondary);vertical-align:top;font-weight:400;font-size:16px;line-height:100%;cursor:pointer}#${def.const.rightButton} input{margin:0;padding:1px 15px 1px 10px!important;height:44px;min-width:100px;border:1px solid var(--theme-col-bg-button-secondary-hover);border-top-right-radius:var(--default-border-radius);border-bottom-right-radius:var(--default-border-radius);background:transparent;box-shadow:0 2px 3px rgba(0, 0, 0, 0.06);color:var(--theme-col-txt-button-secondary);vertical-align:top;font-weight:400;font-size:16px;line-height:100%;cursor:pointer}#${def.const.leftButton} input:hover,#${def.const.rightButton} input:hover{border:1px solid transparent;background-color:#2950bf!important;color:#fff!important}`,
  1514. resultListProp: {
  1515. qs: `ol.react-results--main>li[data-layout="organic"],ol.react-results--main>li[data-layout="videos"] div.module--carousel__item,ol.react-results--main>li:has(div[data-react-module-id="about"])`,
  1516. delay: 10,
  1517. },
  1518. keywords: "strong, b",
  1519. antiRedirectFn: null,
  1520. antiAdsFn: () =>
  1521. deBounce({ fn: parseAntiAdvertising, delay: 20, timer: "ddg_ad", immed: true })({
  1522. selectors: `.footer,.react-results--main>li[data-layout="related_searches"]>div[class]`,
  1523. siteName: "Duckduckgo",
  1524. isRemoveNodes: true,
  1525. }),
  1526. },
  1527. sogou: {
  1528. siteTypeID: 5,
  1529. siteButtonName: IS_CHN ? "搜狗搜索" : "𝐒𝐨𝐠𝐨𝐮",
  1530. siteNickName: IS_CHN ? "搜狗 搜索" : "𝐒𝐨𝐠𝐨𝐮.𝐜𝐨𝐦",
  1531. siteHostName: "www.sogou.com",
  1532. webURL: "https://www.sogou.com/web?query=",
  1533. imageURL: "https://pic.sogou.com/pics?query=",
  1534. imageType: ["pics", "d", "v"],
  1535. splitTypeName: { split: "/", index: 1 },
  1536. mainSelector: "input#searchBtn,input[type='button'][uigs='search_article'],input[type='submit']:is(.search-btn,.sbtn1)",
  1537. buttonCssText: `#${def.const.rndButtonID}{position:absolute;top:0;right:0;z-index:1999999995;margin:-1px 0 0;padding:0;width:auto;height:39px;cursor:pointer;-webkit-appearance:none}#${def.const.rndButtonID} *{-webkit-text-stroke:0 transparent!important}#${def.const.leftButton}{display:inline;height:39px}#${def.const.rightButton}{display:inline;height:39px}#${def.const.leftButton} input{margin:0;padding:0 18px!important;height:39px;min-width:100px;border:2px solid #222;border-radius:12px;background:#f5f5f5;color:#000;vertical-align:top;font-weight:500;font-size:14px!important;line-height:100%;cursor:pointer}#${def.const.rightButton} input{margin:0;padding:0 18px!important;height:39px;min-width:100px;border:2px solid #222;border-radius:12px;background:#f5f5f5;color:#000;vertical-align:top;font-weight:500;font-size:14px!important;line-height:100%;cursor:pointer}#${def.const.leftButton} input:hover,#${def.const.rightButton} input:hover{border:2px solid #205aef;background:#e9f2ff;color:#205aef}.${def.notice.random}_images{height:34px!important;border:1px solid #ababab!important;border-radius:3px!important;background:##fafafa!important}.${def.notice.random}_weixin{height:34px!important;border:1px solid #00a06a!important;border-radius:2px!important;background:#fff!important;color:#00a06a!important;font-size:15px!important}.${def.notice.random}_weixin:hover{background:#f7fffd!important}`,
  1538. resultListProp: { qs: `div.results>div.vrwrap,div.results>div.rb`, delay: 10 },
  1539. keywords: "#wrapper em",
  1540. antiRedirectFn: () =>
  1541. deBounce({ fn: parsingAntiRedirect, delay: 20, timer: "sogou_ar" })("#wrapper a[href^='/link?url=']:not([uigs])", "Sogou", { useNewTab: true, advancedAnti: true }),
  1542. antiAdsFn: () =>
  1543. deBounce({ fn: parseAntiAdvertising, delay: 20, timer: "sogou_ad", immed: true })({
  1544. selectors: `#biz_tip_box_tuiguang_float,.pz_pc_new_container,.share-wrap,.sponsored,.tgad-box,[class~="ext_query"][id*="sq_ext_"],div.top-better-hintBox,#right>div.rvr-model:not([tpl]),.results>.reactResult`,
  1545. siteName: "Sogou",
  1546. isRemoveNodes: true,
  1547. }),
  1548. },
  1549. qwant: {
  1550. siteTypeID: 6,
  1551. siteButtonName: "𝐐𝐰𝐚𝐧𝐭",
  1552. siteNickName: IS_CHN ? "𝐐𝐰𝐚𝐧𝐭 搜索" : "𝐐𝐰𝐚𝐧𝐭.𝐜𝐨𝐦",
  1553. siteHostName: "www.qwant.com",
  1554. webURL: "https://www.qwant.com/?t=web&b=1&q=",
  1555. imageURL: "https://www.qwant.com/?t=images&b=1&q=",
  1556. imageType: ["images"],
  1557. splitTypeName: "t",
  1558. mainSelector: "form[data-testid='mainSearchBar']",
  1559. buttonCssText: `#${def.const.rndButtonID}{position:absolute;top:0;right:0;z-index:1999999995;display:block;height:48px}#${def.const.leftButton}{display:inline-block;height:48px}#${def.const.rightButton}{display:inline-block;margin:0;height:48px}#${def.const.leftButton} input{box-sizing:content-box;margin:1px 0;padding:0 6px 0 12px!important;height:48px;min-width:100px;box-shadow:var(--shadow-searchbar-elevation);transition:box-shadow var(--motion-duration-200) var(--motion-ease), color var(--motion-duration-300) var(--motion-ease), background-color var(--motion-duration-300) var(--motion-ease);border-bottom-left-radius:var(--border-radius-300);border-top-left-radius:var(--border-radius-300);background-color:var(--color-elevation-surface-elevation);color:var(--color-text-primary);vertical-align:top;font-weight:400;font-size:16px;line-height:100%;cursor:pointer}#${def.const.rightButton} input{box-sizing:content-box;margin:1px 0;padding:0 12px 0 6px!important;height:48px;min-width:100px;box-shadow:var(--shadow-searchbar-elevation);transition:box-shadow var(--motion-duration-200) var(--motion-ease), color var(--motion-duration-300) var(--motion-ease), background-color var(--motion-duration-300) var(--motion-ease);border-top-right-radius:var(--border-radius-300);border-bottom-right-radius:var(--border-radius-300);background-color:var(--color-elevation-surface-elevation);color:var(--color-text-primary);vertical-align:top;font-weight:400;font-size:16px;line-height:100%;cursor:pointer}#${def.const.leftButton} input:hover,#${def.const.rightButton} input:hover{background-color:var(--color-elevation-surface-raised);box-shadow:var(--shadow-searchbar-raised);}`,
  1560. resultListProp: { qs: `div[data-testid="containerWeb"] div[data-testid="sectionWeb"]>div>div,.is-sidebar>div>div div[style="display: block;"]`, delay: 50 },
  1561. keywords: "mark",
  1562. antiRedirectFn: null,
  1563. antiAdsFn: () =>
  1564. deBounce({ fn: parseAntiAdvertising, delay: 20, timer: "qwant_ad", immed: true })({
  1565. selectors: `div[data-testid="containerWeb"] section div[style="display: block;"]:has([data-testid="aserpok"]),.is-sidebar>div>div:has([data-testid="aserpok"]),[data-testid="containerWeb"] section>div>div:last-child`,
  1566. siteName: "Qwant",
  1567. removeDataSet: true,
  1568. }),
  1569. },
  1570. yandex: {
  1571. siteTypeID: 7,
  1572. siteButtonName: "𝐘𝐚𝐧𝐝𝐞𝐱",
  1573. siteNickName: IS_CHN ? "𝐘𝐚𝐧𝐝𝐞𝐱 搜索" : "𝐘𝐚𝐧𝐝𝐞𝐱.𝐜𝐨𝐦",
  1574. siteHostName: "yandex.com",
  1575. webURL: `https://yandex.${navigator.language === "ru" ? "ru" : "eu"}/search/?text=`,
  1576. imageURL: `https://yandex.${navigator.language === "ru" ? "ru" : "eu"}/images/search?from=tabbar&family=no&text=`,
  1577. imageType: ["images"],
  1578. splitTypeName: { split: "/", index: 1 },
  1579. mainSelector: "header form.HeaderForm",
  1580. buttonCssText: `#${def.const.rndButtonID}{position:relative;top:0;left:-12px;z-index:1999999995;margin:0;padding:0;width:max-content;height:52px;cursor:pointer;-webkit-appearance:none}#${def.const.leftButton}{display:inline-block;height:52px}#${def.const.rightButton}{display:inline-block;margin:0 0 0 -1px;height:52px}#${def.const.leftButton} input{padding:1px 12px 0 18px!important;height:52px;min-width:100px;border:none;box-shadow:0 0 0 2px inset rgba(0, 0, 0, 0.1);border-bottom-left-radius:28px;border-top-left-radius:28px;background:#fff;color:#00000073;vertical-align:top;font-weight:400;font-size:16px;line-height:100%;cursor:pointer}#${def.const.rightButton} input{padding:1px 18px 0 12px!important;height:52px;min-width:100px;border:none;box-shadow:0 0 0 2px inset rgba(0, 0, 0, .1);border-top-right-radius:28px;border-bottom-right-radius:28px;background:#fff;color:#00000073;vertical-align:top;font-weight:400;font-size:16px;line-height:100%;cursor:pointer}#${def.const.leftButton} input:hover,#${def.const.rightButton} input:hover{background-color:#fbfbfb}@media (prefers-color-scheme: dark){#${def.const.leftButton} input,#${def.const.rightButton} input{color:#eee;background:#18181a;box-shadow:0 0 0 2px inset #3a3a3c;}#${def.const.leftButton} input:hover,#${def.const.rightButton} input:hover{background:#333}}`,
  1581. resultListProp: { qs: "#search-result>li[data-fast]", delay: 10 },
  1582. keywords: ".OrganicTitleContentSpan b,.OrganicTextContentSpan b",
  1583. antiRedirectFn: () => deBounce({ fn: parsingAntiRedirect, delay: 20, timer: "yandex_ar" })("#search-result>li.serp-item a", "Yandex", { useNewTab: true, removeDataSet: true }),
  1584. antiAdsFn: () =>
  1585. deBounce({ fn: parseAntiAdvertising, delay: 20, timer: "yandex_ad", immed: true })({
  1586. selectors: `#distr-pcode-container>div,div.HeaderDesktopActions-Distribution.HeaderDesktopActions-Item,div[tabindex][class*='location_right-bottom'],span.distr-nav,div.market-cart`,
  1587. siteName: "Yandex",
  1588. isRemoveNodes: true,
  1589. }),
  1590. },
  1591. so360: {
  1592. siteTypeID: 8,
  1593. siteButtonName: IS_CHN ? "𝟑𝟔𝟎搜索" : "𝟑𝟔𝟎𝐬𝐨",
  1594. siteNickName: IS_CHN ? "𝟑𝟔𝟎 搜索" : "𝐰𝐰𝐰.𝐬𝐨.𝐜𝐨𝐦",
  1595. siteHostName: "www.so.com",
  1596. webURL: "https://www.so.com/s?ie=utf-8&q=",
  1597. imageURL: "https://image.so.com/i?q=",
  1598. imageType: ["i", "view"],
  1599. splitTypeName: { split: "/", index: 1 },
  1600. mainSelector: "input[type='submit'][value='搜索'],button[type='submit'][class~='so-search__button']",
  1601. buttonCssText: `#${def.const.rndButtonID}{position:relative;top:0;left:0;z-index:199999995;margin:0 0 0 5px;padding:0;width:auto;height:40px;cursor:pointer;-webkit-appearance:none}#${def.const.leftButton}{display:inline-block;padding:0 1px 0 0;height:40px;vertical-align:top}#${def.const.rightButton}{display:inline-block;height:40px;vertical-align:top}#${def.const.leftButton} input{margin:0 -2px 0 0;padding:0 18px!important;height:40px;min-width:100px;border:1px solid #0fb264;border-bottom-left-radius:8px;border-top-left-radius:8px;background:#0fb264;color:#fff;vertical-align:top;font-weight:400;font-size:16px!important;line-height:100%;cursor:pointer}#${def.const.rightButton} input{margin:0;padding:0 18px!important;height:40px;min-width:100px;border:1px solid #0fb264;border-top-right-radius:8px;border-bottom-right-radius:8px;background:#0fb264;color:#fff;vertical-align:top;font-weight:400;font-size:16px!important;line-height:100%;cursor:pointer}#${def.const.leftButton} input:hover,#${def.const.rightButton} input:hover{box-shadow: 0 1px 2px rgba(0,0,0,0.1);background:#2dc471}`,
  1602. resultListProp: { qs: `ul.result>li.res-list`, delay: 10 },
  1603. keywords: "em,#mohe-newdict_dict .mh-exsentence b",
  1604. antiRedirectFn: () =>
  1605. deBounce({ fn: parsingAntiRedirect, delay: 20, timer: "so360_ar" })(".res-list a[href*='//www.so.com/link?m=']", "So360", {
  1606. useNewTab: true,
  1607. cleanAttr: ["e_href", "data-res"],
  1608. advancedAnti: true,
  1609. }),
  1610. antiAdsFn: () =>
  1611. deBounce({ fn: parseAntiAdvertising, delay: 20, timer: "so360_ad", immed: true })({
  1612. selectors: `#so_bd-ad,#e_idea_pp,#righttop_box,[id^='mohe-360pic_ext--'],.res-mediav,.map_business_con,.lianmeng-ad,.res-mediav-right,.atom-adv,.e-buss,.spread,ul[data-so-biz-monitor-so-display],.related_query li.cm,[class='inline-recommend'][data-url],div#so_top,div#so-activity-entry,div.mh-relate-text,.section li[data-id^="related_query_init_"],#mohe-know_side_nlp`,
  1613. siteName: "So360",
  1614. isRemoveNodes: true,
  1615. }),
  1616. },
  1617. toutiao: {
  1618. siteTypeID: 9,
  1619. siteButtonName: IS_CHN ? "搜头条" : "𝐓𝐨𝐮𝐭𝐢𝐚𝐨",
  1620. siteNickName: IS_CHN ? "头条 搜索" : "𝐬𝐨.𝐭𝐨𝐮𝐭𝐢𝐚𝐨.𝐜𝐨𝐦",
  1621. siteHostName: "so.toutiao.com",
  1622. webURL: "https://so.toutiao.com/search?dvpf=pc&keyword=",
  1623. imageURL: "https://so.toutiao.com/search?dvpf=pc&pd=atlas&from=gallery&keyword=",
  1624. imageType: ["atlas"],
  1625. splitTypeName: "pd",
  1626. mainSelector: "div[class^='search'][data-log-click]",
  1627. buttonCssText: `#${def.const.rndButtonID}{position:absolute;top:0;right:-160px;z-index:1999999995;margin:-1px;padding:0;width:auto;height:44px;cursor:pointer;-webkit-appearance:none}#${def.const.leftButton}{display:inline-block;height:44px}#${def.const.rightButton}{display:inline-block;margin:0 0 0 -2px;height:44px}#${def.const.leftButton} input{margin:0;padding:1px 10px 1px 15px!important;height:44px;min-width:100px;border:1px solid transparent;border-bottom-left-radius:8px;border-top-left-radius:8px;background:#f04142;color:#fff;vertical-align:top;font-weight:500;font-size:18px;line-height:100%;cursor:pointer}#${def.const.rightButton} input{margin:0;padding:1px 15px 1px 10px!important;height:44px;min-width:100px;border:1px solid transparent;border-top-right-radius:8px;border-bottom-right-radius:8px;background:#f04142;color:#fff;vertical-align:top;font-weight:500;font-size:18px;line-height:100%;cursor:pointer}#${def.const.leftButton} input:hover,#${def.const.rightButton} input:hover{background-color:rgba(240, 65, 66, 0.7);color:#fff}`,
  1628. resultListProp: { qs: `div.s-result-list:not(.pd-video)>div.result-content[data-i]`, delay: 10 },
  1629. keywords: "em",
  1630. antiRedirectFn: () =>
  1631. deBounce({ fn: parsingAntiRedirect, delay: 20, timer: "toutiao_ar" })(".main a[href*='/search/jump?url=']", "Toutiao", { useNewTab: true, advancedAnti: true }),
  1632. antiAdsFn: null,
  1633. },
  1634. kaifa: {
  1635. siteTypeID: 10,
  1636. siteButtonName: IS_CHN ? "百度开发者" : "𝐃𝐞𝐯.𝐁𝐚𝐢𝐝𝐮",
  1637. siteNickName: IS_CHN ? "百度开发者 搜索" : "𝐃𝐞𝐯.𝐁𝐚𝐢𝐝𝐮",
  1638. siteHostName: "kaifa.baidu.com",
  1639. webURL: "https://kaifa.baidu.com/searchPage?module=SEARCH&wd=",
  1640. imageURL: "https://kaifa.baidu.com/searchPage?module=SUG&wd=",
  1641. imageType: [null],
  1642. splitTypeName: "",
  1643. mainSelector: "div#search-box-container .ant-input-group-addon",
  1644. buttonCssText: `.ant-input-group-addon{background:transparent!important}#${def.const.rndButtonID}{position:relative;z-index:1999999995;display:inline-block;margin-left:4px;height:40px;vertical-align:bottom}#${def.const.rndButtonID} #${def.const.leftButton}{display:inline-block;margin-left:2px;height:40px}#${def.const.rndButtonID} #${def.const.rightButton}{display:inline-block;margin-left:-2px;height:40px}#${def.const.leftButton} input{margin:0;padding:1px 12px 1px 18px!important;height:40px;min-width:100px;border:1px solid var(--ee-brand-6);border-bottom-left-radius:10px;border-top-left-radius:10px;background:var(--ee-brand-6);color:#fff;vertical-align:top;font-weight:500;font-size:16px!important;line-height:100%;cursor:pointer}#${def.const.rightButton} input{margin:0;padding:1px 18px 1px 12px!important;height:40px;min-width:100px;border:1px solid var(--ee-brand-6);border-top-right-radius:10px;border-bottom-right-radius:10px;background:var(--ee-brand-6);color:#fff;vertical-align:top;font-weight:500;font-size:16px!important;line-height:100%;cursor:pointer}#${def.const.leftButton} input:hover,#${def.const.rightButton} input:hover{border:1px solid var(--ee-brand-5);background:var(--ee-brand-5)}`,
  1645. resultListProp: { qs: `ul.ant-list-items>li.ant-list-item`, delay: 10 },
  1646. keywords: "mark",
  1647. antiRedirectFn: null,
  1648. antiAdsFn: () => deBounce({ fn: parseAntiAdvertising, delay: 20, timer: "kaifa_ad", immed: true })({ selectors: `#reward-entry`, siteName: "Kaifa", isRemoveNodes: true }),
  1649. },
  1650. ecosia: {
  1651. siteTypeID: 11,
  1652. siteButtonName: "𝐄𝐜𝐨𝐬𝐢𝐚",
  1653. siteNickName: IS_CHN ? "𝐄𝐜𝐨𝐬𝐢𝐚 搜索" : "𝐄𝐜𝐨𝐬𝐢𝐚.𝐨𝐫𝐠",
  1654. siteHostName: "www.ecosia.org",
  1655. webURL: "https://www.ecosia.org/search?method=index&q=",
  1656. imageURL: "https://www.ecosia.org/images?q=",
  1657. imageType: ["images"],
  1658. splitTypeName: { split: "/", index: 1 },
  1659. mainSelector: "form[role='search'][class~='search-form'][data-test-id='main-header-search-form']",
  1660. buttonCssText: `#${def.const.rndButtonID}{position:relative;z-index:1999999995;display:inline-block;margin-left:4px;height:40px}#${def.const.rndButtonID} #${def.const.leftButton}{display:inline-block;margin-left:2px;height:40px}#${def.const.rndButtonID} #${def.const.rightButton}{display:inline-block;margin-left:-2px;height:40px}#${def.const.leftButton} input{margin:0;padding:1px 12px 1px 18px!important;height:40px;min-width:100px;border:1px solid var(--color-form-border-default);border-bottom-left-radius:20px;border-top-left-radius:20px;background:var(--color-background-primary);box-shadow:0 1px 2px rgba(26,26,26,.18),0 0 8px rgba(26,26,26,.06);color:var(--color-button-content-tertiary);vertical-align:top;font-weight:700;font-size:16px!important;line-height:100%;cursor:pointer}#${def.const.rightButton} input{margin:0;padding:1px 18px 1px 12px!important;height:40px;min-width:100px;border:1px solid var(--color-form-border-default);border-top-right-radius:20px;border-bottom-right-radius:20px;background:var(--color-background-primary);box-shadow:0 1px 2px rgba(26,26,26,.18),0 0 8px rgba(26,26,26,.06);color:var(--color-button-content-tertiary);vertical-align:top;font-weight:700;font-size:16px!important;line-height:100%;cursor:pointer}#${def.const.leftButton} input:hover,#${def.const.rightButton} input:hover{border:1px solid var(--color-button-background-primary-hover);background:var(--color-button-background-primary-hover);color:var(--color-button-content-primary)}`,
  1661. resultListProp: { qs: `.mainline__content>div:not([class])>div[data-test-id="mainline-result-web"],aside>article[position="sidebar"]`, delay: 150 },
  1662. keywords: "",
  1663. antiRedirectFn: function () {
  1664. ["adBlockNoticeDismissed", "personalCounterTooltipSearch"].forEach(item => localStorages?.setItem(item, 1));
  1665. const fn = option => !/:nt=1:/.test(gbCookies.getItem("ECFG")) && gbCookies.setItem(option) && reload();
  1666. const sValue = `a=0:as=1:cs=0:dt=pc:f=i:fr=0:fs=1:l=en:lt=${Date.now()}:mc=zh-cn:nf=1:nt=1:pz=0:t=1:tt=0:tu=auto:wu=auto:ma=1`;
  1667. deBounce({ fn, timer: "ecosia_cookie", immed: true, once: true })({ sKey: "ECFG", sValue, sEnd: Infinity, sDomain: ".ecosia.org", sPath: "/", sSomeSite: "Lax" });
  1668. },
  1669. antiAdsFn: () =>
  1670. deBounce({ fn: parseAntiAdvertising, delay: 20, timer: "ecosia_ad", immed: true })({
  1671. selectors: `div[data-test-id="sidebar-onboarding"][href],div.main-header__install-cta,div.main-footer-visual__cards,div.personal-counter__tooltip,div.cookie-wrapper,div.mainline__footer>a[data-test-id='chat-entry'],[data-test-id="mainline-result-ad"]`,
  1672. siteName: "Ecosia",
  1673. }),
  1674. },
  1675. yahoo: {
  1676. siteTypeID: 12,
  1677. siteButtonName: "𝐘𝐚𝐡𝐨𝐨",
  1678. siteNickName: IS_CHN ? "𝐘𝐚𝐡𝐨𝐨 搜索" : "𝐬𝐞𝐚𝐫𝐜𝐡.𝐘𝐚𝐡𝐨𝐨",
  1679. siteHostName: "search.yahoo.com",
  1680. webURL: "https://search.yahoo.com/search?p=",
  1681. imageURL: "https://images.search.yahoo.com/search/images?p=",
  1682. imageType: ["images"],
  1683. splitTypeName: () => CUR_HOST_NAME.split(".").slice(-4, -3)[0],
  1684. mainSelector: "#hd div.sbx form#sf,header.hd section#sbx form#sf",
  1685. buttonCssText: `#${def.const.rndButtonID}{position:relative;position:absolute;z-index:1999999995;display:inline-block;margin-left:4px;width:max-content;height:44px}#${def.const.rndButtonID} *{text-shadow:none!important;-webkit-text-stroke:0 transparent!important}#${def.const.rndButtonID} #${def.const.leftButton}{display:inline-block;margin-left:2px;height:44px}#${def.const.rndButtonID} #${def.const.rightButton}{display:inline-block;margin-left:-2px;height:44px}#${def.const.leftButton} input{box-sizing:content-box;margin:0;padding:0 12px 0 18px!important;height:44px;min-width:60px;border:1px solid transparent;border-bottom-left-radius:100px;border-top-left-radius:100px;background:#7e1fff;color:#fff;vertical-align:top;font-weight:500;font-size:16px!important;line-height:100%;cursor:pointer}#${def.const.rightButton} input{box-sizing:content-box;margin:0;padding:0 18px 0 12px!important;height:44px;min-width:60px;border:1px solid transparent;border-top-right-radius:100px;border-bottom-right-radius:100px;background:#7e1fff;color:#fff;vertical-align:top;font-weight:500;font-size:16px!important;line-height:100%;cursor:pointer}#${def.const.leftButton} input:hover,#${def.const.rightButton} input:hover{border:1px solid transparent;background:#6001d2;color:#fff}`,
  1686. resultListProp: { qs: `#web>ol>li`, delay: 10 },
  1687. keywords: "strong",
  1688. antiRedirectFn: () =>
  1689. deBounce({ fn: parsingAntiRedirect, delay: 20, timer: "yahoo_ar" })(
  1690. "#main ol a[href^='https://r.search.yahoo.com/_ylt='],#main #results #sres>li>a[href^='https://r.search.yahoo.com/_ylt=']",
  1691. "Yahoo",
  1692. { useNewTab: true, advancedAnti: true }
  1693. ),
  1694. antiAdsFn: () =>
  1695. deBounce({ fn: parseAntiAdvertising, delay: 20, timer: "yahoo_ad", immed: true })({
  1696. selectors: `#main ol.searchCenterBottomAds,#main ol.searchCenterTopAds`,
  1697. siteName: "Yahoo",
  1698. }),
  1699. },
  1700. you: {
  1701. siteTypeID: 13,
  1702. siteButtonName: "𝐘𝐨𝐮 ®",
  1703. siteNickName: IS_CHN ? "𝐘𝐨𝐮 搜索" : "𝐘𝐨𝐮.𝐜𝐨𝐦",
  1704. siteHostName: "you.com",
  1705. webURL: "https://you.com/search?fromSearchBar=true&q=",
  1706. imageURL: "https://you.com/search?fromSearchBar=true&tbm=isch&q=",
  1707. imageType: ["isch"],
  1708. splitTypeName: "tbm",
  1709. mainSelector: "button[data-testid='qb_submit_button'],#ChatQueryBar ._1l6na7p6 :is(.pemrxs0,[data-state='closed'])",
  1710. buttonCssText: `#${def.const.rndButtonID}{position:relative;z-index:999;display:inline;margin:0;height:36px;width:190%;max-width:fit-content}#${def.const.rndButtonID} *{text-shadow:none!important;-webkit-text-stroke:0 transparent!important}#${def.const.rndButtonID} #${def.const.leftButton}{display:inline-block;height:36px}#${def.const.rndButtonID} #${def.const.rightButton}{display:inline-block;margin-left:-2px;height:36px}#${def.const.leftButton} input{margin:0;padding:0 10px;height:36px;min-width:80px;border:1px solid #596ced;border-bottom-left-radius:8px;border-top-left-radius:8px;background-color:#596ced;color:#fff;vertical-align:top;font-weight:400;font-size:16px!important;line-height:100%;cursor:pointer}#${def.const.rightButton} input{margin:0;padding:0 10px;height:36px;min-width:80px;border:1px solid #596ced;border-top-right-radius:8px;border-bottom-right-radius:8px;background-color:#596ced;color:#fff;vertical-align:top;font-weight:400;font-size:16px!important;line-height:100%;cursor:pointer}#${def.const.leftButton} input:hover,#${def.const.rightButton} input:hover{border:1px solid #7a89f0;background-color:#7a89f0;color:#fff}@media (prefers-color-scheme: dark){#${def.const.leftButton} input:hover,#${def.const.rightButton} input:hover{border:1px solid #4d5cc3;background-color:#4d5cc3;}}`,
  1711. resultListProp: {
  1712. qs: `[data-floating-ui-portal]>[role='dialog'][data-open='true'] section>article,div[data-eventappname="web_results"] section>article,div[data-eventappname="web_results"] ul>li`,
  1713. delay: 10,
  1714. },
  1715. keywords: `div[data-testid="app-mainline"] p strong,div[data-testid="app-mainline"] p b`,
  1716. antiRedirectFn: () =>
  1717. deBounce({ fn: parameters => parameters.forEach(item => localStorages?.setItem(item, true)), timer: "you_set", immed: true, once: true })([
  1718. "openLinksInNewTabs",
  1719. "hasSeenP13nAnnouncement",
  1720. "hasUserClosedExtensionModal",
  1721. ]),
  1722. antiAdsFn: null,
  1723. },
  1724. startpage: {
  1725. siteTypeID: 14,
  1726. siteButtonName: "𝐒𝐭𝐚𝐫𝐭𝐩𝐚𝐠𝐞",
  1727. siteNickName: IS_CHN ? "𝐒𝐭𝐚𝐫𝐭𝐩𝐚𝐠𝐞 搜索" : "𝐒𝐭𝐚𝐫𝐭𝐩𝐚𝐠𝐞.𝐜𝐨𝐦",
  1728. siteHostName: "www.startpage.com",
  1729. webURL: `https://www.startpage.com/sp/search?t=device&segment=startpage.${brand.toLowerCase()}&cat=web&query=`,
  1730. imageURL: `https://www.startpage.com/sp/search?t=device&segment=startpage.${brand.toLowerCase()}&cat=images&query=`,
  1731. imageType: ["images"],
  1732. splitTypeName: "cat",
  1733. mainSelector: "#search[role='search'] button.search-btn",
  1734. buttonCssText: `#${def.const.rndButtonID}{position:relative;z-index:999;display:inline-block;margin:-1px 5px 0 0;height:40px}#${def.const.rndButtonID} *{text-shadow:none!important;-webkit-text-stroke:0 transparent!important}#${def.const.rndButtonID} #${def.const.leftButton}{display:inline-block;height:40px}#${def.const.rndButtonID} #${def.const.rightButton}{display:inline-block;margin-left:0;height:40px}#${def.const.leftButton} input{margin:0;padding:0 10px 0 20px!important;height:40px;min-width:95px;border:0 solid transparent;border-bottom-left-radius:2rem;border-top-left-radius:2rem;background:#f1f3ff;box-shadow:0 0 2px #a4a5bb;color:#2e39b3;font-weight:600;font-size:14px!important;line-height:100%;cursor:pointer}#${def.const.rightButton} input{margin:0;padding:0 20px 0 10px!important;height:40px;min-width:95px;border:0 solid transparent;border-top-right-radius:2rem;border-bottom-right-radius:2rem;background:#f1f3ff;box-shadow:0 0 2px #a4a5bb;color:#2e39b3;font-weight:600;font-size:14px!important;line-height:100%;cursor:pointer}#${def.const.leftButton} input:hover,#${def.const.rightButton} input:hover{background:#6573ff;color:#fff}@media (prefers-color-scheme: dark){#${def.const.leftButton} input{border:1px solid #252b3b;background:#252b3b;color:#fff}#${def.const.rightButton} input{border:1px solid #252b3b;background:#252b3b;color:#fff}#${def.const.leftButton} input:hover,#${def.const.rightButton} input:hover{border:1px solid #6573ff;background:#6573ff}}`,
  1735. resultListProp: { qs: `#main>.w-gl>div.result,.wiki-container>div[role="region"]`, delay: 1e2 },
  1736. keywords: `.result b`,
  1737. antiRedirectFn: function () {
  1738. const setGBCookie = option => !/disable_open_in_new_windowEEE0|enable_post_methodEEE0/.test(gbCookies.getItem("preferences")) && gbCookies.setItem(option) && reload();
  1739. const sValue = `date_timeEEEworldN1Ndisable_family_filterEEE0N1Ndisable_open_in_new_windowEEE0N1Nenable_post_methodEEE0N1Nenable_proxy_safety_suggestEEE1N1Nenable_stay_controlEEE0N1Ninstant_answersEEE1N1Nlang_homepageEEEs/device/enN1NlanguageEEEenglishN1Nlanguage_uiEEEenglishN1Nnum_of_resultsEEE20N1Nsearch_results_regionEEEallN1NsuggestionsEEE1N1Nwt_unitEEEcelsius`;
  1740. const option = { sKey: "preferences", sValue, sEnd: Infinity, sDomain: ".startpage.com", sPath: "/", sSecure: true };
  1741. deBounce({ fn: setGBCookie, timer: "startpage_cookie", delay: 20, immed: true, once: true })(option);
  1742. },
  1743. antiAdsFn: () =>
  1744. deBounce({ fn: parseAntiAdvertising, delay: 20, timer: "startpage_ad", immed: true })({
  1745. selectors: `section.a-gl-tp,div.widget-install-legacy,div.mainline-results>div.block-display,.Firefox-promo`,
  1746. siteName: "Startpage",
  1747. }),
  1748. },
  1749. brave: {
  1750. siteTypeID: 15,
  1751. siteButtonName: "𝐁𝐫𝐚𝐯𝐞",
  1752. siteNickName: IS_CHN ? "𝐁𝐫𝐚𝐯𝐞 搜索" : "𝐬𝐞𝐚𝐫𝐜𝐡.𝐁𝐫𝐚𝐯𝐞",
  1753. siteHostName: "search.brave.com",
  1754. webURL: "https://search.brave.com/search?source=web&q=",
  1755. imageURL: "https://search.brave.com/images?source=web&spellcheck=0&q=",
  1756. imageType: ["images"],
  1757. splitTypeName: { split: "/", index: 1 },
  1758. mainSelector: ".searchform-container[data-testid='searchform-container']",
  1759. buttonCssText: `#${def.const.rndButtonID}{position:relative;z-index:999;display:inline;margin:0 0 0 10px;padding:0;width:max-content;height:var(--search-form-height)}.${def.const.scrollspan},.${def.const.scrollbars}{height:var(--search-form-height-compact)!important}.${def.const.scrollbars}{border-radius:var(--border-radius-l)!important;box-shadow:none!important}#${def.const.rndButtonID} *{text-shadow:none!important;-webkit-text-stroke:0 transparent!important}#${def.const.rndButtonID} #${def.const.rightButton},#${def.const.rndButtonID} #${def.const.leftButton}{display:inline-block;height:100%}#${def.const.leftButton} input{margin:0;padding:0 20px!important;height:var(--search-form-height);min-width:95px;border:0;outline:1px solid var(--color-serp-divider-subtle-container);box-shadow:var(--elevation-02);border-bottom-left-radius:var(--border-radius-xl);border-top-left-radius:var(--border-radius-xl);background:var(--color-serp-bar-bg);color:var(--color-text-primary);vertical-align:top;font-weight:600;font-size:16px!important;line-height:16px;box-sizing:border-box;cursor:pointer}#${def.const.rightButton} input{margin:0;padding:0 20px!important;height:var(--search-form-height);min-width:95px;border:0;outline:1px solid var(--color-serp-divider-subtle-container);box-shadow:var(--elevation-02);border-top-right-radius:var(--border-radius-xl);border-bottom-right-radius:var(--border-radius-xl);background:var(--color-serp-bar-bg);color:var(--color-text-primary);vertical-align:top;font-weight:600;font-size:16px!important;line-height:16px;box-sizing:border-box;cursor:pointer}#${def.const.leftButton} input:hover,#${def.const.rightButton} input:hover{color:var(--color-primitive-white, #fff);background:linear-gradient(314deg,#fa7250 8.49%,#ff1893 43.72%,#a78aff 99.51%);}`,
  1760. resultListProp: { qs: `#results>div.snippet[data-type],#results>.standalone>.video-item`, delay: 10 },
  1761. keywords: `.snippet-content strong`,
  1762. antiRedirectFn: function () {
  1763. localStorages?.setItem("app.aiPromoDismissCount", 10);
  1764. const option = { sKey: "olnt", sValue: "1", sEnd: Infinity, sDomain: "search.brave.com", sPath: "/", sSameSite: "Lax", sSecure: true };
  1765. deBounce({ fn: opt => gbCookies.getItem("olnt") !== "1" && gbCookies.setItem(opt) && reload(), timer: "brave_cookie", immed: true, once: true })(option);
  1766. deBounce({ fn: parsingAntiRedirect, delay: 20, timer: "brave_ar" })("#results>div#search-elsewhere a", "Brave", { useNewTab: true, forceNewTab: true, removeDataSet: true });
  1767. },
  1768. antiAdsFn: () => deBounce({ fn: parseAntiAdvertising, delay: 20, timer: "brave_ad" })({ siteName: "Brave" }),
  1769. },
  1770. yep: {
  1771. siteTypeID: 16,
  1772. siteButtonName: "𝐘𝐞𝐩 ®",
  1773. siteNickName: IS_CHN ? "𝐘𝐞𝐩 搜索" : "𝐘𝐞𝐩.𝐜𝐨𝐦",
  1774. siteHostName: "yep.com",
  1775. webURL: "https://yep.com/web?q=",
  1776. imageURL: "https://yep.com/images?q=",
  1777. imageType: ["images"],
  1778. splitTypeName: { split: "/", index: 1 },
  1779. mainSelector: `form div[class$="-addon"]`,
  1780. buttonCssText: `#${def.const.rndButtonID}{position:absolute;top:.5em;z-index:112;display:block;margin:-6px 0 0;padding:0;height:50px}#${def.const.rndButtonID} *{text-shadow:none!important;-webkit-text-stroke:0 transparent!important}#${def.const.rndButtonID} #${def.const.leftButton}{display:inline-block;height:50px}#${def.const.rndButtonID} #${def.const.rightButton}{display:inline-block;margin-left:-1px;height:50px}#${def.const.leftButton} input{margin:0;padding:4px 15px 4px 25px!important;height:50px;min-width:95px;border:1px solid #f1dc1b;border-bottom-left-radius:25px;border-top-left-radius:25px;background:var(--background--brand);color:#333;vertical-align:top;font-weight:600;font-size:16px!important;line-height:16px;cursor:pointer}#${def.const.rightButton} input{margin:0;padding:4px 25px 4px 15px!important;height:50px;min-width:95px;border:1px solid #f1dc1b;border-top-right-radius:25px;border-bottom-right-radius:25px;background:var(--background--brand);color:#333;vertical-align:top;font-weight:600;font-size:16px!important;line-height:16px;cursor:pointer}#${def.const.leftButton} input:hover,#${def.const.rightButton} input:hover{background:var(--background--brandHover)}`,
  1781. resultListProp: { qs: `div[class*='-results']>div>div>div[class*='-card'],div[class*='-sidebar']>div>div>div>div[class*='-stack']`, delay: 20 },
  1782. keywords: ``,
  1783. antiRedirectFn: () =>
  1784. deBounce({ fn: parsingAntiRedirect, delay: 30, timer: "yep_ar", immed: true })(
  1785. "div[class*='-results']>div>div>div[class*='-card'] a,div[class*='-results']>div>div>div[class*='-block'] a,div[class*='-results']>div>div>div[class*='-incut'] div[class*='-newsIncut'] a,div[class*='-results']>div>div>div[class*='-incut'] div[class*='-container'] a",
  1786. "Yep",
  1787. { useNewTab: true, forceNewTab: true, cleanAttr: ["referrerpolicy"] }
  1788. ),
  1789. antiAdsFn: null,
  1790. },
  1791. swisscows: {
  1792. siteTypeID: 17,
  1793. siteButtonName: "𝐒𝐰𝐢𝐬𝐬𝐜𝐨𝐰𝐬",
  1794. siteNickName: IS_CHN ? "𝐒𝐰𝐢𝐬𝐬𝐜𝐨𝐰𝐬 搜索" : "𝐒𝐰𝐢𝐬𝐬𝐜𝐨𝐰𝐬.𝐜𝐨𝐦",
  1795. siteHostName: "swisscows.com",
  1796. webURL: "https://swisscows.com/en/web?query=",
  1797. imageURL: "https://swisscows.com/en/images?query=",
  1798. imageType: ["images"],
  1799. splitTypeName: { split: "/", index: 2 },
  1800. mainSelector: "form>.searchbar>button.erase",
  1801. buttonCssText: `#header .form-search{max-width:35em}#${def.const.rndButtonID}{position:absolute;top:0;z-index:112;display:block;margin:0;padding:0;height:48px}#${def.const.rndButtonID} *{text-shadow:none!important;-webkit-text-stroke:0 transparent!important}#${def.const.rndButtonID} #${def.const.leftButton}{display:inline-block;height:2.5em}#${def.const.rndButtonID} #${def.const.rightButton}{display:inline-block;margin-left:-1px;height:48px}#${def.const.leftButton} input{box-sizing:content-box;margin:0;padding:0 2px 0 4px!important;height:48px;min-width:95px;border-width:0;border-bottom-left-radius:24px;border-top-left-radius:24px;background:var(--button-background);color:var(--button-text-color);vertical-align:top;font-weight:600;font-size:14px!important;line-height:100%;cursor:pointer}#${def.const.rightButton} input{box-sizing:content-box;margin:0;padding:0 4px 0 2px!important;height:48px;min-width:95px;border-width:0;border-top-right-radius:24px;border-bottom-right-radius:24px;background:var(--button-background);color:var(--button-text-color);vertical-align:top;font-weight:600;font-size:14px!important;line-height:100%;cursor:pointer}#${def.const.leftButton} input:hover,#${def.const.rightButton} input:hover{background:var(--button-focus-background);color:var(--button-text-color)}@media (prefers-color-scheme: dark){#${def.const.leftButton} input,#${def.const.rightButton} input{border:1px solid #eee;background:none;color:#eee;height:46px}#${def.const.leftButton} input:hover,#${def.const.rightButton} input:hover{background:var(--button-focus-background);color:var(--button-text-color)}}`,
  1802. resultListProp: { qs: `.web-results>article.item,.web-results>article.widget`, delay: 10 },
  1803. keywords: `.web-results b`,
  1804. antiRedirectFn: () =>
  1805. deBounce({ fn: parsingAntiRedirect, delay: 20, timer: "swisscows_ar" })(".web-results>article.item a,.web-results>div.widget a:not(.widget-button)", "Swisscows", {
  1806. useNewTab: true,
  1807. forceNewTab: true,
  1808. }),
  1809. antiAdsFn: () =>
  1810. deBounce({ fn: parseAntiAdvertising, delay: 50, timer: "swisscows_ad", immed: true })({
  1811. selectors: `header :is(.badge-tg,.badge-vpn,.badge-email,.search-counter,.badge-edelcloud),.web-results>div[class*="-privacy"],.web-results>section.widget.widget-products`,
  1812. siteName: "Swisscows",
  1813. }),
  1814. },
  1815. searxng: {
  1816. siteTypeID: 18,
  1817. siteButtonName: "𝐒𝐞𝐚𝐫𝐗𝐍𝐆",
  1818. siteNickName: IS_CHN ? "𝐒𝐞𝐚𝐫𝐗𝐍𝐆 搜索" : "𝐒𝐞𝐚𝐫𝐗𝐍𝐆 ©",
  1819. siteHostName: "searx.space",
  1820. webURL: "https://search.inetol.net/search?category_general=&language=all&time_range=&safesearch=0&theme=simple&q=",
  1821. imageURL: "https://search.inetol.net/search?category_images=&language=all&time_range=&safesearch=0&theme=simple&q=",
  1822. imageType: ["images"],
  1823. splitTypeName: () => global.location.search.match(/category_([a-z]+)/)?.[1],
  1824. mainSelector: "#search_view>div.search_box",
  1825. buttonCssText: `#${def.const.rndButtonID}{position:relative;top:0;right:-10px;width:0;z-index:199995;display:block;height:45px}#${def.const.leftButton}{display:inline-block;height:45px}#${def.const.rightButton}{display:inline-block;margin:0;height:45px}#${def.const.leftButton} input{margin:0;padding:1px 10px 1px 15px!important;height:45px;min-width:100px;border:0 solid #ccc;border-bottom-left-radius:.8rem;border-top-left-radius:.8rem;background:var(--color-search-background);box-shadow:var(--color-search-shadow);color:var(--color-search-font);vertical-align:top;font-weight:400;font-size:16px;line-height:100%;cursor:pointer}#${def.const.rightButton} input{margin:0;padding:1px 15px 1px 10px!important;height:45px;min-width:100px;border:0;border-top-right-radius:.8rem;border-bottom-right-radius:.8rem;background:var(--color-search-background);box-shadow:var(--color-search-shadow);color:var(--color-search-font);vertical-align:top;font-weight:400;font-size:16px;line-height:100%;cursor:pointer}#${def.const.rndButtonID}:hover #${def.const.leftButton} input,#${def.const.rndButtonID}:hover #${def.const.rightButton} input{background-color:var(--color-search-background);color:var(--color-search-font);}#${def.const.leftButton} input:hover,#${def.const.rightButton} input:hover{border:1px solid transparent;background-color:var(--color-search-background-hover)!important;color:var(--color-search-background)!important}`,
  1826. resultListProp: { qs: `div#urls article.result`, delay: 10 },
  1827. keywords: ".highlight",
  1828. antiRedirectFn: () => deBounce({ fn: parsingAntiRedirect, delay: 20, timer: "searxng_ar" })("div#urls article.result a", "SearXNG", { useNewTab: true }),
  1829. antiAdsFn: null,
  1830. },
  1831. other: { siteTypeID: 0 },
  1832. };
  1833.  
  1834. const newSiteType = {
  1835. BAIDU: listSite.baidu.siteTypeID,
  1836. GOOGLE: listSite.google.siteTypeID,
  1837. BING: listSite.bing.siteTypeID,
  1838. DUCKDUCKGO: listSite.duckduckgo.siteTypeID,
  1839. SOGOU: listSite.sogou.siteTypeID,
  1840. QWANT: listSite.qwant.siteTypeID,
  1841. YANDEX: listSite.yandex.siteTypeID,
  1842. SO360: listSite.so360.siteTypeID,
  1843. TOUTIAO: listSite.toutiao.siteTypeID,
  1844. KAIFA: listSite.kaifa.siteTypeID,
  1845. ECOSIA: listSite.ecosia.siteTypeID,
  1846. YAHOO: listSite.yahoo.siteTypeID,
  1847. YOU: listSite.you.siteTypeID,
  1848. STARTPAGE: listSite.startpage.siteTypeID,
  1849. BRAVE: listSite.brave.siteTypeID,
  1850. YEP: listSite.yep.siteTypeID,
  1851. SWISSCOWS: listSite.swisscows.siteTypeID,
  1852. SEARXNG: listSite.searxng.siteTypeID,
  1853. OTHERS: listSite.other.siteTypeID,
  1854. };
  1855.  
  1856. const engineMap = {
  1857. "^(w+\\.)?google\\.[a-z.]{2,6}$": { siteType: newSiteType.GOOGLE, site: listSite.google },
  1858. "kaifa\\.baidu\\.com$": { siteType: newSiteType.KAIFA, site: listSite.kaifa },
  1859. "\\.baidu\\.com$": { siteType: newSiteType.BAIDU, site: listSite.baidu },
  1860. "\\.bing\\.com$": { siteType: newSiteType.BING, site: listSite.bing },
  1861. "duckduckgo\\.com$": { siteType: newSiteType.DUCKDUCKGO, site: listSite.duckduckgo },
  1862. "\\.sogou\\.com$": { siteType: newSiteType.SOGOU, site: listSite.sogou },
  1863. "www\\.qwant\\.com$": { siteType: newSiteType.QWANT, site: listSite.qwant },
  1864. "yandex\\.(com|ru|eu)$": { siteType: newSiteType.YANDEX, site: listSite.yandex },
  1865. "\\.so\\.com$": { siteType: newSiteType.SO360, site: listSite.so360 },
  1866. "so\\.toutiao\\.com$": { siteType: newSiteType.TOUTIAO, site: listSite.toutiao },
  1867. "www\\.ecosia\\.org$": { siteType: newSiteType.ECOSIA, site: listSite.ecosia },
  1868. "search\\.yahoo\\.com$": { siteType: newSiteType.YAHOO, site: listSite.yahoo },
  1869. "you\\.com$": { siteType: newSiteType.YOU, site: listSite.you },
  1870. "startpage\\.com$": { siteType: newSiteType.STARTPAGE, site: listSite.startpage },
  1871. "search\\.brave\\.com$": { siteType: newSiteType.BRAVE, site: listSite.brave },
  1872. "yep\\.com$": { siteType: newSiteType.YEP, site: listSite.yep },
  1873. "swisscows\\.com$": { siteType: newSiteType.SWISSCOWS, site: listSite.swisscows },
  1874. "search\\.inetol\\.net$": { siteType: newSiteType.SEARXNG, site: listSite.searxng },
  1875. };
  1876.  
  1877. const searchProperties = {
  1878. inputArray: [
  1879. 'input#kw[name^="w"]',
  1880. 'input[name="q"]:not([type="hidden"])',
  1881. 'input[name="text"][type="text"]',
  1882. 'input#q[name="query"]',
  1883. 'input[name="query"][class$="query"]:not([id*="bottom"])',
  1884. 'input.input-search[type="search"]',
  1885. 'input[type="search"][class*="input"]',
  1886. '#search-box-container input[class~="ant-input"]',
  1887. 'input#yschsp[name="p"]',
  1888. 'textarea#sb_form_q[name="q"]',
  1889. 'textarea[jsaction][name="q"]',
  1890. "textarea#search-input-textarea",
  1891. ],
  1892. searchKeys: ["wd", "word", "query", "q", "text", "keyword", "p"],
  1893. };
  1894.  
  1895. const { currentSite = {}, listCurrentSite = {} } = findCurrentSite();
  1896. const { currentSiteName, allSiteURIs } = updateSiteInformation();
  1897. const { backgroundColor: bgcolor, foregroundColor: fgcolor } = customColor;
  1898. const updateDetectionAddress = getUpdateAddress();
  1899. const yandexIconsAPIUrl = `${def.url.yandexIcon}/${allSiteURIs}?size=32&stub=1`;
  1900. const iconBase64Data = await fetchAndCacheRemoteIcons(yandexIconsAPIUrl);
  1901.  
  1902. /* DEFINE_GLOBAL_STYLES */
  1903.  
  1904. def.var.style = String(
  1905. `.${def.notice.noticeX} *,.${def.notice.noticeX} *::after,.${def.notice.noticeX} *::before {box-sizing:content-box;line-height:normal}.${def.notice.animated}{animation-duration:1s;animation-fill-mode:both}@keyframes fadeIn{from{opacity:0}to{opacity:1}}.${def.notice.random}_fadeIn{animation-name:fadeIn}@keyframes fadeOut{from{opacity:1}to{opacity:0}}.${def.notice.random}_fadeOut{animation-name:fadeOut}.${def.notice.appear}{display:block!important}.${def.notice.noticeX},.${def.notice.noticeX} *{text-shadow:none!important;font-family:Microsoft YaHei UI,system-ui,-apple-system,BlinkMacSystemFont,sans-serif!important;-webkit-text-stroke:0 transparent!important}.${def.notice.noticeX}-top{top:0;width:100%}.${def.notice.noticeX}-top .${def.notice.item}{margin:0!important;border-radius:0!important}.${def.notice.noticeX}-topRight{top:10px;right:10px;z-index:2147483647!important}.${def.notice.noticeX}-topLeft{top:10px;left:10px}.${def.notice.noticeX}-topCenter{top:10px;left:50%;transform:translate(-50%)}.${def.notice.noticeX}-middleLeft,.${def.notice.noticeX}-middleRight{right:10px;top:50%;transform:translateY(-50%)}.${def.notice.noticeX}-middleLeft{left:10px}.${def.notice.noticeX}-middleCenter{top:50%;left:50%;transform:translate(-50%,-50%)}.${def.notice.noticeX}-bottom{bottom:0;width:100%}.${def.notice.noticeX}-bottom .${def.notice.item}{border-radius:0!important;margin:0!important}.${def.notice.noticeX}-bottomRight{bottom:10px;right:10px;z-index:2147483646!important}.${def.notice.noticeX}-bottomLeft{bottom:10px;left:10px}.${def.notice.noticeX}-bottomCenter{bottom:10px;left:50%;transform:translate(-50%)}.${def.notice.noticeX} .${def.notice.item}{margin:0 0 10px;border-radius:6px;overflow:hidden}.${def.var.translucent} *{display:none!important}.${def.var.translucent} notice-label{display:block!important}.${def.var.disappear}{display:none!important}[gb-filter-notice]{display:block!important;min-width:430px;margin:18px 0 28px 10px!important;padding:10px 2px!important;font:normal 400 14px/100% 'WenQuanYi Micro Hei','PingFang SC','Microsoft YaHei',sans-serif!important;-webkit-text-stroke:0 transparent!important;color:grey!important;line-height:1!important}gb-filters.code{display:block;margin:20px 0;word-break:break-word;font-size:12px!important}.${def.notice.noticeX} .${def.notice.item} .${def.notice.close}{float:right;margin-right:7px;color:#fff;text-shadow:0 1px 0 #fff;font-weight:700;font-size:18px!important;line-height:1;opacity:1}` +
  1906. `.${def.notice.noticeX} .${def.notice.item} .${def.notice.close}:hover{color:#000;opacity:.5;cursor:pointer}.${def.notice.noticeX} .${def.notice.item} a{border-bottom:1px dashed #fff;color:#fff}.${def.notice.noticeX} .${def.notice.item} a,.${def.notice.noticeX} .${def.notice.item} a:hover{text-decoration:none}.${def.notice.noticeX} .${def.notice.success}{background-color:#64ce83!important}.${def.notice.noticeX} .${def.notice.success} .${def.notice.noticeX}-heading{padding:10px;background-color:#3da95c;color:#fff;font-weight:700;font-size:14px!important}.${def.notice.noticeX} .${def.notice.success} .${def.notice.noticeX}-body{padding:10px!important;color:#fff;}.${def.notice.noticeX} .${def.notice.success} .${def.notice.noticeX}-body:hover{visibility:visible!important}.${def.notice.noticeX} .${def.notice.success} .${def.notice.noticeX}-content{visibility:visible}.${def.notice.noticeX} .${def.notice.info}{background-color:#3ea2ff!important}.${def.notice.noticeX} .${def.notice.info} .${def.notice.noticeX}-heading{padding:10px;background-color:#067cea;color:#fff;font-weight:700;font-size:14px!important}.${def.notice.noticeX} .${def.notice.info} .${def.notice.noticeX}-body{padding:10px!important;color:#fff}.${def.notice.noticeX} .${def.notice.info} .${def.notice.noticeX}-body:hover{visibility:visible!important}.${def.notice.noticeX} .${def.notice.info} .${def.notice.noticeX}-content{visibility:visible}.${def.notice.noticeX} .${def.notice.warning}{background-color:#ff7f48!important}.${def.notice.noticeX} .${def.notice.warning} .${def.notice.noticeX}-heading{padding:10px!important;background-color:#f97038;color:#fff;font-weight:700;font-size:14px!important}.${def.notice.noticeX} .${def.notice.warning} .${def.notice.noticeX}-body{color:#fff;padding:10px}.${def.notice.noticeX} .${def.notice.warning} .${def.notice.noticeX}-body:hover{visibility:visible!important}.${def.notice.noticeX} .${def.notice.warning} .${def.notice.noticeX}-content{visibility:visible}.${def.notice.noticeX} .${def.notice.error}{background-color:#e74c3c!important}.${def.notice.noticeX} .${def.notice.error} .${def.notice.noticeX}-heading{padding:10px!important;background-color:#e93724;color:#fff;font-weight:700;font-size:14px!important}.${def.notice.noticeX} .${def.notice.error} .${def.notice.noticeX}-body{padding:10px;color:#fff}.${def.notice.noticeX} .${def.notice.error} .${def.notice.noticeX}-body:hover{visibility:visible!important}` +
  1907. `.${def.notice.noticeX} .${def.notice.error} .${def.notice.noticeX}-content{visibility:visible}.${def.notice.configuration} input[disabled],.${def.notice.configuration} select[disabled]{color:#bbb;background:linear-gradient(45deg,#ffe9e9 0,#ffe9e9 25%,transparent 25%,transparent 50%,#ffe9e9 50%,#ffe9e9 75%,transparent 75%,transparent)!important;background-size:20px 20px!important;background-color:#fff7f7!important}.${def.notice.noticeX} .${def.notice.configuration}{background:linear-gradient(to right,#fcfcfc,#f2f2f7);background:-webkit-gradient(linear,0 0,0 100%,from(#fcfcfc),to(#f2f2f7));box-shadow:0 0 5px #888}.${def.notice.noticeX} .${def.notice.configuration} .${def.notice.close}{float:right;margin-right:7px;color:#000000;text-shadow:0 1px 0 #aaa;font-weight:700;font-size:18px!important;line-height:1;opacity:1}.${def.notice.noticeX} .${def.notice.configuration} .${def.notice.close}:hover{color:#555;opacity:.5;cursor:pointer}.${def.notice.noticeX} .${def.notice.configuration} .${def.notice.noticeX}-heading{padding:10px!important;background-color:#e7e7e7;color:#333;font-weight:700;font-size:14px!important}.${def.notice.noticeX} .${def.notice.configuration} .${def.notice.noticeX}-body{padding:10px;color:#333333}.${def.notice.noticeX} .${def.notice.configuration} .${def.notice.noticeX}-body:hover{visibility:visible!important}.${def.notice.noticeX} .${def.notice.configuration} .${def.notice.noticeX}-content{visibility:visible}.${def.notice.noticeX} .${def.notice.noticeX}-heading-title{display:inline-block;vertical-align:middle;overflow:hidden;max-width:90%;text-overflow:ellipsis;white-space:nowrap}.${def.notice.noticeX} .${def.notice.success} .${def.notice.noticeX}-progressbar{margin-top:-1px;width:100%;background-color:#64ce83}.${def.notice.noticeX} .${def.notice.success} .${def.notice.noticeX}-progressbar .${def.notice.noticeX}-bar{width:100%;height:5px;background:#3da95c}.${def.notice.noticeX} .${def.notice.info} .${def.notice.noticeX}-progressbar{margin-top:-1px;width:100%;background-color:#3ea2ff}.${def.notice.noticeX} .${def.notice.info} .${def.notice.noticeX}-progressbar .${def.notice.noticeX}-bar{width:100%;height:5px;background:#067cea;}.${def.notice.noticeX} .${def.notice.warning} .${def.notice.noticeX}-progressbar{margin-top:-1px;width:100%;background-color:#ff7f48}.${def.notice.noticeX} .${def.notice.warning} .${def.notice.noticeX}-progressbar .${def.notice.noticeX}-bar{width:100%;height:5px;background:#f44e06}` +
  1908. `.${def.notice.noticeX} .${def.notice.error} .${def.notice.noticeX}-progressbar{margin-top:-1px;width:100%;background-color:#fd5f4e}.${def.notice.noticeX} .${def.notice.error} .${def.notice.noticeX}-progressbar .${def.notice.noticeX}-bar{width:100%;height:5px;background:#ba2c1d}.${def.notice.noticeX} .${def.notice.configuration} .${def.notice.noticeX}-progressbar{margin-top:-1px;width:100%;background-color:#efefef}.${def.notice.noticeX} .${def.notice.configuration} .${def.notice.noticeX}-progressbar .${def.notice.noticeX}-bar{width:100%;height:5px;background:#ccc}@keyframes ${def.notice.noticeX}-progress{0%{width:100%}to{width:0}}@keyframes ${def.notice.noticeX}-fadeOut{0%{opacity:1}to{opacity:0}}.${def.notice.noticeX}-fadeOut{animation-name:${def.notice.noticeX}-fadeOut}.${def.notice.noticeX}{position:fixed;z-index:2147483645}.${def.notice.noticeX} ::-webkit-scrollbar{width:8px}.${def.notice.noticeX} ::-webkit-scrollbar-button{width:8px;height:8px}.${def.notice.noticeX} ::-webkit-scrollbar-track{border-radius:3px}.${def.notice.noticeX} ::-webkit-scrollbar-thumb{background:#e1e1e1;border-radius:3px}.${def.notice.noticeX} ::-webkit-scrollbar-thumb:hover{background:#aaa}.${def.notice.rName}{padding:2px!important}.${def.notice.noticeX} .${def.notice.rName} dl{margin:0!important;padding:1px!important}.${def.notice.noticeX} .${def.notice.rName} dl dt{margin:2px 0 6px!important;font-weight:900!important;font-size:16px!important}.${def.notice.noticeX} .${def.notice.rName} dl dd{margin:2px 2px 0 0!important;font-size:14px!important;line-height:180%!important;margin-inline-start:10px!important}.${def.notice.noticeX} .${def.notice.rName} .${def.notice.center}{width:100%;text-align:center!important}.${def.notice.noticeX} .${def.notice.rName} dl dd em{padding:0 5px;color:#fff;font-style:italic;font-size:24px!important;font-family:Candara,sans-serif!important}.${def.notice.noticeX} .${def.notice.rName} dl dd span{margin-right:8px;font-weight:700;font-size:15px!important}.${def.notice.noticeX} .${def.notice.rName} dl dd i{font-size:20px!important;font-family:Candara,sans-serif!important}.${def.notice.noticeX} .${def.notice.rName} dl dd .im{padding:0 3px;color:gold;font-weight:900;font-size:16px!important}.${def.notice.noticeX} .${def.notice.warning} .${def.notice.rName} ul{display:inline-block;margin:0 0 0 8px;padding:4px 4px 8px;width:95%;color:rgba(255, 255, 255, 0.8);counter-reset:xxx 0;vertical-align:top;text-align:left}` +
  1909. `.${def.notice.noticeX} .${def.notice.warning} .${def.notice.rName} li{position:relative;margin:0 0 0 2px;padding:0 0 2px 2px;list-style:none;font-style:italic!important;line-height:150%;-webkit-transition:.12s;transition:.12s}.${def.notice.noticeX} .${def.notice.warning} .${def.notice.rName} li::before{display:inline-block;margin-left:-1.5em;width:1.5em;content:counter(xxx,decimal) "、";counter-increment:xxx 1;font-size:14px;font-family:Candara,sans-serif;-webkit-transition:.5s;transition:.5s}.${def.notice.noticeX} .${def.notice.warning} .${def.notice.rName} #${def.notice.stopUpdate}{float:right;margin:0 5px!important;font-size:12px!important;cursor:help}.${def.const.loading}{position:relative;}.${def.const.loading}::after{content:" \u21ba";animation:fade 1.25s infinite;}@keyframes fade{0%{opacity:0.1}50%{opacity:0.5}to{opacity:0}}.${def.notice.readonly}{background:linear-gradient(45deg,#ffe9e9,#ffe9e9 25%,transparent 0,transparent 50%,#ffe9e9 0,#ffe9e9 75%,transparent 0,transparent)!important;background-color:#fff7f7!important;background-size:50px 50px!important;color:#999}#${def.notice.stopUpdate} input[type='checkbox']{box-sizing:content-box;margin:2px 4px 0 0;width:14px;height:14px;border:2px solid #fff;border-radius:50%;background:#ffa077;vertical-align:top;cursor:help;-webkit-appearance:none}#${def.notice.stopUpdate}:hover input,#${def.notice.stopUpdate} input:hover{background:#ba2c1d;}.${def.notice.noticeX} .${def.notice.configuration} .${def.notice.checkbox}{display:none!important}.${def.notice.noticeX} .${def.notice.configuration} .${def.notice.checkbox}+label{position:relative;display:inline-block;-webkit-box-sizing:content-box;box-sizing:content-box;margin:0 0 0 25px;padding:11px 9px;width:58px;height:10px;border-radius:7px;background:#f7836d;box-shadow:inset 0 0 20px rgba(0,0,0,.1),0 0 10px rgba(245, 146, 146, 0.4);word-wrap:normal!important;cursor:pointer}.${def.notice.noticeX} .${def.notice.configuration} .${def.notice.checkbox}+label::before{position:absolute;top:0;left:0;z-index:99;width:24px;height:32px;-webkit-border-radius:7px;border-radius:7px;background:#fff;box-shadow:0 0 1px rgba(0, 0, 0, 0.6);color:#fff;content:" "}.${def.notice.noticeX} .${def.notice.configuration} .${def.notice.checkbox}+label::after{position:absolute;top:2px;left:28px;-webkit-box-sizing:content-box;box-sizing:content-box;padding:5px;-webkit-border-radius:100px;border-radius:100px;color:#fff;content:"OFF";font-weight:700;font-size:14px}` +
  1910. `.${def.notice.noticeX} .${def.notice.configuration} .${def.notice.checkbox}:checked+label{-webkit-box-sizing:content-box;box-sizing:content-box;margin:0 0 0 25px;background:#67a5df!important;box-shadow:inset 0 0 20px rgba(0,0,0,.1),0 0 10px rgba(146, 196, 245, 0.4);cursor:pointer}.${def.notice.noticeX} .${def.notice.configuration} .${def.notice.checkbox}:checked+label::after{top:2px;left:10px;content:"ON"}.${def.notice.noticeX} .${def.notice.configuration} .${def.notice.checkbox}:checked+label::before{position:absolute;left:52px;z-index:99;content:" "}.${def.notice.noticeX} .${def.notice.configuration} button.${def.notice.searchButton}{display:flex;margin:0 0 10px;padding:6px 0;width:162px;height:25px;border:2px solid #eee;border-radius:6px;background:#fff;box-shadow:1px 1px 0 1px #aaa;font-size:14px!important;cursor:pointer;align-content:center;justify-content:center;align-items:center}.${def.notice.noticeX} .${def.notice.configuration} button.${def.notice.searchButton}:hover{box-shadow:1px 1px 3px 0 #888;color:#ff0000}.${def.notice.noticeX} .${def.notice.configuration} span.${def.notice.favicon}{margin:0 6px 0 0;width:32px;height:32px}.${def.notice.noticeX} .${def.notice.configuration} ul.${def.notice.searchList}{margin:5px;padding:2px;list-style:none}.${def.notice.noticeX} .${def.notice.configuration} ul.${def.notice.searchList} li{margin:0;list-style:none;font-style:normal}.${def.notice.noticeX} .${def.notice.configuration} .${def.notice.fieldset}{display:block;margin:2px;padding:4px 6px;width:auto;height:auto;border:2px dashed #dfdfdf;border-radius:10px;background:transparent!important;text-align:left}.${def.notice.noticeX} .${def.notice.configuration} .${def.notice.legend}{display:block;margin:0;padding:0 8px;width:auto;color:#8b0000!important;font-weight:900!important;font-size:14px!important;-webkit-user-select:all;user-select:all}.${def.notice.noticeX} .${def.notice.configuration} .${def.notice.settingList}{margin:0;padding:0;background:transparent!important}.${def.notice.noticeX} .${def.notice.configuration} .${def.notice.settingList} li{float:none;display:flex;margin:3px 0;padding:2px 8px 2px 12px;height:36px;border:none;background:transparent!important;list-style:none;cursor:default;-webkit-user-select:none;user-select:none;align-content:center;justify-content:space-between}` +
  1911. `.${def.notice.noticeX} .${def.notice.configuration} .${def.notice.settingList} li div{font:normal 700 14px/150% Microsoft YaHei UI,system-ui,-apple-system,BlinkMacSystemFont,sans-serif!important}.${def.notice.noticeX} .${def.notice.configuration} .${def.notice.settingList} button{box-sizing:border-box;margin:0 0 0 8px;padding:4px 8px;height:36px;min-width:65px;border:1px solid #ccc;border-radius:8px;background:#fafafa;box-shadow:1px 1px 1px 0 #ccc;color:#5e5e5e;font-weight:700;font-size:14px!important}.${def.notice.noticeX} .${def.notice.configuration} .${def.notice.settingList} .${def.notice.random}_filter_info{font-weight:400!important;}.${def.notice.noticeX} .${def.notice.configuration} .${def.notice.settingList} .${def.notice.random}_filter_info em{color:#dc143c!important;font-style:normal;}.${def.notice.noticeX} .${def.notice.configuration} .${def.notice.settingList} .${def.notice.random}_filter_textarea{padding: 6px 0;margin:0}.${def.notice.noticeX} .${def.notice.configuration} .${def.notice.settingList} .${def.notice.random}_filter{display:block;margin:0;height:100%}.${def.notice.random}_filter_textarea textarea::-webkit-scrollbar{width:8px;height:8px}.${def.notice.random}_filter_textarea textarea::-webkit-scrollbar-thumb{border-radius:4px;background:#cfcfcf}.${def.notice.random}_filter_textarea textarea::-webkit-scrollbar-thumb:hover{background:#aaa}.${def.notice.random}_filter_textarea textarea::placeholder{color:#555;font:normal 500 16px/150% ui-monospace,monospace,system-ui,-apple-system,BlinkMacSystemFont!important;opacity:0.85;white-space:break-spaces}.${def.notice.noticeX} .${def.notice.configuration} .${def.notice.settingList} .${def.notice.random}_filter_content{box-sizing:border-box;margin:0;padding:5px;max-height:423px;width:100%;min-height:280px;outline:0!important;border:1px solid #bbb;border-radius:6px;background:#fff;color:#111;white-space:pre;font:normal 400 14px/150% ui-monospace,monospace,sans-serif!important;resize:vertical;overscroll-behavior:contain;word-break:keep-all!important;cursor:auto}.${def.notice.noticeX} .${def.notice.configuration} .${def.notice.settingList} .${def.notice.random}_filter_content::placeholder{font:normal 400 14px/150% ui-monospace,monospace!important}.${def.notice.noticeX} .${def.notice.configuration} #${def.notice.random}_customColor{margin:0;cursor:pointer}.${def.notice.noticeX} .${def.notice.configuration} .${def.notice.settingList} button:hover{background:#fff;cursor:pointer}` +
  1912. `.${def.notice.noticeX} .${def.notice.configuration} .${def.notice.settingList} .${def.notice.random}__content{display:block;margin:0;height:268px}.${def.notice.noticeX} .${def.notice.configuration} .${def.notice.settingList} .${def.notice.grid}{overflow-x:hidden;overflow-y:auto;box-sizing:border-box;margin:4px 0 3px;padding:8px;width:266px;max-height:237px;overscroll-behavior:contain}.${def.notice.card} h2{margin:0;padding:0;border:0;vertical-align:baseline;font:inherit;font-size:100%;line-height:135%;}#${def.notice.random}_help{position:relative;margin:0;padding:4px 15px!important;border:1px solid transparent;background:#f07f6a;box-shadow:0 0 6px 0 #f5846f;color:#fff;cursor:help}#${def.notice.random}_help:hover{background:#ed6248;box-shadow:0 0 6px 0 #f34525;}#${def.notice.random}_clear{margin:0;color:#666;font-weight:500;cursor:pointer}#${def.notice.random}_clear:hover{color:#ff0000}#${def.notice.random}_clear u{padding:0 2px;text-decoration:none}.${def.notice.linkerror},.${def.notice.linkerror}:hover,.${def.notice.linkerror} *,.${def.notice.linkerror} *:hover{color:#a9a9a9!important;text-decoration-line:line-through!important;text-decoration-color:#ff0000!important;text-decoration-style:wavy!important}@-moz-document url-prefix() {.${def.notice.noticeX} *,.${def.notice.noticeX} *::after,.${def.notice.noticeX} *::before,.${def.notice.noticeX} .${def.notice.configuration} .${def.notice.settingList} .${def.notice.random}_filter_content{scrollbar-color:#bbbb #eee1;scrollbar-width:thin}}.${def.notice.card}{margin:0;padding:0;--background:#fff;--background-chackbox:#0082ff;--background-image:#fff,rgba(0, 107, 175, 0.2);--text-color:#666;--text-headline:#000;--card-shadow:#0082ff;--card-height:48px;--card-witght:240px;--card-radius:12px;--header-height:47px;--blend-mode:overlay;--transition:0.15s;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.${def.notice.card}__input{position:absolute;display:none;margin:0;padding:0;outline:none;border:none;background:none;-webkit-appearance:none}.${def.notice.card}__input:checked ~ .${def.notice.card}__body{--shadow:0 0 0 3px var(--card-shadow);}.${def.notice.card}__input:checked ~ .${def.notice.card}__body .${def.notice.card}__body-cover-chackbox{--chack-bg:var(--background-chackbox);--chack-border:#fff;--chack-scale:1;--chack-opacity:1;}` +
  1913. `.${def.notice.card}__input:checked ~ .${def.notice.card}__body .${def.notice.card}__body-cover-chackbox--svg{--stroke-color:#fff;--stroke-dashoffset:0;}.${def.notice.card}__input:checked ~ .${def.notice.card}__body .${def.notice.card}__body-cover:after{--opacity-bg:0;}.${def.notice.random}_iconText{color:#333}.${def.notice.random}_iconText:hover{color:#dc143c}.${def.notice.card}__input:disabled ~ .${def.notice.card}__body{cursor:not-allowed;opacity:0.5;}.${def.notice.card}__input:disabled ~ .${def.notice.card}__body:active{--scale:1;}.${def.notice.card}__body{position:relative;display:grid;overflow:hidden;width:var(--card-witght);height:var(--card-height);border-radius:var(--card-radius);background:var(--background);box-shadow:var(--shadow,1px 1px 3px 1px #ccc);cursor:pointer;-webkit-transition:box-shadow var(--transition),-webkit-transform var(--transition);transition:box-shadow var(--transition),-webkit-transform var(--transition);transition:transform var(--transition),box-shadow var(--transition);transition:transform var(--transition),box-shadow var(--transition),-webkit-transform var(--transition);-webkit-transform:scale(var(--scale,1)) translateZ(0);transform:scale(var(--scale,1)) translateZ(0);grid-auto-rows:calc(var(--card-height) - var(--header-height)) auto}.${def.notice.card}__body:active{--scale:0.96;}.${def.notice.card}__body-cover-image{position:absolute;top:8px;left:10px;z-index:100;width:32px;height:32px}.${def.notice.card}__body-cover-image span.${def.notice.favicons}{display:block;width:32px;height:32px}.${def.notice.card}__body-cover-chackbox{position:absolute;top:10px;right:10px;z-index:1;width:28px;height:28px;border:2px solid var(--chack-border,#fff);border-radius:50%;background:var(--chack-bg,var(--background-chackbox));opacity:var(--chack-opacity,0);transition:transform var(--transition),opacity calc(var(--transition)*1.2) linear,-webkit-transform var(--transition) ease;-webkit-transform:scale(var(--chack-scale,0));transform:scale(var(--chack-scale,0))}.${def.notice.card}__body-cover-chackbox--svg{display:inline-block;visibility:visible!important;margin:8px 0 0 7px;width:13px;height:11px;vertical-align:top;-webkit-transition:stroke-dashoffset .4s ease var(--transition);transition:stroke-dashoffset .4s ease var(--transition);fill:none;stroke:var(--stroke-color,#fff);stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:16px;stroke-dashoffset:var(--stroke-dashoffset,16px)}` +
  1914. `.${def.notice.card}__body-header{padding:4px 10px 6px 50px;height:var(--header-height);background:var(--background)}.${def.notice.card}__body-header-title{margin-bottom:0!important;color:var(--text-headline);font-weight:700!important;font-size:15px!important}.${def.notice.card}__body-header-subtitle{color:var(--text-color);font-weight:500;font-size:13px!important}.${def.notice.noticeX} .${def.notice.configuration} .${def.notice.settingList} .${def.notice.grid}{display:grid;grid-template-columns:repeat(1, 1fr);grid-gap:10px;}.${def.notice.gberror}{display:block;margin:0 0 4px -6px;padding:6px;width:max-content;border:1px dashed #ffb78c;border-radius:4px;color:#ffb78c}`
  1915. );
  1916. def.var.iconbg = iconBase64Data ? `url('${iconBase64Data}')` : `url('${def.url.backupIcon}'),url('${yandexIconsAPIUrl}')`;
  1917. def.var.button = `${currentSite.siteTypeID === newSiteType.GOOGLE ? "<span jsname='s1VaRe' class='ACRAdd M2vV3'></span>" : ""}
  1918. <span id="${def.const.leftButton}" sn="${selectedSite[0].siteTypeID}">
  1919. <input type="button" title="${selectedSite[0].siteNickName}" value="${selectedSite[0].siteButtonName}"/>
  1920. </span>
  1921. <span id="${def.const.rightButton}" sn="${selectedSite[1].siteTypeID}">
  1922. <input type="button" title="${selectedSite[1].siteNickName}" value="${selectedSite[1].siteButtonName}"/>
  1923. </span>`;
  1924. def.var.hlstyle = listCurrentSite.keywords ? `${listCurrentSite.keywords}{background-color:${bgcolor}!important;color:${fgcolor}!important;font-weight:600}` : ``;
  1925. def.var.iconstyle = `.${def.notice.noticeX} .${def.notice.configuration} span.${def.notice.favicon},.${def.notice.card}__body-cover-image span.${def.notice.favicons}{background-color:transparent;background-image:${def.var.iconbg};background-repeat:no-repeat;}`;
  1926.  
  1927. function getQueryString() {
  1928. if (currentSite.siteTypeID === newSiteType.YOU) {
  1929. const textWord = qS(`textarea#search-input-textarea[name='query']`)?.value.trim();
  1930. if (textWord) return encodeURIComponent(textWord);
  1931. const keyNodes = qA(`[data-testid^="youchat-question-turn"] span[class^='sc-']`);
  1932. if (keyNodes.length) return keyNodes[keyNodes.length - 1].textContent;
  1933. }
  1934. const { inputArray, searchKeys } = searchProperties;
  1935. const inputValue = qA(inputArray.join()).Find(item => item.value)?.value;
  1936. if (inputValue) {
  1937. DEBUG("QueryString[INPUT]:", { value: inputValue });
  1938. return encodeURIComponent(inputValue);
  1939. }
  1940. for (const key of searchKeys) {
  1941. const queryString = getUrlParam(key);
  1942. if (!queryString) continue;
  1943. const decodedValue = queryString.replace(/\+/g, " ");
  1944. DEBUG("QueryString[URL]:", { queryKey: key, value: decodedValue });
  1945. return encodeURIComponent(decodedValue);
  1946. }
  1947. return "";
  1948. }
  1949.  
  1950. function checkIndexPage() {
  1951. return [newSiteType.DUCKDUCKGO, newSiteType.QWANT].includes(currentSite.siteTypeID) ? !getUrlParam("q") : location.pathname === "/";
  1952. }
  1953.  
  1954. function getSecurityPolicy() {
  1955. const currentSearchType = getUrlParam(currentSite.splitTypeName);
  1956. return (
  1957. (currentSite.siteTypeID === newSiteType.GOOGLE && (/^fin|26|28$/.test(currentSearchType) || getUrlParam("csui") === "1")) ||
  1958. (currentSite.siteTypeID === newSiteType.BING && /^maps$/.test(currentSearchType)) ||
  1959. (currentSite.siteTypeID === newSiteType.SOGOU && /^(fanyi|hanyu|as)/.test(CUR_HOST_NAME)) ||
  1960. (currentSite.siteTypeID === newSiteType.DUCKDUCKGO && /^maps$/.test(getUrlParam("iaxm"))) ||
  1961. (currentSite.siteTypeID === newSiteType.YANDEX && location.pathname.includes("/direct")) ||
  1962. (currentSite.siteTypeID === newSiteType.YAHOO && CUR_HOST_NAME.search(/news|video/) !== -1) ||
  1963. (currentSite.siteTypeID === newSiteType.SEARXNG && /^map$/.test(currentSearchType))
  1964. );
  1965. }
  1966.  
  1967. function findCurrentSite() {
  1968. for (const regex in engineMap) {
  1969. if (!hasOwnProperty.call(engineMap, regex) || !new RegExp(regex).test(CUR_HOST_NAME)) continue;
  1970. const { siteType, site } = engineMap[regex];
  1971. const currentSite = selectedEngine.includes(siteType) ? site : listSite.other;
  1972. return { currentSite, listCurrentSite: site };
  1973. }
  1974. return {};
  1975. }
  1976.  
  1977. function updateSiteInformation() {
  1978. let [currentSiteName, allSiteURIs] = ["", ""];
  1979. for (let site in listSite) {
  1980. if (!hasOwnProperty.call(listSite, site)) continue;
  1981. if (listSite[site].siteTypeID !== newSiteType.OTHERS) allSiteURIs += listSite[site].siteHostName + ";";
  1982. if (listSite[site].siteTypeID === listCurrentSite.siteTypeID) currentSiteName = site;
  1983. if (listSite[site].siteTypeID !== currentSite.siteTypeID && selectedEngine.includes(Number(listSite[site].siteTypeID))) {
  1984. selectedSite.length < 2 && selectedSite.push(listSite[site]);
  1985. }
  1986. }
  1987. return { currentSiteName, allSiteURIs };
  1988. }
  1989.  
  1990. async function updateToRequestIcon(isReload = true) {
  1991. try {
  1992. const iconDataURL = await requestRemoteIcon(yandexIconsAPIUrl);
  1993. if (iconDataURL) cache.set(REMOTEICONS, iconDataURL, 2592e6) ?? DEBUG("%cRemote icon data parsed successfully.", "color:#006400");
  1994. else DEBUG("%cRemote icon data parsing failed.", "color:#ff0000");
  1995. } catch (e) {
  1996. ERROR("updateToRequestIcon: Can't fetch the iconData.", e.message);
  1997. } finally {
  1998. isReload && reload();
  1999. }
  2000. }
  2001.  
  2002. function openUpdateWindow(url) {
  2003. if (IS_REAL_GECKO || IS_REAL_WEBKIT || (IS_REAL_BLINK && GMscriptHandler === "Tampermonkey" && parseFloat(GMversion) >= 5.2)) {
  2004. def.var.updateWindow = GMopenInTab(IS_GREASEMONKEY ? url.replace(/\?\w+/g, "") : url, false);
  2005. } else global.location.href = url;
  2006. }
  2007.  
  2008. function showUpdateNotify() {
  2009. const title = IS_CHN ? "升级提示" : "Update Tips";
  2010. const loadingTip = IS_REAL_GECKO
  2011. ? `${IS_CHN ? "已经在新窗口打开脚本升级页面,请注意切换!" : "The upgrade page is opened in new window!"}`
  2012. : `${IS_CHN ? "正在申请脚本更新安装页面,请稍后……" : "Installation page is requested, please wait..."}`;
  2013. const okTip = IS_CHN ? "<dd><b>若您已更新完成</b>,请点此刷新页面,以使新版脚本生效!</dd>" : "<dd><b>If updated</b>, click here to make the script effective!</dd>";
  2014. const text = createNoticeHTML(`<dd id="${def.notice.random}_loading" style="color:#ffff00;font-weight:600">${loadingTip}</dd>${okTip}`);
  2015. GMnotification({ title, text, type: def.notice.info, closeWith: ["click"], timeout: false, position: "topRight", callbacks: { onClose: [updateToRequestIcon] } });
  2016. if (def.var.updateWindow) {
  2017. sleep(6e3, { useCachedSetTimeout: true }).then(() => {
  2018. def.var.updateWindow.onclose = () => delete def.var.updateWindow;
  2019. def.var.updateWindow.close?.();
  2020. });
  2021. }
  2022. return qS(`#${def.notice.random}_loading`);
  2023. }
  2024.  
  2025. function removeLoadingElement(node) {
  2026. sleep(4e3, { useCachedSetTimeout: true }).then(() => safeRemoveNode(node));
  2027. }
  2028.  
  2029. function preInstall(url) {
  2030. sleep(5e2)(url.replace(".meta.", ".user."))
  2031. .then(u => openUpdateWindow(u))
  2032. .then(() => showUpdateNotify())
  2033. .then(r => removeLoadingElement(r))
  2034. .catch(e => ERROR("preInstall:", e.message));
  2035. }
  2036.  
  2037. function extractVersion(res) {
  2038. return res.match(/\/\/\s+@version\s+(\S+)/)?.[1]?.trim();
  2039. }
  2040.  
  2041. function extractNotes(res) {
  2042. return res.match(/\/\/\s+@note\s+(.+)/g)?.map(item => escapeHTML(item.replace(/\/\/\s+@note\s+/, "")).trim());
  2043. }
  2044.  
  2045. function generateUpdateList(notes) {
  2046. if (!notes) return `<ol>当前更新源没有更新详情,请访问 <a target="_blank" href="${def.url.homepage}">Github</a> 查看。</ol><ol>&nbsp;</ol>`;
  2047. return notes.reduce((updateInfoList, note) => {
  2048. try {
  2049. const parsedNote = JSON.parse(note);
  2050. updateInfoList += `<li>${IS_CHN ? parsedNote.CN : parsedNote.EN}</li>`;
  2051. } catch (e) {
  2052. updateInfoList += `<li>${note}</li>`;
  2053. }
  2054. return updateInfoList;
  2055. }, "");
  2056. }
  2057.  
  2058. function generateUpdateHTML(version, updateText) {
  2059. const escapedVersion = escapeHTML(version);
  2060. return IS_CHN
  2061. ? `<dd><span>发现新版本</span><i>V${escapedVersion}</i>,点击可自动更新。</dd><dd><ul>${updateText}</ul></dd><dd id="${def.notice.stopUpdate}"><input type="checkbox">一周内不再提醒</dd>`
  2062. : `<dd><span>New Version</span><i>V${escapedVersion}</i>, Click to update.</dd><dd><ul>${updateText}</ul></dd><dd id="${def.notice.stopUpdate}"><input type="checkbox">Don't remind me for <b>7</b> days</dd>`;
  2063. }
  2064.  
  2065. function showNewUpdateNotify(version, newUpdateHTML, url) {
  2066. const [title, text, callbacks] = [IS_CHN ? "发现新更新" : "Found new update", createNoticeHTML(newUpdateHTML), { onClick: [() => preInstall(url)] }];
  2067. const updateInterface = GMnotification({ title, text, type: def.notice.warning, closeWith: ["click"], timeout: 8e3, callbacks });
  2068. qS(`#${def.notice.stopUpdate}`)?.addEventListener("click", event => {
  2069. event.stopPropagation();
  2070. NoticeX.close(updateInterface);
  2071. cache.set(AUTOCHECK, def.var.curVersion);
  2072. });
  2073. const props = ["font-weight:bold;color:#dc143c", "color:0", "color:#dc143c", "color:0"];
  2074. __console("shown_new_update", `%c[GB-Update]%c\r\nWe found a new version: %c${version}%c, which you can update now!`, ...props);
  2075. }
  2076.  
  2077. function showSuccessUpdateNotify() {
  2078. const successHTML = IS_CHN
  2079. ? `<dd style="margin: 10px 0"><span>恭喜!</span>当前版本 <i>${def.var.curVersion}</i> 已为最新!</dd>`
  2080. : `<dd style="margin: 10px 0"><span>Congratulations!</span><br/>The version <i>${def.var.curVersion}</i> is up-to-date!</dd>`;
  2081. const title = IS_CHN ? "更新成功" : "Update Success";
  2082. GMnotification({ title, text: createNoticeHTML(successHTML), timeout: 3e3, closeWith: ["click"] });
  2083. cache.set(AUTOCHECK, def.var.curVersion);
  2084. GMsetValue(VERSION, encrypt(def.var.curVersion));
  2085. const props = ["font-weight:700;color:#008b8b", "color:0", "color:#dc143c", "color:0"];
  2086. __console("shown_update_info", `%c[GB-Update]%c\r\nCurretVersion: %c${def.var.curVersion}%c is up-to-date!`, ...props);
  2087. }
  2088.  
  2089. function showUpdateError() {
  2090. const props = ["font-weight:bold;color:#dc143c", "color:#800000"];
  2091. __console("error", "%c[GB-UpdateError]%c\r\nRefused to connect to 'the UpdateList URLs', Please check your Network or local DNS!", ...props);
  2092. }
  2093.  
  2094. void (async function (getUpdateInformation, parseUpdateInformatio) {
  2095. const addAction = {
  2096. closeConfig: async () => {
  2097. const configureSelector = `.${def.notice.noticeX} .${def.notice.configuration}`;
  2098. return await NoticeX.close(qS(configureSelector));
  2099. },
  2100. listSearchEngine: currentSite => {
  2101. let returnHtml = "";
  2102. for (let site in listSite) {
  2103. if (!hasOwnProperty.call(listSite, site) || listSite[site].siteTypeID === 0 || listSite[site].siteTypeID === currentSite.siteTypeID) continue;
  2104. const iconStyle = `background-position:0 ${(1 - listSite[site].siteTypeID) * 32}px;background-attachment:local;background-size:32px auto;transform:scale(0.75);`;
  2105. const buttonTitle = selectedEngine.includes(listSite[site].siteTypeID) ? `title="${IS_CHN ? "您常用的搜索引擎" : "Commonly used search engine"}"` : ``;
  2106. returnHtml += `<li>
  2107. <button class="${def.notice.searchButton}" id="${listSite[site].siteTypeID}" ${buttonTitle}>
  2108. <span class="${def.notice.favicon} ${def.notice.random}_icon" style="${iconStyle}"></span>
  2109. <span class="${def.notice.random}_iconText">
  2110. ${listSite[site].siteNickName}<sup>${selectedEngine.includes(listSite[site].siteTypeID) ? "\u2726" : "\u0020"}</sup>
  2111. </span>
  2112. </button>
  2113. </li>`;
  2114. }
  2115. return String(`<ul class="${def.notice.searchList}">${returnHtml}</ul>`);
  2116. },
  2117. listSelectSearchEngine: () => {
  2118. let returnHtml = "";
  2119. for (let site in listSite) {
  2120. if (!hasOwnProperty.call(listSite, site) || listSite[site].siteTypeID === 0) continue;
  2121. const iconStyle = `background-position:0 ${(1 - listSite[site].siteTypeID) * 32}px;background-attachment:local;background-size:32px auto;`;
  2122. const inputStatus = selectedEngine.includes(listSite[site].siteTypeID) ? "checked" : "disabled";
  2123. returnHtml += `<label class="${def.notice.card}">
  2124. <input class="${def.notice.card}__input" type="checkbox" name="${def.notice.card}_lists" data-sn="${listSite[site].siteTypeID}" ${inputStatus}/>
  2125. <div class="${def.notice.card}__body">
  2126. <header class="${def.notice.card}__body-header">
  2127. <span class="${def.notice.card}__body-cover-chackbox">
  2128. <svg class="${def.notice.card}__body-cover-chackbox--svg" viewBox="0 0 12 10"><polyline points="1.5 6 4.5 9 10.5 1"></polyline></svg>
  2129. </span>
  2130. <span class="${def.notice.card}__body-cover-image">
  2131. <span class="${def.notice.favicons} ${def.notice.random}_icon" style="${iconStyle}"></span>
  2132. </span>
  2133. <h2 class="${def.notice.card}__body-header-title" fr-fix-stroke="true">${listSite[site].siteNickName}</h2>
  2134. <p class="${def.notice.card}__body-header-subtitle" style="margin:0;padding:0">${listSite[site].siteHostName}</p>
  2135. </header>
  2136. </div>
  2137. </label>`;
  2138. }
  2139. return returnHtml;
  2140. },
  2141. setConfigure: () => {
  2142. sleep(5e2)(addAction.closeConfig()).then(isClosed => {
  2143. if (!isClosed) return;
  2144. const configText = `<fieldset class="${def.notice.fieldset}">
  2145. <legend class="${def.notice.legend}" title="Version ${def.var.curVersion}">
  2146. ${IS_CHN ? "高级功能参数设置" : "Advanced Feature Settings"}
  2147. </legend>
  2148. <ur class="${def.notice.settingList}">
  2149. <li class="${def.notice.random}__content">
  2150. <div><span>${IS_CHN ? "请选择三个最常用的搜索引擎:" : "Choose three search engines:"}</span>
  2151. <span id="${def.notice.random}_clear">[<u>${IS_CHN ? "清除" : "Clear"}</u>]</span></div>
  2152. <div class="${def.notice.grid}">
  2153. ${addAction.listSelectSearchEngine()}
  2154. </div>
  2155. </li>
  2156. <li>
  2157. <div>${IS_CHN ? "键盘快捷键功能开关" : "Keyboard Shortcut"}</div>
  2158. <div style="margin:-2px 2px 0 10px">
  2159. <input type="checkbox" id="${def.notice.hk}" class="${def.notice.checkbox}" ${isHotkey ? "checked" : ""} />
  2160. <label for="${def.notice.hk}"></label>
  2161. </div>
  2162. </li>
  2163. <li>
  2164. <div>${IS_CHN ? "Google 国际站跳转" : "Open Google NCR"}</div>
  2165. <div style="margin:-2px 2px 0 10px">
  2166. <input type="checkbox" id="${def.notice.gj}" class="${def.notice.checkbox}" ${googleJump ? "checked" : ""} />
  2167. <label for="${def.notice.gj}"></label>
  2168. </div>
  2169. </li>
  2170. <li>
  2171. <div>${IS_CHN ? "在当前浏览器窗口跳转" : "Open in Self-window"}</div>
  2172. <div style="margin:-2px 2px 0 10px">
  2173. <input type="checkbox" id="${def.notice.lw}" class="${def.notice.checkbox}" ${localWindow ? "checked" : ""} />
  2174. <label for="${def.notice.lw}"></label>
  2175. </div>
  2176. </li>
  2177. <li>
  2178. <div style="display:flex">${IS_CHN ? "搜索关键词高亮增强" : "Keyword Enhance"}
  2179. <span title="${IS_CHN ? "自定义关键词颜色" : "Custom Keyword Color"}" id="${def.notice.random}_customColor"\
  2180. style="display:${keywordHighlight ? `inline-block` : `none`}">\ud83c\udfa8</span>
  2181. </div>
  2182. <div style="margin:-2px 2px 0 10px">
  2183. <input type="checkbox" id="${def.notice.kh}" class="${def.notice.checkbox}" ${keywordHighlight ? "checked" : ""} />
  2184. <label for="${def.notice.kh}"></label>
  2185. </div>
  2186. </li>
  2187. <li>
  2188. <div>${IS_CHN ? "去除链接重定向跳转" : "Remove Redirection"}</div>
  2189. <div style="margin:-2px 2px 0 10px">
  2190. <input type="checkbox" id="${def.notice.ar}" class="${def.notice.checkbox}" ${antiLinkRedirect ? "checked" : ""} />
  2191. <label for="${def.notice.ar}"></label>
  2192. </div>
  2193. </li>
  2194. <li>
  2195. <div title="${IS_CHN ? "实验性功能" : "Beta Version"}"><span>${IS_CHN ? "去除搜索结果广告" : "Remove Ads"}</span>
  2196. <sup style="padding:0;font-style:italic;color:#dc143c;font-size:10px">Beta!</sup></div>
  2197. <div style="margin:-2px 2px 0 10px">
  2198. <input type="checkbox" id="${def.notice.aa}" class="${def.notice.checkbox}" ${antiAds ? "checked" : ""} />
  2199. <label for="${def.notice.aa}"></label>
  2200. </div>
  2201. </li>
  2202. <li>
  2203. <div title="${IS_CHN ? "关闭更新检测或由扩展自动更新时,您需要到脚本主页查看更新内容。" : "We recommend that you turn on update detection."}">
  2204. ${IS_CHN ? "更新检测(默认:开)" : "Auto Update Detect"}</div>
  2205. <div style="margin:-2px 2px 0 10px">
  2206. <input type="checkbox" id="${def.notice.au}" class="${def.notice.checkbox}" ${isAutoUpdate ? "checked" : ""} />
  2207. <label for="${def.notice.au}"></label>
  2208. </div>
  2209. </li>
  2210. <li style="display:flex;justify-content:space-between;">
  2211. <button id="${def.notice.random}_help" title="${IS_CHN ? "单击查看脚本主页" : "View Homepage"}">
  2212. ${IS_CHN ? "脚本主页" : "Guide!"}
  2213. </button>
  2214. <div style="display:flex">
  2215. <button id="${def.notice.random}_cancel">${IS_CHN ? "取消" : "Cancel"}</button>
  2216. <button id="${def.notice.random}_submit">${IS_CHN ? "保存" : "Save"}</button>
  2217. </div>
  2218. </li>
  2219. </ul>
  2220. </fieldset>`;
  2221. const [title, text, type, scroll] = [`${def.var.scriptName} v${def.var.curVersion}`, configText, def.notice.configuration, { maxHeight: 680, showOnHover: true }];
  2222. const configInterface = GMnotification({ title, text, type, width: 326, closeWith: ["button"], scroll, progressBar: false, timeout: false, position: "topRight" });
  2223. qA(`input[name='${def.notice.card}_lists']`).forEach(node => void addCardClickEvent(node));
  2224. qS(`#${def.notice.random}_clear`)?.addEventListener("click", cleanSelectedCard);
  2225. qS(`#${def.notice.kh}`)?.addEventListener("click", showCustomColor);
  2226. qS(`#${def.notice.random}_customColor`)?.addEventListener("click", submitKeywordColor);
  2227. qS(`#${def.notice.random}_help`)?.addEventListener("click", openHomePage);
  2228. qS(`#${def.notice.random}_cancel`)?.addEventListener("click", () => void NoticeX.close(configInterface));
  2229. qS(`#${def.notice.random}_submit`)?.addEventListener("click", saveConfigureData);
  2230. });
  2231. },
  2232. listEngine: () => {
  2233. sleep(5e2)(addAction.closeConfig()).then(isClosed => {
  2234. if (!isClosed) return;
  2235. const [title, text] = [`\ud83d\udc4b ${IS_CHN ? "你想去哪里吖?" : "Where to visit?"}`, addAction.listSearchEngine(listCurrentSite)];
  2236. const [type, scroll] = [def.notice.configuration, { maxHeight: 565, showOnHover: true }];
  2237. GMnotification({ title, text, type, width: 200, closeWith: ["button"], scroll, timeout: 12e3, position: "topRight" });
  2238. qA(`.${def.notice.noticeX} .${def.notice.configuration} .${def.notice.searchButton}`).forEach(item => setupClickEventOnCard(item));
  2239. });
  2240. },
  2241. filterResult: () => {
  2242. sleep(5e2)(addAction.closeConfig()).then(async isClosed => {
  2243. if (!isClosed) return;
  2244. const _filter_Data_ = await getResultFilterData();
  2245. const { trigger: antiResultsFilter, filter: resultFilters } = _filter_Data_;
  2246. const infoText = IS_CHN
  2247. ? `设置拦截关键词以数组为标准格式,每行一组过滤关键词(注意:非正则语句须转义字符,且最末行尾无逗号),支持高级正则表达式语法,不区分大小写。<em>详细设置规则请查看『设置指引』。</em>`
  2248. : `Filter keyword settings use Array as standard format, one filter keyword per line. Supports regular expressions and is not case-sensitive. <em>See "Guide" for detailed setting rules!</em>`;
  2249. const placeholder = IS_CHN
  2250. ? `设置如下数组格式:\n[\n "任意关键词",\n "任意网址但要注意转义",\n "\\\\/\\\\/test\\\\.cn\\\\/id-\\\\d+",\n "\\\\(\\\\?\\\\=非正则须转义\\\\)",`
  2251. : `Set Array as follows: \n[\n "Any keywords",\n "Any URLs but must be escaped",\n "v\\\\.test\\\\.com\\\\/test\\\\.html",\n \\\\(\\\\?\\\\:Non-regex escaped\\\\)",`;
  2252. const placeholderText = placeholder + `\n "www\\\\.example\\\\.[a-z]{2,3}",\n "(a|b)\\\\.test\\\\.com",\n "keyword1|keyword[2345]",\n "^(?!.*B).*A.*$"\n]`;
  2253. const resultFiltersJSON = resultFilters.length ? JSON.stringify(resultFilters, null, " ") : "";
  2254. const filterHTML = `<fieldset class="${def.notice.fieldset}">
  2255. <legend class="${def.notice.legend}" title="Version ${def.var.curVersion}">
  2256. ${IS_CHN ? "搜索结果拦截关键词设置" : "Search Filter Settings"}
  2257. </legend>
  2258. <ur class="${def.notice.settingList}">
  2259. <li>
  2260. <div>${IS_CHN ? "关键词拦截开关" : "Filter Switches"}</div>
  2261. <div style="margin:-2px 2px 0 10px">
  2262. <input type="checkbox" id="${def.notice.rf}" class="${def.notice.checkbox}" ${antiResultsFilter ? "checked" : ""} />
  2263. <label for="${def.notice.rf}"></label>
  2264. </div>
  2265. </li>
  2266. <li class="${def.notice.random}_filter">
  2267. <div class="${def.notice.random}_filter_info">
  2268. ${infoText}
  2269. </div>
  2270. <div class="${def.notice.random}_filter_textarea">
  2271. <textarea class="${def.notice.random}_filter_content" placeholder='${placeholderText}'>${resultFiltersJSON}</textarea>
  2272. </div>
  2273. <div style="text-align:center;padding:0 0 6px 0">
  2274. ${IS_CHN ? "(程序仅检测搜索结果列表内的可见文字)" : "(ONLY DETECT VISIBLE TEXT IN RESULT)"}
  2275. </div>
  2276. </li>
  2277. <li style="display:flex;justify-content:space-between;">
  2278. <button id="${def.notice.random}_help" title="${IS_CHN ? "查看详细设置规则请单击设置指引!" : "See document for detailed setting rules! (Chinese)"}">
  2279. ${IS_CHN ? "设置指引" : "Guide!"}
  2280. </button>
  2281. <div style="display:flex">
  2282. <button id="${def.notice.random}_cancel">${IS_CHN ? "取消" : "Cancel"}</button>
  2283. <button id="${def.notice.random}_submit">${IS_CHN ? "保存" : "Save"}</button>
  2284. </div>
  2285. </li>
  2286. </ul>
  2287. </fieldset>`;
  2288. const [title, text, type, scroll] = [`${def.var.scriptName} v${def.var.curVersion}`, filterHTML, def.notice.configuration, { maxHeight: 680, showOnHover: true }];
  2289. const filterInterface = GMnotification({ title, text, type, width: 380, closeWith: ["button"], scroll, progressBar: false, timeout: false, position: "topRight" });
  2290. const textarea = qS(`.${def.notice.random}_filter_textarea .${def.notice.random}_filter_content`);
  2291. const tigger = qS(`#${def.notice.rf}`);
  2292. if (tigger && !tigger.checked) {
  2293. textarea.classList.add(def.notice.readonly);
  2294. textarea.setAttribute("readonly", true);
  2295. }
  2296. tigger?.addEventListener("change", changeEventOnTigger);
  2297. textarea?.addEventListener("compositionstart", () => (def.var.composing = true));
  2298. textarea?.addEventListener("compositionend", () => delete def.var.composing);
  2299. textarea?.addEventListener("input", addInputEventOnTextarea);
  2300. qS(`#${def.notice.random}_help`)?.addEventListener("click", () => void GMopenInTab(`${def.url.feedback}/288`, false));
  2301. qS(`#${def.notice.random}_cancel`)?.addEventListener("click", () => void NoticeX.close(filterInterface));
  2302. qS(`#${def.notice.random}_submit`)?.addEventListener("click", saveFilterResultData);
  2303. });
  2304. },
  2305. };
  2306.  
  2307. function changeEventOnTigger() {
  2308. const textarea = qS(`.${def.notice.random}_filter_textarea .${def.notice.random}_filter_content`);
  2309. textarea?.classList.toggle(def.notice.readonly, !this.checked);
  2310. textarea?.toggleAttribute("readonly", !this.checked);
  2311. }
  2312.  
  2313. async function saveFilterResultData() {
  2314. try {
  2315. const filterString = qS(`.${def.notice.random}_filter_textarea .${def.notice.random}_filter_content`).value.trim();
  2316. const filterTrigger = qS(`#${def.notice.rf}`).checked;
  2317. const parsedFilterString = filterString ? JSON.parse(filterString) : [];
  2318. if (!Array.isArray(parsedFilterString) || asArray(parsedFilterString).Some(item => typeof item !== "string")) throw new Error("Format Error");
  2319. const resultFilterData = { filter: [...new Set(parsedFilterString.filter(Boolean))], trigger: filterTrigger };
  2320. GMsetValue(RESULTFILTER, encrypt(JSON.stringify(resultFilterData)));
  2321. const successTitle = IS_CHN ? "保存成功!" : "Success!";
  2322. const successText = IS_CHN ? "<dd>设置参数已成功保存,页面稍后自动刷新!</dd>" : "<dd>The data is saved successfully, Page will refresh!</dd>";
  2323. if (await addAction.closeConfig()) GMnotification({ title: successTitle, text: createNoticeHTML(successText), callbacks: { onClose: [reload] } });
  2324. } catch (error) {
  2325. const errorMessage = IS_CHN ? "设置数据格式有误,请修正后重新提交。" : "The setting data format is incorrect!";
  2326. const errorText = `<dd><e style="font-size:24px;vertical-align:bottom">\ud83d\ude31\u0020</e>${errorMessage}</dd>`;
  2327. GMnotification({ text: createNoticeHTML(errorText), type: def.notice.error, closeWith: ["click"] });
  2328. }
  2329. }
  2330.  
  2331. async function addInputEventOnTextarea(event) {
  2332. const _this = this ?? event.target;
  2333. try {
  2334. if (def.var.composing) return;
  2335. const value = _this.value.trim();
  2336. if (value.length === 0) return _this.setAttribute("style", "border: 1px solid #999");
  2337. const previousCursorPosition = _this.selectionStart;
  2338. const formattedValue = JSON.stringify(JSON.parse(value), null, 2);
  2339. const newCursorPosition = previousCursorPosition + formattedValue.length - _this.value.length;
  2340. const currentScrollTop = _this.scrollTop;
  2341. _this.value = formattedValue;
  2342. _this.setAttribute("style", "border: 1px solid #999");
  2343. await sleep(10, { instant: true });
  2344. _this.scrollTop = currentScrollTop;
  2345. _this.setSelectionRange(newCursorPosition, newCursorPosition);
  2346. } catch (e) {
  2347. _this.setAttribute("style", "border: 2px solid #dc143c");
  2348. }
  2349. }
  2350.  
  2351. function setupClickEventOnCard(item) {
  2352. item?.addEventListener("click", () => {
  2353. const [itemID, queryString] = [Number(item.id), getQueryString()];
  2354. const splitTypeName = getUrlParam(listCurrentSite.splitTypeName).trim();
  2355. const isImageType = listCurrentSite.imageType.includes(splitTypeName);
  2356. for (const [type, typeID] of Object.entries(newSiteType)) {
  2357. if (typeID === itemID) {
  2358. const siteType = type.toLowerCase();
  2359. const url = isImageType ? listSite[siteType].imageURL : listSite[siteType].webURL;
  2360. const fullURL = decodeURI(url + queryString);
  2361. if (localWindow) top.location.href = fullURL;
  2362. else GMopenInTab(fullURL, false);
  2363. break;
  2364. }
  2365. }
  2366. });
  2367. }
  2368.  
  2369. function openHomePage() {
  2370. const hash = IS_CHN ? "#%E4%BC%98%E9%9B%85%E7%9A%84%E6%90%9C%E7%B4%A2%E5%BC%95%E6%93%8E%E5%8A%A9%E6%89%8B" : "index_en.html#search-engine-assistant";
  2371. GMopenInTab(`${def.url.homepage}${hash}-google--baidu-switcheruserjs`, false);
  2372. }
  2373.  
  2374. function addCardClickEvent(node) {
  2375. node.addEventListener("click", () => {
  2376. const input_checked = qA(`input[name='${def.notice.card}_lists']:checked:enabled`).length;
  2377. if (input_checked < 3) {
  2378. qA(`input[name='${def.notice.card}_lists']:disabled`).forEach(item => (item.disabled = false));
  2379. qS(`#${def.notice.random}_clear`).style.display = input_checked === 0 ? "none" : "inline";
  2380. } else {
  2381. qA(`input[name='${def.notice.card}_lists']:not(:checked)`).forEach(item => (item.disabled = true));
  2382. }
  2383. });
  2384. }
  2385.  
  2386. function submitKeywordColor() {
  2387. let inputFgColor, inputBgColor;
  2388. const colorReg =
  2389. /^#[0-9a-f]{3}$|^#[0-9a-f]{6}$|^#[0-9a-f]{8}$|^rgba\(([0-9]|([1-9][0-9])|(1[0-9][0-9])|(2([0-4][0-9]|5[0-5]))),\s*([0-9]|([1-9][0-9])|(1[0-9][0-9])|(2([0-4][0-9]|5[0-5]))),\s*([0-9]|([1-9][0-9])|(1[0-9][0-9])|(2([0-4][0-9]|5[0-5]))),\s*((?!1.[1-9])[0-1]?(\.[0-9]{1,3})?)\)$|^rgb\(((([0-9]|([1-9][0-9])|(1[0-9][0-9])|(2([0-4][0-9]|5[0-5]))),\s*([0-9]|([1-9][0-9])|(1[0-9][0-9])|(2([0-4][0-9]|5[0-5]))),\s*([0-9]|([1-9][0-9])|(1[0-9][0-9])|(2([0-4][0-9]|5[0-5]))))|(([0-9]|([1-9][0-9])|(1[0-9][0-9])|(2([0-4][0-9]|5[0-5])))\s+([0-9]|([1-9][0-9])|(1[0-9][0-9])|(2([0-4][0-9]|5[0-5])))\s+([0-9]|([1-9][0-9])|(1[0-9][0-9])|(2([0-4][0-9]|5[0-5])))(\s+\/\s+((\d+%)|1|(0\.\d+)))?))\)$|^transparent$|^currentcolor$/i;
  2390. const foregroundColorText = IS_CHN
  2391. ? `请输入关键词前景色(字体颜色),默认为“#f73131cd”,支持HEX, HEXA, RGB, RGBA, currentcolor的颜色格式。`
  2392. : `𝐏𝐥𝐞𝐚𝐬𝐞 𝐞𝐧𝐭𝐞𝐫 𝐭𝐡𝐞 𝐤𝐞𝐲𝐰𝐨𝐫𝐝 𝐟𝐨𝐫𝐞𝐠𝐫𝐨𝐮𝐧𝐝-𝐜𝐨𝐥𝐨𝐫 (𝐟𝐨𝐧𝐭 𝐜𝐨𝐥𝐨𝐫):\r\nThe default is "#f73131cd" and supports the color formats of HEX, HEXA, RGB, RGBA and currentcolor.`;
  2393. const backgroundColorText = IS_CHN
  2394. ? `请输入关键词背景色,默认为“#ffff80ad”,支持HEX, HEXA, RGB, RGBA, transparent的颜色格式。`
  2395. : `𝐏𝐥𝐞𝐚𝐬𝐞 𝐞𝐧𝐭𝐞𝐫 𝐭𝐡𝐞 𝐤𝐞𝐲𝐰𝐨𝐫𝐝 𝐛𝐚𝐜𝐤𝐠𝐫𝐨𝐮𝐧𝐝-𝐜𝐨𝐥𝐨𝐫:\r\nThe default is "#ffff80ad" and supports the color formats of HEX, HEXA, RGB, RGBA and transparent.`;
  2396. const confirmColorsText = IS_CHN ? `请确认您输入的颜色代码是否正确?` : `𝐏𝐥𝐞𝐚𝐬𝐞 𝐦𝐚𝐤𝐞 𝐬𝐮𝐫𝐞 𝐭𝐡𝐚𝐭 𝐭𝐡𝐞 𝐜𝐨𝐥𝐨𝐫 𝐜𝐨𝐝𝐞 𝐞𝐧𝐭𝐞𝐫𝐞𝐝 𝐢𝐬 𝐜𝐨𝐫𝐫𝐞𝐜𝐭?`;
  2397. const confirmfgColorText = IS_CHN ? "\r\n前景色代码:" : "\r\n𝐅𝐨𝐫𝐞𝐠𝐫𝐨𝐮𝐧𝐝-𝐂𝐨𝐥𝐨𝐫: ";
  2398. const fonfirmbgColorText = IS_CHN ? "\r\n背景色代码:" : "\r\n𝐁𝐚𝐜𝐤𝐠𝐫𝐨𝐮𝐧𝐝-𝐂𝐨𝐥𝐨𝐫: ";
  2399. const saveData = async () => {
  2400. if (!inputFgColor || !inputBgColor) return;
  2401. const customColor = { foregroundColor: inputFgColor.trim().toLowerCase(), backgroundColor: inputBgColor.trim().toLowerCase() };
  2402. _config_date_ = { ..._config_date_, keywordHighlight: true, customColor };
  2403. GMsetValue(CONFIGURE, encrypt(JSON.stringify(_config_date_)));
  2404. };
  2405. inputFgColor = prompt(foregroundColorText, customColor.foregroundColor);
  2406. if (inputFgColor === null) return;
  2407. else if (colorReg.test(inputFgColor.trim())) {
  2408. inputBgColor = prompt(backgroundColorText, customColor.backgroundColor);
  2409. if (inputBgColor === null) return;
  2410. else if (colorReg.test(inputBgColor.trim())) {
  2411. const confirmForegroundColor = /^#/gi.test(inputFgColor.trim()) ? inputFgColor.trim().toUpperCase() : inputFgColor.trim().toLowerCase();
  2412. const confirmbackgroundColor = /^#/gi.test(inputBgColor.trim()) ? inputBgColor.trim().toUpperCase() : inputBgColor.trim().toLowerCase();
  2413. const confirmText = `${confirmColorsText}${confirmfgColorText}${confirmForegroundColor}${fonfirmbgColorText}${confirmbackgroundColor}`;
  2414. if (confirm(confirmText)) {
  2415. const text = createNoticeHTML(IS_CHN ? "<dd>搜索关键词自定义颜色已保存,当前页面即将刷新!</dd>" : "<dd>Search keywords custom color has been saved!</dd>");
  2416. GMnotification({ title: IS_CHN ? "自定义颜色保存" : "Save Custom Color", text, callbacks: { onShow: [saveData], onClose: [reload] } });
  2417. }
  2418. } else alert(IS_CHN ? "背景色 格式输入错误!" : "Background-color input-format error!");
  2419. } else alert(IS_CHN ? "前景色(字体颜色) 格式输入错误!" : "Foreground-color (font-color) input-format error!");
  2420. }
  2421.  
  2422. function cleanSelectedCard() {
  2423. qA(`input[name='${def.notice.card}_lists']:checked:enabled`).forEach(node => node.click());
  2424. }
  2425.  
  2426. function showCustomColor() {
  2427. qS(`#${def.notice.random}_customColor`).style.display = this.checked ? "inline-block" : "none";
  2428. }
  2429.  
  2430. async function saveConfigureData() {
  2431. const selectEngineList = qA(`input[name='${def.notice.card}_lists']:checked`).map(item => Number(item.dataset.sn));
  2432. if (selectEngineList.length < 3) {
  2433. const noticeText = IS_CHN
  2434. ? `\u0020您需要选择「三个」搜索引擎,还少<em>${3 - selectEngineList.length}</em>个呢!`
  2435. : `\u0020Please select <b>three</b> search engines, still less<em>${3 - selectEngineList.length}</em>`;
  2436. const text = createNoticeHTML(`<dd><e style="font-size:24px;vertical-align:bottom">\ud83d\ude31</e>${noticeText}</dd>`);
  2437. return GMnotification({ text, type: def.notice.error, closeWith: ["click"] });
  2438. }
  2439. const configKeys = ["hk", "gj", "lw", "kh", "ar", "aa", "au"];
  2440. const configValues = configKeys.map(key => qS(`#${def.notice[key]}`).checked);
  2441. const [isHotkey, googleJump, localWindow, keywordHighlight, antiLinkRedirect, antiAds, isAutoUpdate] = configValues;
  2442. const _config_date_ = { isAutoUpdate, keywordHighlight, isHotkey, selectedEngine: selectEngineList, localWindow, googleJump, antiLinkRedirect, antiAds, customColor };
  2443. GMsetValue(CONFIGURE, encrypt(JSON.stringify(_config_date_)));
  2444. if (await addAction.closeConfig()) {
  2445. const text = createNoticeHTML(IS_CHN ? "<dd>设置参数已成功保存,页面稍后自动刷新!</dd>" : "<dd>The data is saved successfully, Page will refresh!</dd>");
  2446. GMnotification({ title: IS_CHN ? "保存成功!" : "Success!", text, callbacks: { onClose: [reload] } });
  2447. }
  2448. }
  2449.  
  2450. function insertMenus() {
  2451. const parameter_Set_Menu = `\ufff0\u2699\ufe0f ${IS_CHN ? "搜索引擎助手高级设置" : "Advanced Feature Settings "}${isHotkey ? "(E)" : ""}`;
  2452. GMregisterMenuCommand(parameter_Set_Menu, addAction.setConfigure) && DEBUG("%cInstalling Parameter_Set_Menu", "color:#808080");
  2453. const filter_Set_Menu = `\ufff2\ud83d\udcdb ${IS_CHN ? "搜索结果拦截词设置" : "SearchResult Filter Settings "}${isHotkey ? "(B)" : ""}`;
  2454. GMregisterMenuCommand(filter_Set_Menu, addAction.filterResult) && DEBUG("%cInstalling Filter_Set_Menu", "color:#808080");
  2455. const engine_List_Menu = `\ufff4\ud83d\udc4b ${IS_CHN ? "嗨,你想去哪里吖?" : "Hi, Where to visit? "} ${isHotkey ? "(V)" : ""}`;
  2456. GMregisterMenuCommand(engine_List_Menu, addAction.listEngine) && DEBUG("%cInstalling Engine_List_Menu", "color:#808080");
  2457. isHotkey ? insertHotkey() : DEBUG("%cNo Hotkey_Setting", "color:#a9a9a9");
  2458. }
  2459.  
  2460. function insertHotkey() {
  2461. document.addEventListener("keydown", e => {
  2462. const ekey = (e.altKey || e.code === "AltRight") && !e.ctrlKey && !e.shiftKey && !e.metaKey;
  2463. if (e.code === "KeyE" && ekey) handleClickEvent("setConfigure", 1e3, e);
  2464. else if (e.code === "KeyV" && ekey) handleClickEvent("listEngine", 1e3, e);
  2465. else if (e.code === "KeyB" && ekey) handleClickEvent("filterResult", 1e3, e);
  2466. }) || DEBUG("%cInstalling Hotkey_Setting", "color:#808080");
  2467. }
  2468.  
  2469. function handleClickEvent(name, time, event) {
  2470. stopEventPropagation(event);
  2471. const currentTime = performance.now();
  2472. currentTime - def.count.clickTimer > time && (def.count.clickTimer = currentTime) && addAction[name]();
  2473. }
  2474.  
  2475. function showSystemInfo() {
  2476. if (CUR_WINDOW_TOP && listCurrentSite.siteTypeID !== newSiteType.OTHERS) {
  2477. const isFavEngine = currentSite.siteTypeID !== newSiteType.OTHERS;
  2478. const securityPolicy = getSecurityPolicy();
  2479. const fontStyle = `text-transform:capitalize;font:italic 16px/130% Candara,'Times New Roman'`;
  2480. __console(
  2481. "shown_system_info",
  2482. `%c${def.var.scriptName}\r\n%cINTRO.URL:\u0020https://f9y4ng.likes.fans/Search-Engine-Assistant\r\n%c%s%cV%s%c%s\r\n%c%s%c%s\r\n%c%s%c%s\r\n%c%s%c%s\r\n%c%s%c%s\r\n%c%s%c%s\r\n%c%s%c%s`,
  2483. "font:normal 700 16px/150% system-ui,-apple-system,BlinkMacSystemFont,sans-serif;color:#dc143c",
  2484. "color:#777;font:italic 400 10px/180% monospace",
  2485. "font-size:12px;font-weight:700;color:#4682b4",
  2486. IS_CHN ? "脚本版本:" : "Version:\u0020",
  2487. "color:#708090;font:italic 600 14px/150% Candara,Times New Roman",
  2488. def.var.curVersion,
  2489. "color:darkred;font:italic 11px/150% Candara,'Times New Roman'",
  2490. IS_CHEAT_UA ? "\u3000(CHEAT-UA)" : "",
  2491. "font-size:12px;font-weight:700;color:#4682b4",
  2492. IS_CHN ? "当前搜索引擎:" : "CurrentEngine:\u0020",
  2493. `color:#dc143c;${fontStyle};font-weight:700`,
  2494. currentSiteName,
  2495. "font-size:12px;font-weight:700;color:#4682b4",
  2496. IS_CHN ? "常用的搜索引擎:" : "YourFavEngine:\u0020",
  2497. `color:${isFavEngine ? "#006400" : "#0000ff"};${fontStyle}`,
  2498. isFavEngine,
  2499. "font-size:12px;font-weight:700;color:#4682b4",
  2500. IS_CHN ? "移除链接重定向:" : "antiRedirectFn:\u0020",
  2501. `color:${antiLinkRedirect ? "#006400" : "#0000ff"};${fontStyle}`,
  2502. antiLinkRedirect,
  2503. "font-size:12px;font-weight:700;color:#4682b4",
  2504. IS_CHN ? "去除搜索结果广告:" : "AntiAdvertising:\u0020",
  2505. `color:${antiAds ? "#006400" : "#0000ff"};${fontStyle}`,
  2506. antiAds,
  2507. "font-size:12px;font-weight:700;color:#4682b4",
  2508. IS_CHN ? "搜索结果关键词过滤:" : "SearchResultFilter:\u0020",
  2509. `color:${antiResultsFilter ? "#006400" : "#0000ff"};${fontStyle}`,
  2510. antiResultsFilter,
  2511. "font-size:12px;font-weight:700;color:#4682b4",
  2512. IS_CHN ? "因安全策略被阻止:" : "SecurityPolicy:\u0020",
  2513. `color:${securityPolicy ? "#006400" : "#0000ff"};${fontStyle}`,
  2514. securityPolicy
  2515. );
  2516. }
  2517. }
  2518.  
  2519. /* SEARCH_ENGINE_ASSISTANT_COMMAND_FUNCTIONS */
  2520.  
  2521. const siteConfigMap = {
  2522. baidu: {
  2523. listTypes: { target: "#content_left", listName: "div", className: "result-op" },
  2524. clear: () => safeRemoveNode("#con-ar"),
  2525. applyButton: ({ buttonSection, buttonID, target }) => {
  2526. insertAfter(buttonSection, target);
  2527. const width = buttonSection.getBoundingClientRect().width || 2e2;
  2528. switch (getUrlParam(currentSite.splitTypeName)) {
  2529. case currentSite.imageType[0]:
  2530. buttonSection.style.right = `-${width + 8}px`;
  2531. break;
  2532. case currentSite.imageType[1]:
  2533. buttonSection.style.cssText += "height:34px;position:relative;left:10px";
  2534. qA(`${buttonID} input`).forEach(node => {
  2535. node.style.cssText = "min-width:100px;height:34px;padding:0 5px!important;color:#fff;background:#3388ff;border-radius:0;border:1px solid #2d78f4";
  2536. });
  2537. break;
  2538. case "news":
  2539. case "vsearch":
  2540. buttonSection.style.right = `-${width + 8}px`;
  2541. qS(`#${def.const.rightButton} input`).style.marginLeft = "3px";
  2542. break;
  2543. default:
  2544. buttonSection.style.right = `-${width + 8}px`;
  2545. break;
  2546. }
  2547. },
  2548. },
  2549. bing: {
  2550. listTypes: { target: "#b_results", listName: "li", className: "b_algo" },
  2551. clear: () => safeRemoveNode("aside>ol#b_context"),
  2552. applyButton: ({ buttonSection, target }) => {
  2553. insertAfter(buttonSection, target);
  2554. const formBox = qS(".b_searchboxForm");
  2555. if (formBox && getUrlParam("view") === "detailV2") {
  2556. formBox.style.cssText += "width:max-content!important;z-index:1000;position:relative;";
  2557. qA(`#${def.const.rndButtonID} input`).forEach(input => {
  2558. input.style.cssText += "height:34px!important;border-radius:6px!important;padding:0 12px!important;margin:0 0 0 2px!important;";
  2559. });
  2560. }
  2561. },
  2562. },
  2563. google: {
  2564. listTypes: { target: "div.MjjYud", listName: "div" },
  2565. applyButton: ({ buttonSection, target }) => {
  2566. getGlobalGoogle("www.google.com", googleJump);
  2567. insertAfter(buttonSection, target);
  2568. },
  2569. },
  2570. duckduckgo: {
  2571. listTypes: { target: "ol.react-results--main", listName: "li" },
  2572. applyButton: ({ buttonSection, target }) => {
  2573. target.parentNode.appendChild(buttonSection);
  2574. sleep(0)(buttonSection.getBoundingClientRect().width || 2e2).then(sectionWidth => (buttonSection.style.right = `-${sectionWidth + 8}px`));
  2575. },
  2576. },
  2577. yandex: {
  2578. listTypes: { target: "#search-result", listName: "li" },
  2579. clear: () => safeRemoveNode("div.content__right>div"),
  2580. applyButton: ({ buttonSection, target }) => {
  2581. insertAfter(buttonSection, target);
  2582. sleep(0)(buttonSection.getBoundingClientRect().width || 2e2).then(sectionWidth => {
  2583. buttonSection.style.width = `${sectionWidth + 12}px`;
  2584. });
  2585. },
  2586. },
  2587. qwant: {
  2588. listTypes: { target: "div[data-testid='containerWeb'] div[data-testid='sectionWeb']>div", listName: "div" },
  2589. applyButton: ({ buttonSection, target }) => {
  2590. target.parentNode.appendChild(buttonSection);
  2591. sleep(0)(buttonSection.getBoundingClientRect().width || 2e2).then(sectionWidth => {
  2592. const llmButtonWidth = qS(`div[data-testid="llm-button-force"][class]`)?.getBoundingClientRect().width || 0;
  2593. buttonSection.style.right = `-${sectionWidth + 10 + llmButtonWidth}px`;
  2594. });
  2595. },
  2596. },
  2597. sogou: {
  2598. listTypes: { target: "div.results", listName: "div", className: "vrwrap" },
  2599. clear: () => safeRemoveNode("#right"),
  2600. applyButton: ({ buttonSection, buttonID, target }) => {
  2601. const currentSearchType = getUrlParam(currentSite.splitTypeName);
  2602. if (currentSite.imageType.includes(currentSearchType)) {
  2603. sleep(4e2).then(() => {
  2604. if (!qS(buttonID) && target) {
  2605. insertAfter(buttonSection, target);
  2606. const sectionWidth = buttonSection.getBoundingClientRect().width;
  2607. buttonSection.style.right = `-${sectionWidth + 10}px`;
  2608. qA(`${buttonID} input`).forEach(node => node.classList.add(`${def.notice.random}_images`));
  2609. addSearchButtonEvent(qA(`${buttonID} span[sn]:not([event-insert])`));
  2610. }
  2611. });
  2612. } else if (currentSearchType === "weixin") {
  2613. insertAfter(buttonSection, target);
  2614. buttonSection.style = "position:relative";
  2615. qA(`${buttonID} input`).forEach(node => node.classList.add(`${def.notice.random}_weixin`));
  2616. } else {
  2617. insertAfter(buttonSection, target);
  2618. safeRemoveNode(qS(`#searchBtn2[value="\u5168\u7f51\u641c\u7d22"]`));
  2619. sleep(0).then(() => {
  2620. const sectionWidth = buttonSection.getBoundingClientRect().width || 2e2;
  2621. buttonSection.style.right = `-${sectionWidth + 10}px`;
  2622. const btn2 = qS(`#searchBtn2`);
  2623. if (btn2) btn2.style.right = `-${sectionWidth + 120}px`;
  2624. });
  2625. }
  2626. },
  2627. },
  2628. toutiao: {
  2629. listTypes: { target: "div.s-result-list", listName: "div", className: "result-content" },
  2630. clear: () => safeRemoveNode(".main>.s-side-list>.result-content"),
  2631. applyButton: ({ buttonSection, target }) => {
  2632. insertAfter(buttonSection, target);
  2633. sleep(0)(buttonSection.getBoundingClientRect().width || 2e2).then(sectionWidth => (buttonSection.style.right = `-${sectionWidth + 10}px`));
  2634. },
  2635. },
  2636. so360: {
  2637. listTypes: { target: "#main>ul.result", listName: "li", className: "res-list" },
  2638. clear: () => safeRemoveNode("#side_wrap"),
  2639. applyButton: ({ buttonSection, buttonID, target }) => {
  2640. insertAfter(buttonSection, target);
  2641. if (currentSite.imageType.includes(getUrlParam(currentSite.splitTypeName))) {
  2642. qA(`${buttonID} input`).forEach(node => (node.style = "margin:0 0 0 1px;"));
  2643. sleep(5e2).then(() => qS("#tools_close")?.click());
  2644. }
  2645. },
  2646. },
  2647. kaifa: {
  2648. listTypes: { target: "ul.ant-list-items", listName: "li", className: "ant-list-item" },
  2649. applyButton: ({ buttonSection, target }) => {
  2650. target.appendChild(buttonSection);
  2651. const input = qS("#search-box-container input[class~='ant-input']");
  2652. if (input) input.style.cssText += `width:580px!important`;
  2653. },
  2654. },
  2655. ecosia: {
  2656. listTypes: { target: ".mainline__content>div:not([class])", listName: "div" },
  2657. clear: () => safeRemoveNode("aside>div[data-test-id='sidebar-web-related-queries']"),
  2658. applyButton: ({ buttonSection, buttonID, target }) => {
  2659. if (IS_GREASEMONKEY) insertAfter(buttonSection, target);
  2660. else {
  2661. sleep(5e2).then(() => {
  2662. if (qS(buttonID) || !target) return;
  2663. insertAfter(buttonSection, target);
  2664. addSearchButtonEvent(qA(`${buttonID} span[sn]:not([event-insert])`));
  2665. });
  2666. }
  2667. },
  2668. },
  2669. yahoo: {
  2670. listTypes: { target: "#web>ol", listName: "li" },
  2671. clear: () => safeRemoveNode("#right>ol"),
  2672. applyButton: ({ buttonSection, target }) => {
  2673. try {
  2674. if (currentSite.imageType.includes(getUrlParam(currentSite.splitTypeName))) target.appendChild(buttonSection);
  2675. else {
  2676. insertAfter(buttonSection, target);
  2677. const sectionWidth = buttonSection.getBoundingClientRect().width ?? 224;
  2678. buttonSection.style.cssText = `position:absolute;top:0;right:-${10 + sectionWidth}px`;
  2679. }
  2680. } catch (e) {
  2681. ERROR("insertButtons.YAHOO:", e.message);
  2682. }
  2683. },
  2684. },
  2685. startpage: {
  2686. listTypes: { target: "#main>div.w-gl", listName: "div", className: "result" },
  2687. applyButton: ({ buttonSection, target }) => {
  2688. insertAfter(buttonSection, target);
  2689. const sectionWidth = buttonSection.getBoundingClientRect().width || 2e2;
  2690. const formSection = qS(`#header-search-form>.search-form-relative-container`);
  2691. formSection.style.cssText = `max-width:${parseFloat(gCS(formSection).getPropertyValue("max-width")) + sectionWidth}px`;
  2692. },
  2693. },
  2694. you: { listTypes: { target: "[data-floating-ui-portal]>[role='dialog'][data-open='true'] div>section", listName: "article" } },
  2695. brave: { listTypes: { target: "#results", listName: "div", className: "snippet" }, clear: () => safeRemoveNode("aside>div") },
  2696. yep: {
  2697. listTypes: { target: "div[class$='-results']>div>div", listName: "div" },
  2698. applyButton: ({ buttonSection, target }) => {
  2699. insertAfter(buttonSection, target);
  2700. const sectionWidth = buttonSection.getBoundingClientRect().width || 2e2;
  2701. buttonSection.style.right = `-${10 + sectionWidth}px`;
  2702. },
  2703. },
  2704. swisscows: {
  2705. listTypes: { target: ".web-results", listName: "article", className: "item-web" },
  2706. applyButton: ({ buttonSection, target }) => {
  2707. insertAfter(buttonSection, target);
  2708. sleep(0)
  2709. .then(() => buttonSection.getBoundingClientRect().width || 2e2)
  2710. .then(sectionWidth => (buttonSection.style.right = `-${10 + sectionWidth}px`));
  2711. },
  2712. },
  2713. searxng: {
  2714. listTypes: { target: "div#urls", listName: "article", className: "result" },
  2715. clear: () => safeRemoveNode("#infoboxes"),
  2716. applyButton: ({ buttonSection, target }) => void target.appendChild(buttonSection),
  2717. },
  2718. };
  2719.  
  2720. function insertCSS(isOverwrite = false) {
  2721. try {
  2722. const buttonCss = currentSite.buttonCssText ? `@charset "UTF-8";` + currentSite.buttonCssText : "";
  2723. addStyle({ target: document.head, styleId: def.const.rndclassName, media: "all", styleContent: buttonCss, isOverwrite });
  2724. } catch (e) {
  2725. ERROR("insertCSS:", e.message);
  2726. }
  2727. }
  2728.  
  2729. function insertStyle() {
  2730. try {
  2731. const noticeStyle = `@charset "UTF-8";` + def.var.style + def.var.iconstyle + String(keywordHighlight ? def.var.hlstyle : "");
  2732. addStyle({ target: document.head, styleId: def.const.rndstyleName, media: "screen", styleContent: noticeStyle, isOverwrite: false });
  2733. } catch (e) {
  2734. ERROR("insertStyle:", e.message);
  2735. }
  2736. }
  2737.  
  2738. async function insertButtons() {
  2739. try {
  2740. const target = qS(currentSite.mainSelector);
  2741. if (checkIndexPage() || !getQueryString() || !target || qS(`#${def.const.rndButtonID}`)) return;
  2742. const buttonSection = cE("gb-button", { id: def.const.rndButtonID, innerHTML: tTP.createHTML(def.var.button) });
  2743. const spans = await applyButtons(buttonSection, target);
  2744. if (!spans) return;
  2745. addSearchButtonEvent(spans);
  2746. scrollDetect();
  2747. } catch (e) {
  2748. ERROR("insertButtons:", e.message);
  2749. }
  2750. }
  2751.  
  2752. async function applyButtons(buttonSection, target) {
  2753. if (currentSite.siteTypeID === newSiteType.OTHERS) return null;
  2754. const [buttonID, applyButtonMethod] = [`#${buttonSection.id}`, siteConfigMap[currentSiteName]?.applyButton];
  2755. if (typeof applyButtonMethod === "function") await applyButtonMethod({ buttonSection, buttonID, target });
  2756. else insertAfter(buttonSection, target);
  2757. return qA(`${buttonID} span[sn]:not([event-insert])`);
  2758. }
  2759.  
  2760. function setupScrollButton(selector, className, scrollOffset) {
  2761. const element = qS(selector);
  2762. if (!element) return;
  2763. const offsetTop = element.getBoundingClientRect().top;
  2764. const toggleClass = () => {
  2765. const scrollTop = global.scrollY || document.documentElement?.scrollTop || 0;
  2766. element.classList.toggle(className, scrollTop > offsetTop + scrollOffset);
  2767. };
  2768. toggleClass();
  2769. document.addEventListener("scroll", toggleClass);
  2770. }
  2771.  
  2772. function scrollDetect() {
  2773. if (checkIndexPage()) return;
  2774. let scrollspan, scrollbars, height, searchType;
  2775. const currentSearchType = getUrlParam(currentSite.splitTypeName);
  2776. switch (currentSite.siteTypeID) {
  2777. case newSiteType.GOOGLE:
  2778. searchType = /^isch|2$/.test(currentSearchType);
  2779. scrollspan = def.const.scrollspan;
  2780. scrollbars = def.const.scrollbars;
  2781. height = searchType ? 100 : 80;
  2782. break;
  2783. case newSiteType.BING:
  2784. searchType = /^(images|videos)$/.test(currentSearchType);
  2785. scrollspan = searchType ? def.const.scrollspan2 : def.const.scrollspan;
  2786. scrollbars = searchType ? def.const.scrollbars2 : def.const.scrollbars;
  2787. height = 50;
  2788. break;
  2789. case newSiteType.BRAVE:
  2790. scrollspan = def.const.scrollspan;
  2791. scrollbars = def.const.scrollbars;
  2792. height = 80;
  2793. break;
  2794. default:
  2795. return;
  2796. }
  2797. setupScrollButton(`#${def.const.rndButtonID}`, scrollspan, height);
  2798. setupScrollButton(`#${def.const.rndButtonID} #${def.const.leftButton} input`, scrollbars, height);
  2799. setupScrollButton(`#${def.const.rndButtonID} #${def.const.rightButton} input`, scrollbars, height);
  2800. }
  2801.  
  2802. function addSearchButtonEvent(nodes) {
  2803. if (!Array.isArray(nodes) || nodes.length === 0) return;
  2804. nodes.forEach(node => {
  2805. node.setAttribute("event-insert", true);
  2806. const inputElement = qS("input", node);
  2807. const siteTypeID = Number(node.getAttribute("sn"));
  2808. inputElement.addEventListener("click", () => {
  2809. const imageSearch = getUrlParam(currentSite.splitTypeName)?.trim();
  2810. let selectedSiteData;
  2811. if (siteTypeID === selectedSite[0].siteTypeID) selectedSiteData = selectedSite[0];
  2812. else if (siteTypeID === selectedSite[1].siteTypeID) selectedSiteData = selectedSite[1];
  2813. else return;
  2814. const isImageSearch = currentSite.imageType.includes(imageSearch);
  2815. const gotoUrl = isImageSearch ? selectedSiteData.imageURL : selectedSiteData.webURL;
  2816. const finalUrl = decodeURI(gotoUrl + getQueryString());
  2817. if (localWindow) top.location.href = finalUrl;
  2818. else GMopenInTab(finalUrl, false);
  2819. });
  2820. });
  2821. }
  2822.  
  2823. function createNotice(listName, className, userdFilter) {
  2824. const listAttrib = className ? ` class="${className}"` : ``;
  2825. const noticeText = IS_CHN ? "本页所有搜索结果均被屏蔽,如异常请检查过滤词。" : "All results are blocked, Check the filters if abnormal.";
  2826. const filterArray = userdFilter ? `<gb-filters class="code">${IS_CHN ? "过滤词:" : "Filter:"} [${userdFilter}]</gb-filters>` : ``;
  2827. const tips = `<br/>✄┏━┓╋┏┓╋╋╋┏━━━┓╋╋╋╋╋╋╋╋┏┓┏┓╋┏┓<br/>✄┃┃┗┓┃┃╋╋╋┃┏━┓┃╋╋╋╋╋╋╋╋┃┣┛┗┓┃┃<br/>✄┃┏┓┗┛┣━━┓┃┗━┛┣━━┳━━┳┓┏┫┣┓┏┛┃┃<br/>✄┃┃┗┓┃┃┏┓┃┃┏┓┏┫┃━┫━━┫┃┃┃┃┃┃╋┗┛<br/>✄┃┃╋┃┃┃┗┛┃┃┃┃┗┫┃━╋━━┃┗┛┃┗┫┗┓┏┓<br/>✄┗┛╋┗━┻━━┛┗┛┗━┻━━┻━━┻━━┻━┻━┛┗┛<br/><br/>`;
  2828. const noticeCode = tTP.createHTML(`<${listName}${listAttrib} gb-filter-notice>${tips}${noticeText} ${def.var.scriptName}${filterArray}</${listName}>`);
  2829. return noticeCode;
  2830. }
  2831.  
  2832. function showEmptyNotice(siteName) {
  2833. const siteConfig = siteConfigMap[siteName];
  2834. if (!siteConfig) return;
  2835. const { target, listName, className } = siteConfig.listTypes;
  2836. const noticeNode = qS(`${target} [gb-filter-notice]`);
  2837. if (noticeNode) return;
  2838. const usedFilterWordsStr = escapeHTML([...usedFilterWords].join(", "));
  2839. const noticeCode = createNotice(listName, className, usedFilterWordsStr);
  2840. const el = qS(target)?.firstElementChild;
  2841. if (el) {
  2842. const position = el.classList.contains(def.var.translucent) || el.classList.contains(def.var.disappear) ? "beforebegin" : "afterend";
  2843. el.insertAdjacentHTML(position, noticeCode);
  2844. }
  2845. usedFilterWords.clear();
  2846. }
  2847.  
  2848. function filterSearchResults(filterObj) {
  2849. if (resultFilters.length === 0) return;
  2850. const { qs, delay } = filterObj ?? {};
  2851. deBounce({ fn: filterSearchResultsProcess, timer: "filterSearchResults", delay: delay || 50 })(qs);
  2852. }
  2853.  
  2854. async function filterSearchResultsProcess(querystring) {
  2855. if (!querystring) return;
  2856. const selectors = buildSelectors(querystring);
  2857. const elements = qA(selectors);
  2858. if (elements.length === 0) return;
  2859. const returnContent = new Map();
  2860. elements.forEach(item => processNode(item, returnContent));
  2861. if (returnContent.size === 0) return;
  2862. returnContent.forEach((content, item) => matchFilters(item, content));
  2863. await sleep(1e2, { instant: true });
  2864. if (usedFilterWords.size > 0 && qA(querystring.split(/,(?![^()]*\))/g)[0]).length >= 2) {
  2865. const remainingResults = qA(selectors.split(/,(?![^()]*\))/g)[0]).length;
  2866. handleRemainingResults(remainingResults);
  2867. }
  2868. }
  2869.  
  2870. function processMatchedItem(item, content, filter) {
  2871. if (IS_DEBUG) addDebugNotice(item, filter);
  2872. usedFilterWords.add(filter);
  2873. item.classList.add(IS_DEBUG ? def.var.translucent : def.var.disappear);
  2874. DEBUG("Filter.match:", { filter, item, content });
  2875. qA("a", item).forEach(node => node.setAttribute("gd-antiredirect-status", "blocked"));
  2876. }
  2877.  
  2878. function addDebugNotice(item, filter) {
  2879. if (qS("notice-label", item)) return;
  2880. const notice = cE("notice-label", { class: "code", textContent: `<![CDATA[ "${filter}" ]]>` });
  2881. item.prepend(notice);
  2882. }
  2883.  
  2884. function adjustUI(siteName) {
  2885. const logicFunction = siteConfigMap[siteName]?.clear;
  2886. if (typeof logicFunction === "function") logicFunction();
  2887. }
  2888.  
  2889. function buildSelectors(querystring) {
  2890. return querystring
  2891. .split(/,(?![^()]*\))/g)
  2892. .map(item => `${item}:not(.${def.var.disappear},.${def.var.translucent},[gb-filter-notice])`)
  2893. .join(",");
  2894. }
  2895.  
  2896. function processNode(item, returnContent) {
  2897. if (item.nodeType !== Node.ELEMENT_NODE) return;
  2898. const href = qS("a:not([data-testid='result-extras-site-search-link']):not([aria-label^='Anonymous']):not([href*='.bing.com/ck/a?'])", item)?.href ?? "";
  2899. const url = [1, 5, 8].includes(listCurrentSite.siteTypeID) ? "" : getDecodeURI(href);
  2900. const content = item.innerText?.replace(/[\t\r\n\ue62b]/g, "").trim() + url;
  2901. if (content) returnContent.set(item, content);
  2902. }
  2903.  
  2904. function matchFilters(item, content) {
  2905. if (item?.nodeType !== Node.ELEMENT_NODE) return;
  2906. try {
  2907. resultFilters.forEach(filter => new RegExp(filter, "i").test(content) && processMatchedItem(item, content, filter));
  2908. } catch (e) {
  2909. ERROR("Filter.match:", e.message);
  2910. }
  2911. }
  2912.  
  2913. function handleRemainingResults(remainingResults) {
  2914. if (remainingResults > 2) return;
  2915. if (remainingResults === 0) showEmptyNotice(currentSiteName);
  2916. else qS(`[gb-filter-notice]`)?.remove();
  2917. adjustUI(currentSiteName);
  2918. }
  2919.  
  2920. function getDecodeURI(href) {
  2921. if (typeof href !== "string" || href.startsWith("javascript:")) return "";
  2922. return `\ue620${decodeURIComponent(href)}\ue620`;
  2923. }
  2924.  
  2925. function getGlobalGoogle(NCRHost, permission) {
  2926. if (!permission || CUR_HOST_NAME === NCRHost) return;
  2927. try {
  2928. const url = `${CUR_PROTOCOL}//${NCRHost}/ncr?prev=${CUR_PATH_NAME}${encodeURIComponent(location.search)}`;
  2929. const text = createNoticeHTML(`<dd class="${def.notice.center}">${IS_CHN ? "即将跳转至 Google.com (NCR)" : "Jump to Google.com (NCR)"}</dd>`);
  2930. GMnotification({ title: "Google NCR", text, type: def.notice.info, callbacks: { beforeClose: [() => top.location.replace(url)] } });
  2931. } catch (e) {
  2932. ERROR("getGlobalGoogle:", e.message);
  2933. }
  2934. }
  2935.  
  2936. function updateIconsForExtension(requestVer) {
  2937. if (decrypt(requestVer) === def.var.curVersion) return;
  2938. DEBUG("%cRequest icon data for extension update...", "color:#25f") ?? updateToRequestIcon(false);
  2939. cache.set(AUTOCHECK, def.var.curVersion);
  2940. GMsetValue(VERSION, encrypt(def.var.curVersion));
  2941. }
  2942.  
  2943. function processMainThreadTasks() {
  2944. const { siteTypeID } = currentSite;
  2945. if (siteTypeID !== newSiteType.OTHERS && !getSecurityPolicy()) {
  2946. if (!qS(`#${def.const.rndclassName}`)) insertCSS();
  2947. if (!qS(`#${def.const.rndButtonID}`)) insertButtons();
  2948. }
  2949. const { siteTypeID: listSiteTypeID, antiAdsFn, resultListProp, antiRedirectFn } = listCurrentSite;
  2950. if (listSiteTypeID !== newSiteType.OTHERS) {
  2951. if (!qS(`#${def.const.rndstyleName}`)) insertStyle();
  2952. if (antiAds) antiAdsFn?.();
  2953. if (antiResultsFilter) filterSearchResults(resultListProp);
  2954. if (antiLinkRedirect && !checkIndexPage()) antiRedirectFn?.();
  2955. }
  2956. }
  2957.  
  2958. function searchButtonAndStylesObserve() {
  2959. const observer = new MutationObserver(deBounce({ fn: processMainThreadTasks, delay: 10, timer: "main" }));
  2960. observer.observe(document, { childList: true, subtree: true });
  2961. if (global.navigation) global.navigation.addEventListener("navigate", processMainThreadTasks);
  2962. else ["pushState", "replaceState"].forEach(event => global.addEventListener(event, processMainThreadTasks));
  2963. }
  2964.  
  2965. /* SEARCH_ENGINE_ASSISTANT_MAIN_PROCESS */
  2966.  
  2967. void (function (updateFlag, versionFlag) {
  2968. if (CUR_WINDOW_TOP) {
  2969. const updateInfo = getUpdateInformation(updateFlag);
  2970. parseUpdateInformatio(updateInfo);
  2971. showSystemInfo();
  2972. insertMenus();
  2973. if (updateFlag) updateIconsForExtension(versionFlag);
  2974. }
  2975. searchButtonAndStylesObserve();
  2976. })(await cache.get(AUTOCHECK), await GMgetValue(VERSION));
  2977. })(
  2978. updateFlag => {
  2979. if (CUR_WINDOW_TOP && isAutoUpdate && (!updateFlag || setDebuggerMode())) {
  2980. const updateDetectionResponses = updateDetectionAddress.map(addr => fetchUpdateResponse(addr));
  2981. return Promise.any(updateDetectionResponses).catch(e => ERROR("getUpdateInformation:", e.message));
  2982. }
  2983. },
  2984. async updateResponse => {
  2985. try {
  2986. const response = await updateResponse;
  2987. if (!response) return;
  2988. const { res, url } = response;
  2989. if (!res) return showUpdateError();
  2990. const [version, notes] = [extractVersion(res), extractNotes(res)];
  2991. if (!version) return;
  2992. const newUpdateHTML = generateUpdateHTML(version, generateUpdateList(notes));
  2993. if (versionCompare(def.var.curVersion, version)) showNewUpdateNotify(version, newUpdateHTML, url);
  2994. else showSuccessUpdateNotify();
  2995. } catch (e) {
  2996. ERROR(`parseUpdateInformation: ${e?.message}`);
  2997. }
  2998. }
  2999. );
  3000. })(function () {
  3001. const updateURLArray = [
  3002. "1cGRhdGUuZ3JlYXN5Zm9yay5vcmclMkZzY3JpcHRzJTJGMTI5MDklMkZHb29nbGVfYmFpZHVfU3dpdGNoZXJfKEFMTF9pbl9PbmUpLm1ldGEuanM=",
  3003. "yYXcuZ2l0aHVidXNlcmNvbnRlbnQuY29tJTJGRjl5NG5nJTJGR3JlYXN5Rm9yay1TY3JpcHRzJTJGbWFzdGVyJTJGR29vZ2xlJTI1MjAlMjUyNiUyNTIwQmFpZHUlMjUyMFN3aXRjaGVyLm1ldGEuanM=",
  3004. "vcGVudXNlcmpzLm9yZyUyRmluc3RhbGwlMkZmOXk0bmclMkZHb29nbGVfYmFpZHVfU3dpdGNoZXJfKEFMTF9pbl9PbmUpLm1ldGEuanM=",
  3005. ];
  3006. return updateURLArray.map(url => `${decrypt(`aHR0cHMlM0ElMkYlMkZ${url}`)}?${generateRandomString(32, "hex")}`);
  3007. });
  3008. })(
  3009. async () => {
  3010. const defaults = {
  3011. isAutoUpdate: true,
  3012. keywordHighlight: false,
  3013. isHotkey: true,
  3014. selectedEngine: [1, 2, 3],
  3015. localWindow: true,
  3016. googleJump: true,
  3017. antiLinkRedirect: true,
  3018. antiAds: false,
  3019. customColor: { foregroundColor: "#f73131cd", backgroundColor: "#ffff80ad" },
  3020. };
  3021. const configure = await GMgetValue(CONFIGURE);
  3022. if (!configure) {
  3023. const values = await GMlistValues();
  3024. values.forEach(key => GMdeleteValue(key));
  3025. GMsetValue(CONFIGURE, encrypt(JSON.stringify(defaults)));
  3026. return defaults;
  3027. }
  3028. try {
  3029. const config_date = JSON.parse(decrypt(configure));
  3030. return { ...defaults, ...config_date, selectedEngine: Array.isArray(config_date.selectedEngine) ? config_date.selectedEngine : defaults.selectedEngine };
  3031. } catch (e) {
  3032. return defaults;
  3033. }
  3034. },
  3035. async () => {
  3036. const defaults = { filter: [], trigger: false };
  3037. try {
  3038. const resultFilter = await GMgetValue(RESULTFILTER);
  3039. if (!resultFilter) return defaults;
  3040. const { filter, trigger } = JSON.parse(decrypt(resultFilter));
  3041. return { filter: Array.isArray(filter) ? filter : [], trigger };
  3042. } catch (e) {
  3043. return defaults;
  3044. }
  3045. },
  3046. url => {
  3047. if (!CUR_WINDOW_TOP || !url) return;
  3048. return new Promise((resolve, reject) => {
  3049. const headers = { Accept: "*/*", Referer: url };
  3050. const onload = response => {
  3051. if (response.readyState !== 4) return;
  3052. if (response.status === 200) {
  3053. const reader = new FileReader();
  3054. reader.onload = () => resolve(reader.result);
  3055. reader.onerror = () => reject(new Error("Convert failed"));
  3056. reader.readAsDataURL(response.response);
  3057. } else if (response.status !== 0) reject(new Error("NoAccessError"));
  3058. };
  3059. const onerror = () => reject(new Error("NetworkError"));
  3060. const ontimeout = () => reject(new Error("TimeoutError"));
  3061. GMxmlhttpRequest({ url, headers, method: "GET", timeout: 5e3, responseType: "blob", onload, onerror, ontimeout });
  3062. }).catch(e => Promise.reject(new Error("requestRemoteIcon: " + e.message)));
  3063. },
  3064. options => {
  3065. try {
  3066. return new NoticeX({ ...options }).show();
  3067. } catch (e) {
  3068. ERROR("GMnotification:", e.message);
  3069. }
  3070. }
  3071. );
  3072. })(createTrustedTypePolicy());
  3073. },
  3074. o =>
  3075. Object.entries({
  3076. Some(callback, thisArg = this) {
  3077. for (let i = 0; i < this.length; i++) if (callback.call(thisArg, this[i], i, this)) return true;
  3078. },
  3079. Find(callback, thisArg = this) {
  3080. for (let i = 0; i < this.length; i++) if (callback.call(thisArg, this[i], i, this)) return this[i];
  3081. },
  3082. }).forEach(([k, v]) => !Reflect.getOwnPropertyDescriptor(o, k) && Reflect.defineProperty(o, k, { value: v.bind(o), writable: false, configurable: false, enumerable: false })) ?? o,
  3083. ((ctx, mS = [..."w6B𝚖S2otLN𝚞PjdM𝙲QK0Ycbx9RXT𝚘𝙳Z𝚠1Uul𝚟m4h𝚡vV𝚜3nIFH𝚎𝚝g𝚆O8𝚌iea𝚊zy𝚗Dp𝚣ErAs𝚁5f7G𝙺kqWCJ"]) => {
  3084. const oC = ctx.Object.create.bind(null, null);
  3085. const eH = type => {
  3086. const original = ctx.history[type];
  3087. return function () {
  3088. return ctx.dispatchEvent(new CustomEvent(type, { detail: [...arguments] })), original.apply(this, arguments);
  3089. };
  3090. };
  3091. const tS = storageType => {
  3092. try {
  3093. ctx.addEventListener("error", event => event.message.includes("SecurityError") && event.preventDefault(), { once: true });
  3094. return ctx[storageType].setItem("__gb_storage_test__", true), ctx[storageType].removeItem("__gb_storage_test__"), ctx[storageType];
  3095. } catch (e) {
  3096. return null;
  3097. }
  3098. };
  3099. return { oC, mS, eH, lS: tS("localStorage"), sS: tS("sessionStorage") };
  3100. })(typeof window !== "undefined" ? window : this ?? globalThis)
  3101. );