URL Modifier for Search Engines

Modify (Redirect) URL links in search engines results to alternative frontends or for other purposes

当前为 2024-02-13 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name URL Modifier for Search Engines
  3. // @namespace http://tampermonkey.net/
  4. // @version 2.5.3
  5. // @description Modify (Redirect) URL links in search engines results to alternative frontends or for other purposes
  6. // @author Domenic
  7.  
  8. // @match *://www.google.com/search?*
  9. // @match *://www.google.ad/search?*
  10. // @match *://www.google.ae/search?*
  11. // @match *://www.google.com.af/search?*
  12. // @match *://www.google.com.ag/search?*
  13. // @match *://www.google.al/search?*
  14. // @match *://www.google.am/search?*
  15. // @match *://www.google.co.ao/search?*
  16. // @match *://www.google.com.ar/search?*
  17. // @match *://www.google.as/search?*
  18. // @match *://www.google.at/search?*
  19. // @match *://www.google.com.au/search?*
  20. // @match *://www.google.az/search?*
  21. // @match *://www.google.ba/search?*
  22. // @match *://www.google.com.bd/search?*
  23. // @match *://www.google.be/search?*
  24. // @match *://www.google.bf/search?*
  25. // @match *://www.google.bg/search?*
  26. // @match *://www.google.com.bh/search?*
  27. // @match *://www.google.bi/search?*
  28. // @match *://www.google.bj/search?*
  29. // @match *://www.google.com.bn/search?*
  30. // @match *://www.google.com.bo/search?*
  31. // @match *://www.google.com.br/search?*
  32. // @match *://www.google.bs/search?*
  33. // @match *://www.google.bt/search?*
  34. // @match *://www.google.co.bw/search?*
  35. // @match *://www.google.by/search?*
  36. // @match *://www.google.com.bz/search?*
  37. // @match *://www.google.ca/search?*
  38. // @match *://www.google.cd/search?*
  39. // @match *://www.google.cf/search?*
  40. // @match *://www.google.cg/search?*
  41. // @match *://www.google.ch/search?*
  42. // @match *://www.google.ci/search?*
  43. // @match *://www.google.co.ck/search?*
  44. // @match *://www.google.cl/search?*
  45. // @match *://www.google.cm/search?*
  46. // @match *://www.google.cn/search?*
  47. // @match *://www.google.com.co/search?*
  48. // @match *://www.google.co.cr/search?*
  49. // @match *://www.google.com.cu/search?*
  50. // @match *://www.google.cv/search?*
  51. // @match *://www.google.com.cy/search?*
  52. // @match *://www.google.cz/search?*
  53. // @match *://www.google.de/search?*
  54. // @match *://www.google.dj/search?*
  55. // @match *://www.google.dk/search?*
  56. // @match *://www.google.dm/search?*
  57. // @match *://www.google.com.do/search?*
  58. // @match *://www.google.dz/search?*
  59. // @match *://www.google.com.ec/search?*
  60. // @match *://www.google.ee/search?*
  61. // @match *://www.google.com.eg/search?*
  62. // @match *://www.google.es/search?*
  63. // @match *://www.google.com.et/search?*
  64. // @match *://www.google.fi/search?*
  65. // @match *://www.google.com.fj/search?*
  66. // @match *://www.google.fm/search?*
  67. // @match *://www.google.fr/search?*
  68. // @match *://www.google.ga/search?*
  69. // @match *://www.google.ge/search?*
  70. // @match *://www.google.gg/search?*
  71. // @match *://www.google.com.gh/search?*
  72. // @match *://www.google.com.gi/search?*
  73. // @match *://www.google.gl/search?*
  74. // @match *://www.google.gm/search?*
  75. // @match *://www.google.gr/search?*
  76. // @match *://www.google.com.gt/search?*
  77. // @match *://www.google.gy/search?*
  78. // @match *://www.google.com.hk/search?*
  79. // @match *://www.google.hn/search?*
  80. // @match *://www.google.hr/search?*
  81. // @match *://www.google.ht/search?*
  82. // @match *://www.google.hu/search?*
  83. // @match *://www.google.co.id/search?*
  84. // @match *://www.google.ie/search?*
  85. // @match *://www.google.co.il/search?*
  86. // @match *://www.google.im/search?*
  87. // @match *://www.google.co.in/search?*
  88. // @match *://www.google.iq/search?*
  89. // @match *://www.google.is/search?*
  90. // @match *://www.google.it/search?*
  91. // @match *://www.google.je/search?*
  92. // @match *://www.google.com.jm/search?*
  93. // @match *://www.google.jo/search?*
  94. // @match *://www.google.co.jp/search?*
  95. // @match *://www.google.co.ke/search?*
  96. // @match *://www.google.com.kh/search?*
  97. // @match *://www.google.ki/search?*
  98. // @match *://www.google.kg/search?*
  99. // @match *://www.google.co.kr/search?*
  100. // @match *://www.google.com.kw/search?*
  101. // @match *://www.google.kz/search?*
  102. // @match *://www.google.la/search?*
  103. // @match *://www.google.com.lb/search?*
  104. // @match *://www.google.li/search?*
  105. // @match *://www.google.lk/search?*
  106. // @match *://www.google.co.ls/search?*
  107. // @match *://www.google.lt/search?*
  108. // @match *://www.google.lu/search?*
  109. // @match *://www.google.lv/search?*
  110. // @match *://www.google.com.ly/search?*
  111. // @match *://www.google.co.ma/search?*
  112. // @match *://www.google.md/search?*
  113. // @match *://www.google.me/search?*
  114. // @match *://www.google.mg/search?*
  115. // @match *://www.google.mk/search?*
  116. // @match *://www.google.ml/search?*
  117. // @match *://www.google.com.mm/search?*
  118. // @match *://www.google.mn/search?*
  119. // @match *://www.google.com.mt/search?*
  120. // @match *://www.google.mu/search?*
  121. // @match *://www.google.mv/search?*
  122. // @match *://www.google.mw/search?*
  123. // @match *://www.google.com.mx/search?*
  124. // @match *://www.google.com.my/search?*
  125. // @match *://www.google.co.mz/search?*
  126. // @match *://www.google.com.na/search?*
  127. // @match *://www.google.com.ng/search?*
  128. // @match *://www.google.com.ni/search?*
  129. // @match *://www.google.ne/search?*
  130. // @match *://www.google.nl/search?*
  131. // @match *://www.google.no/search?*
  132. // @match *://www.google.com.np/search?*
  133. // @match *://www.google.nr/search?*
  134. // @match *://www.google.nu/search?*
  135. // @match *://www.google.co.nz/search?*
  136. // @match *://www.google.com.om/search?*
  137. // @match *://www.google.com.pa/search?*
  138. // @match *://www.google.com.pe/search?*
  139. // @match *://www.google.com.pg/search?*
  140. // @match *://www.google.com.ph/search?*
  141. // @match *://www.google.com.pk/search?*
  142. // @match *://www.google.pl/search?*
  143. // @match *://www.google.pn/search?*
  144. // @match *://www.google.com.pr/search?*
  145. // @match *://www.google.ps/search?*
  146. // @match *://www.google.pt/search?*
  147. // @match *://www.google.com.py/search?*
  148. // @match *://www.google.com.qa/search?*
  149. // @match *://www.google.ro/search?*
  150. // @match *://www.google.ru/search?*
  151. // @match *://www.google.rw/search?*
  152. // @match *://www.google.com.sa/search?*
  153. // @match *://www.google.com.sb/search?*
  154. // @match *://www.google.sc/search?*
  155. // @match *://www.google.se/search?*
  156. // @match *://www.google.com.sg/search?*
  157. // @match *://www.google.sh/search?*
  158. // @match *://www.google.si/search?*
  159. // @match *://www.google.sk/search?*
  160. // @match *://www.google.com.sl/search?*
  161. // @match *://www.google.sn/search?*
  162. // @match *://www.google.so/search?*
  163. // @match *://www.google.sm/search?*
  164. // @match *://www.google.sr/search?*
  165. // @match *://www.google.st/search?*
  166. // @match *://www.google.com.sv/search?*
  167. // @match *://www.google.td/search?*
  168. // @match *://www.google.tg/search?*
  169. // @match *://www.google.co.th/search?*
  170. // @match *://www.google.com.tj/search?*
  171. // @match *://www.google.tl/search?*
  172. // @match *://www.google.tm/search?*
  173. // @match *://www.google.tn/search?*
  174. // @match *://www.google.to/search?*
  175. // @match *://www.google.com.tr/search?*
  176. // @match *://www.google.tt/search?*
  177. // @match *://www.google.com.tw/search?*
  178. // @match *://www.google.co.tz/search?*
  179. // @match *://www.google.com.ua/search?*
  180. // @match *://www.google.co.ug/search?*
  181. // @match *://www.google.co.uk/search?*
  182. // @match *://www.google.com.uy/search?*
  183. // @match *://www.google.co.uz/search?*
  184. // @match *://www.google.com.vc/search?*
  185. // @match *://www.google.co.ve/search?*
  186. // @match *://www.google.co.vi/search?*
  187. // @match *://www.google.com.vn/search?*
  188. // @match *://www.google.vu/search?*
  189. // @match *://www.google.ws/search?*
  190. // @match *://www.google.rs/search?*
  191. // @match *://www.google.co.za/search?*
  192. // @match *://www.google.co.zm/search?*
  193. // @match *://www.google.co.zw/search?*
  194. // @match *://www.google.cat/search?*
  195.  
  196. // @match *://search.yahoo.com/search*
  197. // @match *://search.yahoo.co.jp/search?*
  198. // @match *://*.search.yahoo.com/search*
  199.  
  200. // @match *://yandex.com/search/?*
  201. // @match *://yandex.ru/search/?*
  202.  
  203. // @match *://search.disroot.org/search*
  204. // @match *://searx.tiekoetter.com/search*
  205. // @match *://search.bus-hit.me/search*
  206. // @match *://search.inetol.net/search*
  207. // @match *://priv.au/search*
  208. // @match *://searx.be/search*
  209. // @match *://searxng.site/search*
  210. // @match *://search.hbubli.cc/search*
  211. // @match *://search.im-in.space/search*
  212. // @match *://opnxng.com/search*
  213. // @match *://search.upinmars.com/search*
  214. // @match *://search.sapti.me/search*
  215. // @match *://freesearch.club/search*
  216. // @match *://xo.wtf/search*
  217. // @match *://www.gruble.de/search*
  218. // @match *://searx.tuxcloud.net/search*
  219. // @match *://baresearch.org/search*
  220. // @match *://searx.daetalytica.io/search*
  221. // @match *://etsi.me/search*
  222. // @match *://search.leptons.xyz/search*
  223. // @match *://search.rowie.at/search*
  224. // @match *://search.mdosch.de/search*
  225. // @match *://searx.catfluori.de/search*
  226. // @match *://searx.si/search*
  227. // @match *://searx.namejeff.xyz/search*
  228. // @match *://search.itstechtime.com/search*
  229. // @match *://s.mble.dk/search*
  230. // @match *://searx.kutay.dev/search*
  231. // @match *://ooglester.com/search*
  232. // @match *://searx.ox2.fr/search*
  233. // @match *://searx.techsaviours.org/search*
  234. // @match *://searx.perennialte.ch/search*
  235. // @match *://s.trung.fun/searxng/search*
  236. // @match *://search.in.projectsegfau.lt/search*
  237. // @match *://search.projectsegfau.lt/search*
  238. // @match *://darmarit.org/searx/search*
  239. // @match *://searx.lunar.icu/search*
  240. // @match *://nyc1.sx.ggtyler.dev/search*
  241. // @match *://search.rhscz.eu/search*
  242. // @match *://paulgo.io/search*
  243. // @match *://northboot.xyz/search*
  244. // @match *://searx.zhenyapav.com/search*
  245. // @match *://searxng.ch/search*
  246. // @match *://copp.gg/search*
  247. // @match *://searx.sev.monster/search*
  248. // @match *://searx.oakleycord.dev/search*
  249. // @match *://searx.juancord.xyz/search*
  250. // @match *://searx.work/search*
  251. // @match *://search.ononoki.org/search*
  252. // @match *://search.demoniak.ch/search*
  253. // @match *://searx.cthd.icu/search*
  254. // @match *://searx.fmhy.net/search*
  255. // @match *://searx.headpat.exchange/search*
  256. // @match *://sex.finaltek.net/search*
  257. // @match *://search.gcomm.ch/search*
  258. // @match *://search.smnz.de/search*
  259. // @match *://searx.ankha.ac/search*
  260. // @match *://search.lvkaszus.pl/search*
  261. // @match *://searx.nobulart.com/search*
  262. // @match *://sx.t-1.org/search*
  263. // @match *://www.jabber-germany.de/searx/search*
  264. // @match *://sx.catgirl.cloud/search*
  265. // @match *://sx.vern.cc/searxng/search*
  266.  
  267. // @match *://www.startpage.com/search*
  268. // @match *://www.startpage.com/sp/search*
  269.  
  270. // @match *://search.brave.com/search*
  271.  
  272. // @match *://duckduckgo.com
  273. // @match *://duckduckgo.com/?*
  274.  
  275. // @match *://ghosterysearch.com/search?*
  276. // @match *://presearch.com/search?*
  277.  
  278. // @match *://metager.org/*meta/meta.ger3*
  279. // @match *://metager.de/*meta/meta.ger3*
  280.  
  281. // @match *://4get.ca/web?*
  282. // @match *://4get.silly.computer/web?*
  283. // @match *://4get.plunked.party/web?*
  284. // @match *://4get.konakona.moe/web?*
  285. // @match *://4get.sijh.net/web?*
  286. // @match *://4get.hbubli.cc/web?*
  287. // @match *://4get.perennialte.ch/web?*
  288. // @match *://4get.zzls.xyz/web?*
  289. // @match *://4getus.zzls.xyz/web?*
  290. // @match *://4get.seitan-ayoub.lol/web?*
  291. // @match *://4get.dcs0.hu/web?*
  292. // @match *://4get.psily.garden/web?*
  293. // @match *://4get.lvkaszus.pl/web?*
  294. // @match *://4get.kizuki.lol/web?*
  295.  
  296. // @match *://search.ahwx.org/search.php?*
  297. // @match *://search2.ahwx.org/search.php?*
  298. // @match *://search3.ahwx.org/search.php?*
  299. // @match *://ly.owo.si/search.php?*
  300. // @match *://librey.franklyflawless.org/search.php?*
  301. // @match *://librey.org/search.php?*
  302. // @match *://search.davidovski.xyz/search.php?*
  303. // @match *://search.milivojevic.in.rs/search.php?*
  304. // @match *://glass.prpl.wtf/search.php?*
  305. // @match *://librex.uk.to/search.php?*
  306. // @match *://librey.ix.tc/search.php?*
  307. // @match *://search.funami.tech/search.php?*
  308. // @match *://librex.retro-hax.net/search.php?*
  309. // @match *://librex.nohost.network/search.php?*
  310. // @match *://search.pabloferreiro.es/search.php?*
  311. // @match *://librey.baczek.me/search.php?*
  312. // @match *://lx.benike.me/search.php?*
  313. // @match *://search.seitan-ayoub.lol/search.php?*
  314. // @match *://librey.myroware.net/search.php?*
  315. // @match *://librey.nezumi.party/search.php?*
  316. // @match *://search.zeroish.xyz/search.php?*
  317.  
  318. // @match *://stract.com/search?*
  319.  
  320. // @match *://www.etools.ch/searchSubmit.do*
  321. // @match *://www.etools.ch/mobileSearch.do*
  322.  
  323. // @match *://www.mojeek.com/search?*
  324. // @match *://yep.com/web?*
  325. // @match *://www.torry.io/search*
  326. // @match *://www.qwant.com/?*
  327. // @match *://www.ecosia.org/search?*
  328. // @match *://search.becovi.com/serp.php?*
  329. // @match *://good-search.org/*search/?*
  330. // @match *://www.alltheinternet.com/?*
  331. // @match *://search.aol.com/*search*
  332. // @match *://www.onesearch.com/*search*
  333. // @match *://www.info.com/serp?*
  334. // @match *://oceanhero.today/web?*
  335.  
  336. // @match *://swisscows.com/*/web?*
  337.  
  338. // @match *://search.lilo.org/?*
  339. // @match *://search.entireweb.com/search?*
  340. // @match *://search.gmx.com/web/result?*
  341. // @match *://search.gmx.com/web?*
  342. // @match *://youcare.world/all?*
  343. // @match *://search.lycos.com/web/?*
  344. // @match *://alohafind.com/search/?*
  345. // @match *://spot.ecloud.global/search*
  346. // @match *://qmamu.com/search?*
  347. // @match *://www.nona.de/?*
  348. // @match *://www.sapo.pt/pesquisa/web/tudo?*
  349. // @match *://www.exalead.com/search/web/results/?*
  350. // @match *://search.seznam.cz/?*
  351. // @match *://search.naver.com/search.naver?*
  352. // @match *://gibiru.com/results.html?*
  353. // @match *://www.lukol.com/s.php?*
  354. // @match *://search.givewater.com/serp?*
  355. // @match *://results.excite.com/serp?*
  356. // @match *://www.webcrawler.com/serp?*
  357. // @match *://www.metacrawler.com/serp?*
  358. // @match *://www.dogpile.com/serp?*
  359. // @match *://www.zapmeta.com/search?*
  360. // @match *://www.ask.com/web?*
  361. // @match *://www.pronto.com/web?*
  362. // @match *://anoox.com/find.php?*
  363.  
  364. // @grant none
  365. // @run-at document-end
  366. // @license GPL-2.0-only
  367. // ==/UserScript==
  368.  
  369. (function () {
  370. 'use strict';
  371.  
  372. // Define URL modification rules with precompiled regex
  373. const urlModificationRules = [
  374. // {
  375. // matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?(?:https?:\/\/)(?:[\w-]+\.|)((?:imdb|imgur|instagram|medium|odysee|quora|reddit|tiktok|twitter|wikipedia|youtube)\.(?:[a-z]+).*?)(?:$|\/RK=.*|&sa=.*)/),
  376. // replaceWith: 'https://farside.link/$1'
  377. // },
  378. {
  379. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/((?!test)[a-z]+)\.?m?\.wikipedia\.org\/(?:[a-z]+|wiki)\/(?!Special:Search)(.*?)(?:$|\/RK=.*|&sa=.*)/),
  380. replaceWith: 'https://www.wikiwand.com/$1/$2'
  381. },
  382. {
  383. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/zh\.?m?\.wikipedia\.org\/(?:zh-hans|wiki)\/(.*?)(?:$|\/RK=.*|&sa=.*)/),
  384. replaceWith: 'https://www.wikiwand.com/zh-hans/$1'
  385. },
  386. {
  387. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/wikipedia\.org\/(?:[a-z]+|wiki)\/(?!Special:Search)(.*?)(?:$|\/RK=.*|&sa=.*)/),
  388. replaceWith: 'https://www.wikiwand.com/en/$1'
  389. },
  390. {
  391. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/(?:old|www)\.reddit\.com\/((?:r|u)\/.*?)(?:$|\/RK=.*|&sa=.*)/),
  392. replaceWith: 'https://safereddit.com/$1'
  393. // replaceWith: 'https://lr.vern.cc/$1'
  394. },
  395. {
  396. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/www\.quora\.com\/((?=.*-)[\w-]+|profile\/.*?)(?:$|\/RK=.*|&sa=.*)/),
  397. replaceWith: 'https://quetre.iket.me/$1'
  398. },
  399. {
  400. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/twitter\.com\/([A-Za-z_][\w]+)(\/status\/(?:\d+))?(?:.*?)(?:$|\/RK=.*|&sa=.*)/),
  401. replaceWith: 'https://nitter.catsarch.com/$1$2'
  402. },
  403. {
  404. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/stackoverflow\.com(\/questions\/\d+\/[\w-]+)(?:.*?)(?:$|\/RK=.*|&sa=.*)/),
  405. replaceWith: 'https://ao.vern.cc$1'
  406. },
  407. {
  408. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/(.*?(?:medium.*?|towardsdatascience|betterprogramming|plainenglish|gitconnected|aninjusticemag|betterhumans|uxdesign|uxplanet)\.\w+\/(?!tag)(?=.*-)(?:[\w\/-]+|[\w@.]+\/[\w-]+))(?:\?source=.*)?(?:$|\/RK=.*|&sa=.*)/),
  409. replaceWith: 'https://freedium.cfd/https://$1'
  410. },
  411. {
  412. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/(?:www\.|m\.)?youtube\.com\/((?:@|watch\?|playlist\?|channel\/|user\/|shorts\/).*?)(?:$|\/RK=.*|&sa=.*)/),
  413. // replaceWith: 'https://vid.puffyan.us/$1'
  414. replaceWith: 'https://piped.video/$1'
  415. },
  416. {
  417. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/music\.youtube\.com\/((?:playlist\?|watch\?|channel\/|browse\/).*?)(?:$|\/RK=.*|&sa=.*)/),
  418. replaceWith: 'https://hyperpipe.surge.sh/$1'
  419. },
  420. {
  421. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/www\.twitch\.tv\/(\w+)(?:.*?)(?:$|\/RK=.*|&sa=.*)/),
  422. replaceWith: 'https://ttv.vern.cc/$1'
  423. },
  424. {
  425. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/(?:m|www)\.imdb\.com\/((?:title|name)\/\w+)(?:.*?)(?:$|\/RK=.*|&sa=.*)/),
  426. replaceWith: 'https://ld.vern.cc/$1'
  427. },
  428. {
  429. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/www\.goodreads\.com\/((?:(?:[a-z]+\/)?book\/show|work\/quotes|series|author\/show)\/[\w.-]+)(?:.*?)(?:$|\/RK=.*|&sa=.*)/),
  430. replaceWith: 'https://bl.vern.cc/$1'
  431. },
  432. {
  433. // only support English Fandom sites
  434. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/((?!www|community).*?)\.fandom\.com\/wiki\/(.*?)(?:$|\/RK=.*|&sa=.*)/),
  435. replaceWith: 'https://antifandom.com/$1/wiki/$2'
  436. },
  437. {
  438. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/www\.urbandictionary\.com\/(define\.php\?term=.*?)(?:$|\/RK=.*|&sa=.*)/),
  439. replaceWith: 'https://rd.vern.cc/$1'
  440. },
  441. {
  442. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/www\.reuters\.com\/((?=.*\/)(?=.*-).*?)(?:$|\/RK=.*|&sa=.*)/),
  443. replaceWith: 'https://nu.vern.cc/$1'
  444. },
  445. {
  446. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/(www\.ft\.com\/content\/[\w-]+)(?:.*?)(?:$|\/RK=.*|&sa=.*)/),
  447. replaceWith: 'https://archive.today/https://$1'
  448. },
  449. {
  450. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/(www\.bloomberg\.com\/(?:(?:[a-z]+\/)?news|opinion)\/.*?)(?:$|\/RK=.*|&sa=.*)/),
  451. replaceWith: 'https://archive.today/https://$1'
  452. },
  453. {
  454. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/www\.npr\.org\/(?:\d{4}\/\d{2}\/\d{2}|sections)\/(?:[A-Za-z-]+\/\d{4}\/\d{2}\/\d{2}\/)?(\d+)\/(?:.*?)(?:$|\/RK=.*|&sa=.*)/),
  455. replaceWith: 'https://text.npr.org/$1'
  456. },
  457. {
  458. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/news\.ycombinator\.com\/item\?id=(\d+)(?:.*?)(?:$|\/RK=.*|&sa=.*)/),
  459. replaceWith: 'https://www.hckrnws.com/stories/$1'
  460. },
  461. {
  462. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/(?:[a-z]+)\.slashdot\.org(.*?)(?:$|\/RK=.*|&sa=.*)/),
  463. replaceWith: 'https://slashdot.org$1'
  464. },
  465. {
  466. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/(?:(?:.*)(?:arxiv\.org\/pdf|arxiv-export-lb\.library\.cornell\.edu\/(?:pdf|abs)))\/(\d{4}\.\d{4,5}(v\d)?)(?:.*)/),
  467. replaceWith: 'https://arxiv.org/abs/$1'
  468. },
  469. {
  470. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/(ieeexplore\.ieee\.org\/document\/\d+)\/(?:.*?)(?:$|\/RK=.*|&sa=.*)/),
  471. replaceWith: 'https://$1'
  472. },
  473. {
  474. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/github\.ink(.*?)(?:$|\/RK=.*|&sa=.*)/),
  475. replaceWith: 'https://github.com$1'
  476. },
  477. {
  478. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/www\.snopes\.com(.*?)(?:$|\/RK=.*|&sa=.*)/),
  479. replaceWith: 'https://sd.vern.cc$1'
  480. },
  481. {
  482. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/www\.instructables\.com\/(.*?)(?:$|\/RK=.*|&sa=.*)/),
  483. replaceWith: 'https://ds.vern.cc/$1'
  484. // replaceWith: 'https://structables.private.coffee/$1'
  485. },
  486. {
  487. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/genius\.com\/((?=[\w-]+lyrics|search\?q=).*?)(?:$|\/RK=.*|&sa=.*)/),
  488. replaceWith: 'https://dm.vern.cc/$1'
  489. },
  490. {
  491. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/(.*?)\.bandcamp\.com\/(?:$|\/RK=.*|&sa=.*)/),
  492. replaceWith: 'https://tn.vern.cc/artist.php?name=$1'
  493. },
  494. {
  495. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/(.*?)\.bandcamp\.com\/(.*?)\/(.*?)(?:$|\/RK=.*|&sa=.*)/),
  496. replaceWith: 'https://tn.vern.cc/release.php?artist=$1&type=$2&name=$3'
  497. },
  498. {
  499. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/bandcamp\.com\/search\?q=(.*?)(?:$|\/RK=.*|&sa=.*)/),
  500. replaceWith: 'https://tn.vern.cc/search.php?query=$1'
  501. },
  502. {
  503. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/f4\.bcbits\.com\/img\/(.*?)(?:$|\/RK=.*|&sa=.*)/),
  504. replaceWith: 'https://tn.vern.cc/image.php?file=$1'
  505. },
  506. {
  507. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/t4\.bcbits\.com\/stream\/(.*?)\/(.*?)\/(.*?)\?token=(.*?)(?:$|\/RK=.*|&sa=.*)/),
  508. replaceWith: 'https://tn.vern.cc/audio.php?directory=$1&format=$2&file=$3&token=$4'
  509. },
  510. {
  511. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/(?:[\w.]+)?imgur.com\/((?:a\/)?(?!gallery)[\w.]+)(?:.*?)(?:$|\/RK=.*|&sa=.*)/),
  512. replaceWith: 'https://rimgo.totaldarkness.net/$1'
  513. },
  514. {
  515. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/www\.pixiv\.net\/(?:[a-z]+\/)?(artworks\/\d+|tags\/\w+|users\/\d+).*/),
  516. replaceWith: 'https://pixivfe.exozy.me/$1'
  517. },
  518. {
  519. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/knowyourmeme\.com\/(.*?)(?:$|\/RK=.*|&sa=.*)/),
  520. replaceWith: 'https://mm.vern.cc/$1'
  521. },
  522. {
  523. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/tenor\.com\/((?:view|search)\/.*?)(?:$|\/RK=.*|&sa=.*)/),
  524. replaceWith: 'https://sp.vern.cc/$1'
  525. },
  526. {
  527. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/(?:\w+\.)?ifunny\.co\/(picture\/.*?)(?:$|\/RK=.*|&sa=.*)/),
  528. replaceWith: 'https://uf.vern.cc/$1'
  529. },
  530. {
  531. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))https?:\/\/(.*?)(?:$|\/RK=.*|&sa=.*)/),
  532. replaceWith: 'https://$1'
  533. },
  534. // Add more rules here as needed
  535. ];
  536.  
  537. // Define enhanced selector rules for each search engine
  538. const selectorRules = {
  539. 'google': [
  540. {
  541. selector: 'div.MjjYud div.yuRUbf div span a',
  542. childSelector: 'div.byrV5b cite',
  543. updateChildText: true,
  544. containProtocol: true,
  545. urlDisplayMethod: 1
  546. },
  547. {
  548. // selector for sub-results
  549. selector: 'div.MjjYud div.HiHjCd a'
  550. },
  551. {
  552. // selector for sidebar links
  553. selector: 'div.TQc1id#rhs a'
  554. }
  555. ],
  556. 'yahoo': [
  557. {
  558. parentSelector: 'div#left div#web ol li div div.compTitle h3.title',
  559. linkNodeSelector: 'a',
  560. textNodeSelector: 'span.p-abs',
  561. childSelector: 'span',
  562. updateChildText: true,
  563. containProtocol: false,
  564. multiElementsForUrlDisplay: 2
  565. },
  566. {
  567. selector: 'div#left div#web ol li div ul.compArticleList a'
  568. },
  569. {
  570. selector: 'div#left div#web ol li div div.compGenericCardList a'
  571. },
  572. {
  573. selector: 'div#right ol.cardReg.searchRightTop a'
  574. }
  575. ],
  576. 'yahoojp': [
  577. {
  578. parentSelector: 'div.sw-CardBase div.sw-Card__title',
  579. linkNodeSelector: 'a.sw-Card__titleInner',
  580. textNodeSelector: 'div.sw-Card__titleCiteWrapper cite ol',
  581. childSelector: 'li',
  582. updateChildText: true,
  583. containProtocol: true,
  584. multiElementsForUrlDisplay: 1
  585. },
  586. {
  587. selector: 'div.sw-CardBase p.Algo__osl a'
  588. },
  589. {
  590. selector: 'div.sw-CardBase div.sw-Card.AnswerKnowledgePanel__title div.sw-Tooltip__balloonInner a',
  591. updateTextByOverwrite: true,
  592. urlDisplayMethod: 2
  593. },
  594. {
  595. selector: 'div.sw-CardBase div.sw-Card.AnswerKnowledgePanel__title a'
  596. },
  597. {
  598. selector: 'div.sw-CardBase div.sw-Card.AnswerKnowledgePanel__info a'
  599. }
  600. ],
  601. 'yandex': [
  602. {
  603. selector: 'ul#search-result li div.Organic-Subtitle div a',
  604. updateChildText: true,
  605. containProtocol: false,
  606. urlDisplayMethod: 1,
  607. },
  608. {
  609. selector: 'ul#search-result li div.Organic div a',
  610. }
  611. ],
  612. 'searx': [
  613. {
  614. selector: 'article.result a.url_wrapper',
  615. childSelector: 'span span',
  616. updateChildText: true,
  617. containProtocol: true,
  618. multiElementsForUrlDisplay: 1
  619. },
  620. {
  621. selector: 'article.result h3 a'
  622. },
  623. {
  624. selector: 'aside.infobox div.urls ul li a'
  625. }
  626. ],
  627. 'startpage': [
  628. {
  629. selector: 'a.w-gl__result-url.result-link',
  630. updateTextByOverwrite: true,
  631. urlDisplayMethod: 2
  632. },
  633. {
  634. selector: 'a.w-gl__result-title.result-link'
  635. },
  636. {
  637. selector: 'div.sx-kp-main a'
  638. }
  639. ],
  640. 'brave': [
  641. {
  642. selector: 'div.snippet a.h',
  643. childSelector: 'div.site cite.snippet-url span',
  644. updateChildText: true,
  645. containProtocol: false,
  646. multiElementsForUrlDisplay: 1
  647. },
  648. {
  649. selector: 'div#discussions.snippet a',
  650. },
  651. {
  652. selector: 'div#infobox-snippet.snippet a'
  653. }
  654. ],
  655. 'duckduckgo': [
  656. {
  657. selector: 'a.eVNpHGjtxRBq_gLOfGDr.LQNqh2U1kzYxREs65IJu'
  658. },
  659. {
  660. selector: 'a.Rn_JXVtoPVAFyGkcaXyK',
  661. childSelector: 'span',
  662. updateChildText: true,
  663. containProtocol: true,
  664. multiElementsForUrlDisplay: 1
  665. },
  666. {
  667. // Selector for sub-results
  668. selector: 'ul.b269SZlC2oyR13Fcc4Iy li a.f3uDrYrWF3Exrfp1m3Og'
  669. },
  670. {
  671. selector: 'div.react-module div section div a'
  672. }
  673. ],
  674. 'ghostery': [
  675. {
  676. selector: 'li.result h2 a'
  677. },
  678. {
  679. selector: 'li.result div.snippet div.address a.url',
  680. updateTextByOverwrite: true,
  681. urlDisplayMethod: 2
  682. }
  683. ],
  684. 'presearch': [
  685. {
  686. selector: 'div.relative div.w-auto a',
  687. childSelector: 'div',
  688. updateChildText: true,
  689. urlDisplayMethod: 3,
  690. },
  691. {
  692. selector: 'div.relative div.inline-block a'
  693. }
  694. ],
  695. 'metager': [
  696. {
  697. selector: 'h2.result-title a'
  698. },
  699. {
  700. selector: 'div.result-subheadline a',
  701. updateTextByOverwrite: true,
  702. urlDisplayMethod: 3
  703. },
  704. {
  705. selector: 'div.quicktip div.quicktip-headline h1 a'
  706. },
  707. {
  708. selector: 'div.quicktip div.quicktip-detail h2 a'
  709. }
  710. ],
  711. '4get': [
  712. {
  713. parentSelector: 'div.text-result',
  714. linkNodeSelector: 'a.hover',
  715. textNodeSelector: 'div.url',
  716. childSelector: 'a.part',
  717. updateChildText: true,
  718. containProtocol: true,
  719. multiElementsForUrlDisplay: 4
  720. },
  721. {
  722. selector: 'div.text-result div.sublinks a'
  723. },
  724. {
  725. parentSelector: 'div.right-wrapper div.answer',
  726. linkNodeSelector: 'a.answer-title',
  727. textNodeSelector: 'div.url',
  728. childSelector: 'a.part',
  729. updateChildText: true,
  730. containProtocol: true,
  731. multiElementsForUrlDisplay: 4
  732. }
  733. ],
  734. 'librey': [
  735. {
  736. selector: 'div.text-result-wrapper a',
  737. updateTextWithoutOverwrite: true,
  738. useTopLevelDomain: true,
  739. urlDisplayMethod: 2
  740. },
  741. {
  742. selector: 'p.special-result-container a',
  743. updateTextWithoutOverwrite: true,
  744. urlDisplayMethod: 2
  745. },
  746. ],
  747. 'stract': [
  748. {
  749. selector: 'div.grid div div.flex div div a.text-link'
  750. },
  751. {
  752. selector: 'div.grid div div.flex div div div a',
  753. updateTextByOverwrite: true,
  754. urlDisplayMethod: 2
  755. },
  756. {
  757. selector: 'div.mb-5.text-xl a'
  758. },
  759. {
  760. selector: 'div.text-sm a.text-link'
  761. }
  762. ],
  763. 'etools': [
  764. {
  765. // searchSubmit.do
  766. selector: 'td.record a.title'
  767. },
  768. {
  769. // mobileSearch.do
  770. selector: 'p a.title'
  771. }
  772. ],
  773. 'mojeek': [
  774. {
  775. selector: 'ul.results-standard li h2 a.title'
  776. },
  777. {
  778. selector: 'ul.results-standard li a.ob',
  779. childSelector: 'span.url',
  780. updateChildText: true,
  781. containProtocol: true,
  782. urlDisplayMethod: 1
  783. },
  784. {
  785. selector: 'div.infobox p a'
  786. },
  787. {
  788. selector: 'div.results.news-results li a'
  789. },
  790. {
  791. selector: 'div.right-col div.results ul li a'
  792. }
  793. ],
  794. 'yep': [
  795. {
  796. selector: 'div.css-102xgmn-card div div a',
  797. childSelector: 'div span',
  798. updateChildText: true,
  799. containProtocol: false,
  800. urlDisplayMethod: 1
  801. }
  802. ],
  803. 'torry': [
  804. {
  805. selector: 'div.searpList p a.toranclick',
  806. updateTextByOverwrite: true,
  807. urlDisplayMethod: 2
  808. },
  809. {
  810. selector: 'div.searpList div h2 a.toranclick',
  811. },
  812. {
  813. selector: 'div.searpList ul li a',
  814. }
  815. ],
  816. 'qwant': [
  817. {
  818. selector: 'div._35zId._3A7p7 a.external'
  819. },
  820. {
  821. selector: 'div._35zId._3WA-c a.external',
  822. childSelector: 'span',
  823. updateChildText: true,
  824. containProtocol: false,
  825. multiElementsForUrlDisplay: 1
  826. },
  827. {
  828. // Selector for sub-results
  829. selector: 'div._12BMd div._2-LMx._2E8gc._16lFV.Ks7KS.tCpbb.m_hqb a.external'
  830. },
  831. {
  832. selector: 'div._3McWE.is-sidebar a.external'
  833. }
  834. ],
  835. 'ecosia': [
  836. {
  837. selector: 'div.mainline__result-wrapper div.result__header div.result__info a',
  838. childSelector: 'span span',
  839. updateChildText: true,
  840. containProtocol: true,
  841. multiElementsForUrlDisplay: 1
  842. },
  843. {
  844. selector: 'div.mainline__result-wrapper div.result__header div.result__title a'
  845. },
  846. {
  847. selector: 'div.mainline__result-wrapper div ul li a'
  848. },
  849. {
  850. selector: 'aside.sidebar article div.entity-links ul li a'
  851. },
  852. {
  853. selector: 'aside.sidebar article div.entity__content p a'
  854. }
  855. ],
  856. 'oscobo': [
  857. {
  858. selector: 'div.result a',
  859. childSelector: 'span.siteTitleWrap span.favicons',
  860. updateTextWithoutOverwrite: true,
  861. containProtocol: true,
  862. urlDisplayMethod: 1
  863. }
  864. ],
  865. 'good': [
  866. {
  867. selector: 'div.content div.margin-bottom--small.box a.link--search',
  868. childSelector: 'p.url',
  869. updateTextByOverwrite: true,
  870. urlDisplayMethod: 2
  871. },
  872. {
  873. selector: 'div.sx-kp-top a'
  874. },
  875. {
  876. selector: 'div.sx-kp-tab-content-wrap section ul.sx-kp-social-links a'
  877. },
  878. {
  879. selector: 'div.sx-kp-tab-content-wrap section div.sx-kp-attributions a'
  880. }
  881. ],
  882. 'alltheinternet': [
  883. {
  884. parentSelector: 'div.gs-webResult.gs-result',
  885. linkNodeSelector: 'a.gs-title',
  886. textNodeSelector: 'div.gsc-url-top div.gs-visibleUrl-long',
  887. updateTextByOverwrite: true,
  888. urlDisplayMethod: 2
  889. }
  890. ],
  891. 'aol': [
  892. {
  893. parentSelector: 'div#left div#web ol li div div.compTitle',
  894. linkNodeSelector: 'h3.title a',
  895. textNodeSelector: 'div span',
  896. updateTextByOverwrite: true,
  897. urlDisplayMethod: 3
  898. },
  899. {
  900. selector: 'div#left div#web ol li div div.compList a'
  901. },
  902. {
  903. selector: 'div#right ol.cardReg.searchRightTop a'
  904. }
  905. ],
  906. 'onesearch': [
  907. {
  908. parentSelector: 'div#left div#web ol li div div.compTitle',
  909. linkNodeSelector: 'h3.title a',
  910. textNodeSelector: 'div span',
  911. updateTextByOverwrite: true,
  912. urlDisplayMethod: 3
  913. },
  914. {
  915. selector: 'div#left div#web ol li div div.compList a'
  916. },
  917. {
  918. selector: 'div#right ol.cardReg.searchRightTop a'
  919. }
  920. ],
  921. 'info': [
  922. {
  923. parentSelector: 'div.web-yahoo__result',
  924. linkNodeSelector: 'a.web-yahoo__title',
  925. textNodeSelector: 'span.web-yahoo__url',
  926. updateTextWithoutOverwrite: true,
  927. urlDisplayMethod: 2
  928. },
  929. {
  930. selector: 'div.sidebar-results a'
  931. }
  932. ],
  933. 'oceanhero': [
  934. {
  935. selector: 'div div div a',
  936. childSelector: 'span cite',
  937. updateChildText: true,
  938. containProtocol: false,
  939. urlDisplayMethod: 1
  940. },
  941. {
  942. selector: 'section div ul li a'
  943. },
  944. {
  945. selector: 'div div div p a'
  946. }
  947. ],
  948. 'swisscows': [
  949. {
  950. selector: 'article.item-web a.site',
  951. updateTextWithoutOverwrite: true,
  952. containProtocol: false,
  953. urlDisplayMethod: 1
  954. },
  955. {
  956. selector: 'article.item-web a'
  957. }
  958. ],
  959. 'lilo': [
  960. {
  961. selector: 'div.lilo-text-result div p a.has-text-grey-darker',
  962. childSelector: 'span',
  963. updateChildText: true,
  964. containProtocol: true,
  965. multiElementsForUrlDisplay: 2
  966. },
  967. {
  968. selector: 'div.lilo-text-result div a.has-text-primary'
  969. },
  970. {
  971. selector: 'div.column.is-two-fifths a'
  972. }
  973. ],
  974. 'entireweb': [
  975. {
  976. parentSelector: 'div.web-result',
  977. linkNodeSelector: 'a.web-result-title',
  978. textNodeSelector: 'div.web-result-domain',
  979. updateTextWithoutOverwrite: true,
  980. urlDisplayMethod: 3
  981. },
  982. {
  983. selector: 'div#infobox-list.card div.card-body a'
  984. },
  985. {
  986. parentSelector: 'div.gsc-webResult.gsc-result',
  987. linkNodeSelector: 'a.gs-title',
  988. textNodeSelector: 'div.gsc-url-top',
  989. updateTextByOverwrite: true,
  990. containProtocol: false,
  991. urlDisplayMethod: 1
  992. }
  993. ],
  994. 'gmx': [
  995. {
  996. selector: 'div.eMd a.eMdhl'
  997. },
  998. {
  999. selector: 'div.eMd a.eMdu',
  1000. childSelector: 'span',
  1001. updateChildText: true,
  1002. containProtocol: true,
  1003. multiElementsForUrlDisplay: 2
  1004. },
  1005. ],
  1006. 'youcare': [
  1007. {
  1008. selector: 'div.search-result-item-text a.search-result-item-text__title'
  1009. },
  1010. {
  1011. selector: 'div.search-result-item-text div div a.search-result-item-text-sitename'
  1012. },
  1013. {
  1014. selector: 'div.search-result-item-text div div a.search-result-item-text__header-url',
  1015. updateTextWithoutOverwrite: true,
  1016. containProtocol: true,
  1017. urlDisplayMethod: 1
  1018. },
  1019. {
  1020. selector: "div.search-results-view__side a"
  1021. }
  1022. ],
  1023. 'lycos': [
  1024. {
  1025. parentSelector: 'div.results li.result-item',
  1026. linkNodeSelector: 'a.result-link',
  1027. textNodeSelector: 'span.result-url',
  1028. updateTextByOverwrite: true,
  1029. urlDisplayMethod: 3
  1030. },
  1031. {
  1032. selector: 'div.col-aside a'
  1033. }
  1034. ],
  1035. 'alohafind': [
  1036. {
  1037. parentSelector: 'div.gsc-webResult.gsc-result',
  1038. linkNodeSelector: 'a.gs-title',
  1039. textNodeSelector: 'div.gs-visibleUrl-short',
  1040. updateTextByOverwrite: true,
  1041. urlDisplayMethod: 3
  1042. }
  1043. ],
  1044. 'spot': [
  1045. {
  1046. selector: 'div.result h4 a'
  1047. },
  1048. {
  1049. selector: 'div.result a.external-link',
  1050. updateTextByOverwrite: true,
  1051. urlDisplayMethod: 2
  1052. },
  1053. {
  1054. selector: 'div.infobox div.footer div.links a'
  1055. }
  1056. ],
  1057. 'qmamu': [
  1058. {
  1059. selector: 'div.sc-1i4c0yr-4.cxFATD a'
  1060. },
  1061. {
  1062. selector: 'div.sc-meawca-31.liCyKS a',
  1063. childSelector: 'span.sc-meawca-10.czAks',
  1064. updateChildText: true,
  1065. containProtocol: true,
  1066. urlDisplayMethod: 1
  1067. }
  1068. ],
  1069. 'nona': [
  1070. {
  1071. selector: 'section.result-section article.teaser div.teaser__container a.teaser__topline',
  1072. updateTextByOverwrite: true,
  1073. urlDisplayMethod: 2
  1074. },
  1075. {
  1076. selector: 'section.result-section article.teaser div.teaser__container a.teaser__link'
  1077. },
  1078. {
  1079. selector: 'section.result-section article.entity-teaser div.entity-teaser__wrapper a'
  1080. }
  1081. ],
  1082. 'sapo': [
  1083. {
  1084. parentSelector: 'div.gs-webResult.gs-result',
  1085. linkNodeSelector: 'a.gs-title',
  1086. textNodeSelector: 'div.gsc-url-top div.gs-visibleUrl-breadcrumb',
  1087. childSelector: 'span',
  1088. updateChildText: true,
  1089. containProtocol: false,
  1090. urlDisplayMethod: 1
  1091. }
  1092. ],
  1093. 'exalead': [
  1094. {
  1095. selector: 'li.media div.media-body a.ellipsis',
  1096. updateTextByOverwrite: true,
  1097. urlDisplayMethod: 3
  1098. },
  1099. {
  1100. selector: 'li.media div.media-body a'
  1101. }
  1102. ],
  1103. 'seznam': [
  1104. {
  1105. selector: 'div.f2c528 h3 a'
  1106. },
  1107. {
  1108. selector: 'div.f2c528 a.d5e75c',
  1109. updateTextByOverwrite: true,
  1110. urlDisplayMethod: 3
  1111. },
  1112. ],
  1113. 'naver': [
  1114. {
  1115. selector: 'li.bx div.total_wrap div.source_box a.thumb'
  1116. },
  1117. {
  1118. selector: 'li.bx div.total_wrap div.source_box a.txt',
  1119. updateTextByOverwrite: true,
  1120. containProtocol: false,
  1121. urlDisplayMethod: 1
  1122. },
  1123. {
  1124. selector: 'li.bx div.total_wrap a.link_tit'
  1125. },
  1126. {
  1127. selector: 'li.bx div.snippet_rel_wrap a.link_item'
  1128. },
  1129. {
  1130. selector: 'li.bx div.source_cluster_wrap a'
  1131. },
  1132. {
  1133. selector: 'section.sc_new a'
  1134. }
  1135. ],
  1136. 'gibiru': [
  1137. {
  1138. parentSelector: 'div.gs-webResult.gs-result',
  1139. linkNodeSelector: 'a.gs-title',
  1140. textNodeSelector: 'div.gsc-url-top div.gs-visibleUrl-breadcrumb',
  1141. childSelector: 'span',
  1142. updateChildText: true,
  1143. containProtocol: false,
  1144. multiElementsForUrlDisplay: 1
  1145. }
  1146. ],
  1147. 'lukol': [
  1148. {
  1149. parentSelector: 'div.gsc-webResult.gsc-result',
  1150. linkNodeSelector: 'a.gs-title',
  1151. textNodeSelector: 'div.gsc-url-bottom div.gs-visibleUrl-long',
  1152. updateTextByOverwrite: true,
  1153. urlDisplayMethod: 2
  1154. }
  1155. ],
  1156. 'givewater': [
  1157. {
  1158. parentSelector: 'div.web-bing__result',
  1159. linkNodeSelector: 'a.web-bing__title',
  1160. textNodeSelector: 'span.web-bing__url',
  1161. updateTextByOverwrite: true,
  1162. urlDisplayMethod: 2
  1163. }
  1164. ],
  1165. 'excite': [
  1166. {
  1167. parentSelector: 'div.web-bing__result',
  1168. linkNodeSelector: 'a.web-bing__title',
  1169. textNodeSelector: 'span.web-bing__url',
  1170. updateTextByOverwrite: true,
  1171. urlDisplayMethod: 2
  1172. }
  1173. ],
  1174. 'webcrawler': [
  1175. {
  1176. parentSelector: 'div.web-bing__result',
  1177. linkNodeSelector: 'a.web-bing__title',
  1178. textNodeSelector: 'span.web-bing__url',
  1179. updateTextByOverwrite: true,
  1180. urlDisplayMethod: 2
  1181. }
  1182. ],
  1183. 'metacrawler': [
  1184. {
  1185. parentSelector: 'div.web-bing__result',
  1186. linkNodeSelector: 'a.web-bing__title',
  1187. textNodeSelector: 'span.web-bing__url',
  1188. updateTextByOverwrite: true,
  1189. urlDisplayMethod: 2
  1190. }
  1191. ],
  1192. 'dogpile': [
  1193. {
  1194. parentSelector: 'div.web-bing__result',
  1195. linkNodeSelector: 'a.web-bing__title',
  1196. textNodeSelector: 'span.web-bing__url',
  1197. updateTextByOverwrite: true,
  1198. urlDisplayMethod: 2
  1199. }
  1200. ],
  1201. 'zapmeta': [
  1202. {
  1203. parentSelector: 'ol.organic-results__list li',
  1204. linkNodeSelector: 'div.organic-results__title a',
  1205. textNodeSelector: 'div.organic-results__display-url',
  1206. updateTextByOverwrite: true,
  1207. useTopLevelDomain: true,
  1208. urlDisplayMethod: 3
  1209. }
  1210. ],
  1211. 'ask': [
  1212. {
  1213. selector: 'div.result-title a'
  1214. },
  1215. {
  1216. selector: 'div.result-url-section a',
  1217. childSelector: 'span.result-url',
  1218. updateChildText: true,
  1219. urlDisplayMethod: 3
  1220. }
  1221. ],
  1222. 'pronto': [
  1223. {
  1224. selector: 'div.result-title a'
  1225. },
  1226. {
  1227. selector: 'div.result-url-section a',
  1228. childSelector: 'span.result-url',
  1229. updateChildText: true,
  1230. urlDisplayMethod: 3
  1231. }
  1232. ],
  1233. 'anoox': [
  1234. {
  1235. selector: 'div.search_item div.ad_brief_desc a'
  1236. },
  1237. {
  1238. selector: 'div.search_item div.adv_url_con a',
  1239. updateTextByOverwrite: true,
  1240. urlDisplayMethod: 2
  1241. }
  1242. ]
  1243. // Additional search engines can be defined here...
  1244. };
  1245.  
  1246. // User-defined list of search engine instance URLs
  1247. const searchEngines = {
  1248. 'google': {
  1249. hosts: ['google.com'],
  1250. // search results container
  1251. // you can ignore this parameter if you don't want to set it, just delete it
  1252. // defult value is 'body'
  1253. resultContainerSelectors: ['div.GyAeWb#rcnt']
  1254. },
  1255. 'yahoo': {
  1256. hosts: ['search.yahoo.com'],
  1257. resultContainerSelectors: ['div#results div#cols']
  1258. },
  1259. 'yahoojp': {
  1260. hosts: ['search.yahoo.co.jp'],
  1261. resultContainerSelectors: ['div#contents div#contents__wrap']
  1262. },
  1263. 'yandex': {
  1264. hosts: [
  1265. 'yandex.com',
  1266. 'yandex.ru'
  1267. ],
  1268. resultContainerSelectors: ['div.main__container']
  1269. },
  1270. 'searx': {
  1271. hosts: [
  1272. 'search.disroot.org',
  1273. 'searx.tiekoetter.com',
  1274. 'search.bus-hit.me',
  1275. 'search.inetol.net',
  1276. 'priv.au',
  1277. 'searx.be',
  1278. 'searxng.site',
  1279. 'search.hbubli.cc',
  1280. 'search.im-in.space',
  1281. 'opnxng.com',
  1282. 'search.upinmars.com',
  1283. 'search.sapti.me',
  1284. 'freesearch.club',
  1285. 'xo.wtf',
  1286. 'www.gruble.de',
  1287. 'searx.tuxcloud.net',
  1288. 'baresearch.org',
  1289. 'searx.daetalytica.io',
  1290. 'etsi.me',
  1291. 'search.leptons.xyz',
  1292. 'search.rowie.at',
  1293. 'search.mdosch.de',
  1294. 'searx.catfluori.de',
  1295. 'searx.si',
  1296. 'searx.namejeff.xyz',
  1297. 'search.itstechtime.com',
  1298. 's.mble.dk',
  1299. 'searx.kutay.dev',
  1300. 'ooglester.com',
  1301. 'searx.ox2.fr',
  1302. 'searx.techsaviours.org',
  1303. 'searx.perennialte.ch',
  1304. 's.trung.fun',
  1305. 'search.in.projectsegfau.lt',
  1306. 'search.projectsegfau.lt',
  1307. 'darmarit.org',
  1308. 'searx.lunar.icu',
  1309. 'nyc1.sx.ggtyler.dev',
  1310. 'search.rhscz.eu',
  1311. 'paulgo.io',
  1312. 'northboot.xyz',
  1313. 'searx.zhenyapav.com',
  1314. 'searxng.ch',
  1315. 'copp.gg',
  1316. 'searx.sev.monster',
  1317. 'searx.oakleycord.dev',
  1318. 'searx.juancord.xyz',
  1319. 'searx.work',
  1320. 'search.ononoki.org',
  1321. 'search.demoniak.ch',
  1322. 'searx.cthd.icu',
  1323. 'searx.fmhy.net',
  1324. 'searx.headpat.exchange',
  1325. 'sex.finaltek.net',
  1326. 'search.gcomm.ch',
  1327. 'search.smnz.de',
  1328. 'searx.ankha.ac',
  1329. 'search.lvkaszus.pl',
  1330. 'searx.nobulart.com',
  1331. 'sx.t-1.org',
  1332. 'www.jabber-germany.de',
  1333. 'sx.catgirl.cloud'
  1334. ],
  1335. resultContainerSelectors: [
  1336. 'main#main_results'
  1337. // 'maindiv#main_results div#urls'
  1338. // 'div#sidebar div#infoboxes'
  1339. ]
  1340. },
  1341. 'startpage': {
  1342. hosts: ['startpage.com'],
  1343. resultContainerSelectors: [
  1344. 'div.show-results',
  1345. ]
  1346. },
  1347. 'brave': {
  1348. hosts: ['search.brave.com'],
  1349. resultContainerSelectors: [
  1350. 'main.main-column',
  1351. 'aside.sidebar'
  1352. ]
  1353. },
  1354. 'duckduckgo': {
  1355. hosts: ['duckduckgo.com'],
  1356. resultContainerSelectors: [
  1357. 'section[data-testid="mainline"][data-area="mainline"]',
  1358. 'section[data-testid="sidebar"][data-area="sidebar"]'
  1359. ]
  1360. },
  1361. 'ghostery': {
  1362. hosts: ['ghosterysearch.com'],
  1363. resultContainerSelectors: ['section.results']
  1364. },
  1365. 'presearch': {
  1366. hosts: ['presearch.com'],
  1367. resultContainerSelectors: ['div.w-full']
  1368. },
  1369. 'metager': {
  1370. hosts: [
  1371. 'metager.org',
  1372. 'metager.de'
  1373. ],
  1374. resultContainerSelectors: [
  1375. 'div#results',
  1376. 'div#additions-container'
  1377. ]
  1378. },
  1379. '4get': {
  1380. hosts: [
  1381. '4get.ca',
  1382. '4get.silly.computer',
  1383. '4get.plunked.party',
  1384. '4get.konakona.moe',
  1385. '4get.sijh.net',
  1386. '4get.hbubli.cc',
  1387. '4get.perennialte.ch',
  1388. '4get.zzls.xyz',
  1389. '4getus.zzls.xyz',
  1390. '4get.seitan-ayoub.lol',
  1391. '4get.dcs0.hu',
  1392. '4get.psily.garden',
  1393. '4get.lvkaszus.pl',
  1394. '4get.kizuki.lol'
  1395. ],
  1396. resultContainerSelectors: ['div#overflow']
  1397. },
  1398. 'librey': {
  1399. hosts: [
  1400. 'search.ahwx.org',
  1401. 'search2.ahwx.org',
  1402. 'search3.ahwx.org',
  1403. 'ly.owo.si',
  1404. 'librey.franklyflawless.org',
  1405. 'librey.org',
  1406. 'search.davidovski.xyz',
  1407. 'search.milivojevic.in.rs',
  1408. 'glass.prpl.wtf',
  1409. 'librex.uk.to',
  1410. 'librey.ix.tc',
  1411. 'search.funami.tech',
  1412. 'librex.retro-hax.net',
  1413. 'librex.nohost.network',
  1414. 'search.pabloferreiro.es',
  1415. 'librey.baczek.me',
  1416. 'lx.benike.me',
  1417. 'search.seitan-ayoub.lol',
  1418. 'librey.myroware.net',
  1419. 'librey.nezumi.party',
  1420. 'search.zeroish.xyz',
  1421. 'search.zeroish.xyz'
  1422. ],
  1423. resultContainerSelectors: [
  1424. 'div.text-result-container',
  1425. 'p.special-result-container'
  1426. ]
  1427. },
  1428. 'stract': {
  1429. hosts: ['stract.com'],
  1430. resultContainerSelectors: [
  1431. 'div.col-start-1',
  1432. 'div.row-start-2'
  1433. ]
  1434. },
  1435. 'etools': {
  1436. hosts: ['etools.ch'],
  1437. // resultContainerSelectors: ['table.result']
  1438. },
  1439. 'mojeek': {
  1440. hosts: ['mojeek.com'],
  1441. resultContainerSelectors: ['div.container.serp-results']
  1442. },
  1443. 'yep': {
  1444. hosts: ['yep.com']
  1445. },
  1446. 'torry': {
  1447. hosts: ['torry.io'],
  1448. resultContainerSelectors: ['div.searpListouterappend'],
  1449. attribute: 'data-target'
  1450. },
  1451. 'qwant': {
  1452. hosts: ['qwant.com'],
  1453. resultContainerSelectors: ['div._35zId']
  1454. },
  1455. 'ecosia': {
  1456. hosts: ['ecosia.org'],
  1457. resultContainerSelectors: [
  1458. 'section.mainline.web__mainline',
  1459. 'aside.sidebar.web__sidebar'
  1460. ]
  1461. },
  1462. 'oscobo': {
  1463. hosts: ['search.becovi.com'],
  1464. resultContainerSelectors: ['div#results.col']
  1465. },
  1466. 'good': {
  1467. hosts: ['good-search.org'],
  1468. resultContainerSelectors: [
  1469. 'div.grid__item.two-thirds',
  1470. 'div.grid__item.one-third'
  1471. ]
  1472. },
  1473. 'alltheinternet': {
  1474. hosts: ['alltheinternet.com']
  1475. },
  1476. 'aol': {
  1477. hosts: ['search.aol.com'],
  1478. resultContainerSelectors: ['div#results div#cols']
  1479. },
  1480. 'onesearch': {
  1481. hosts: ['onesearch.com'],
  1482. resultContainerSelectors: ['div#results div#cols']
  1483. },
  1484. 'info': {
  1485. hosts: ['info.com'],
  1486. resultContainerSelectors: ['div.layout__body']
  1487. },
  1488. 'oceanhero': {
  1489. hosts: ['oceanhero.today']
  1490. },
  1491. 'swisscows': {
  1492. hosts: ['swisscows.com'],
  1493. resultContainerSelectors: ['section.container.page-results']
  1494. },
  1495. 'lilo': {
  1496. hosts: ['search.lilo.org'],
  1497. resultContainerSelectors: ['div.container#content']
  1498. },
  1499. 'entireweb': {
  1500. hosts: ['search.entireweb.com'],
  1501. resultContainerSelectors: ['div.container.search-container']
  1502. },
  1503. 'gmx': {
  1504. hosts: ['search.gmx.com']
  1505. },
  1506. 'youcare': {
  1507. hosts: ['youcare.world']
  1508. },
  1509. 'lycos': {
  1510. hosts: ['search.lycos.com'],
  1511. resultContainerSelectors: ['div.content.con-search']
  1512. },
  1513. 'alohafind': {
  1514. hosts: ['alohafind.com'],
  1515. resultContainerSelectors: ['section.layout']
  1516. },
  1517. 'spot': {
  1518. hosts: ['spot.ecloud.global'],
  1519. resultContainerSelectors: ['div.container.contents']
  1520. },
  1521. 'qmamu': {
  1522. hosts: ['qmamu.com'],
  1523. resultContainerSelectors: ['div.sc-7aqnu-1.ffCHAv']
  1524. },
  1525. 'nona': {
  1526. hosts: ['nona.de'],
  1527. resultContainerSelectors: ['main.search-results div.container']
  1528. },
  1529. 'sapo': {
  1530. hosts: ['sapo.pt'],
  1531. resultContainerSelectors: ['div.content div.ink-tabs.top']
  1532. },
  1533. 'exalead': {
  1534. hosts: ['exalead.com'],
  1535. resultContainerSelectors: ['ul.media-list']
  1536. },
  1537. 'seznam': {
  1538. hosts: ['search.seznam.cz'],
  1539. resultContainerSelectors: ['div.PageWrapper.SearchPage#searchpage-root'],
  1540. },
  1541. 'naver': {
  1542. hosts: ['search.naver.com'],
  1543. resultContainerSelectors: ['div#main_pack.main_pack'],
  1544. },
  1545. 'gibiru': {
  1546. hosts: ['gibiru.com'],
  1547. resultContainerSelectors: ['div.container#web-results'],
  1548. },
  1549. 'lukol': {
  1550. hosts: ['lukol.com']
  1551. },
  1552. 'givewater': {
  1553. hosts: ['search.givewater.com'],
  1554. resultContainerSelectors: ['div.mainline-results']
  1555. },
  1556. 'excite': {
  1557. hosts: ['results.excite.com'],
  1558. resultContainerSelectors: ['div.mainline-results']
  1559. },
  1560. 'webcrawler': {
  1561. hosts: ['webcrawler.com'],
  1562. resultContainerSelectors: ['div.web-bing'],
  1563. },
  1564. 'metacrawler': {
  1565. hosts: ['metacrawler.com'],
  1566. resultContainerSelectors: ['div.web-bing'],
  1567. },
  1568. 'dogpile': {
  1569. hosts: ['dogpile.com'],
  1570. resultContainerSelectors: ['div.web-bing'],
  1571. },
  1572. 'zapmeta': {
  1573. hosts: ['zapmeta.com'],
  1574. resultContainerSelectors: ['div.component-container__main'],
  1575. },
  1576. 'ask': {
  1577. hosts: ['ask.com'],
  1578. resultContainerSelectors: ['div.search-results div.results'],
  1579. },
  1580. 'pronto': {
  1581. hosts: ['pronto.com'],
  1582. resultContainerSelectors: ['div.search-results div.results'],
  1583. },
  1584. 'anoox': {
  1585. hosts: ['anoox.com'],
  1586. resultContainerSelectors: ['div#main_srch_window div#se_holder_center'],
  1587. }
  1588. // ... more search engines
  1589. };
  1590.  
  1591. // Function to modify URLs and optionally text
  1592. const modifyUrls = (engine, observer, resultContainer, engineInfo) => {
  1593. try {
  1594. const selectors = selectorRules[engine];
  1595. if (selectors) {
  1596. // Disconnect the observer to prevent recursive triggering
  1597. observer.disconnect();
  1598.  
  1599. // Modify results
  1600. selectors.forEach(rule => {
  1601. if (rule.selector) {
  1602. processElements(rule.selector, rule, engineInfo);
  1603. } else if (rule.parentSelector) {
  1604. processParentElements(rule.parentSelector, rule, engineInfo);
  1605. }
  1606. });
  1607.  
  1608. // Reconnect the observer after DOM modifications are done
  1609. observer.observe(resultContainer, { childList: true, subtree: true });
  1610. }
  1611. } catch (error) {
  1612. console.error("URL Modification Error: ", error);
  1613. }
  1614. };
  1615.  
  1616. // Function to process elements specified by `selector`
  1617. const processElements = (selector, rule, engineInfo) => {
  1618. const elements = document.querySelectorAll(selector);
  1619. const additionalAttribute = engineInfo.attribute; // Get the additional attribute if specified
  1620. if (elements.length > 0) {
  1621. elements.forEach(element => {
  1622. for (let i = 0; i < urlModificationRules.length; i++) {
  1623. try {
  1624. const urlRule = urlModificationRules[i];
  1625. let urlToModify = additionalAttribute ? element.getAttribute(additionalAttribute) : element.href;
  1626. urlToModify = decodeURIComponent(urlToModify);
  1627. // update attribute
  1628. if (urlToModify && urlRule.matchRegex.test(urlToModify)) {
  1629. // Generate redirected URL
  1630. let newUrl = urlToModify.replace(urlRule.matchRegex, urlRule.replaceWith);
  1631. newUrl = rule.useTopLevelDomain ? extractTopLevelDomain(newUrl) : newUrl;
  1632. if (element.href) {
  1633. element.href = newUrl;
  1634. } else if (additionalAttribute) {
  1635. element.setAttribute(additionalAttribute, newUrl);
  1636. }
  1637. updateTextContent(element, rule, removeTailingSlash(removeParameters(newUrl)));
  1638. break;
  1639. }
  1640. } catch (error) {
  1641. console.error("Update Link/Text Error: ", error);
  1642. }
  1643. }
  1644. });
  1645. }
  1646. };
  1647.  
  1648. // Function to process elements specified by `parentSelector`
  1649. const processParentElements = (selector, rule, engineInfo) => {
  1650. const elements = document.querySelectorAll(selector);
  1651. const additionalAttribute = engineInfo.attribute; // Get the additional attribute if specified
  1652. if (elements.length > 0) {
  1653. elements.forEach(element => {
  1654. const linkElement = element.querySelector(rule.linkNodeSelector);
  1655. const textElement = element.querySelector(rule.textNodeSelector);
  1656.  
  1657. for (let i = 0; i < urlModificationRules.length; i++) {
  1658. try {
  1659. const urlRule = urlModificationRules[i];
  1660. let urlToModify = additionalAttribute ? element.getAttribute(additionalAttribute) : linkElement.href;
  1661. urlToModify = decodeURIComponent(urlToModify);
  1662. // update attribute
  1663. if (urlToModify && urlRule.matchRegex.test(urlToModify)) {
  1664. // Generate redirected URL
  1665. let newUrl = urlToModify.replace(urlRule.matchRegex, urlRule.replaceWith);
  1666. newUrl = rule.useTopLevelDomain ? extractTopLevelDomain(newUrl) : newUrl;
  1667. if (linkElement.href) {
  1668. linkElement.href = newUrl;
  1669. } else if (additionalAttribute) {
  1670. linkElement.setAttribute(additionalAttribute, newUrl);
  1671. }
  1672. updateTextContent(textElement, rule, removeTailingSlash(removeParameters(newUrl)));
  1673. break;
  1674. }
  1675. } catch (error) {
  1676. console.error("Update Link/Text Error: ", error);
  1677. }
  1678. }
  1679. });
  1680. }
  1681. };
  1682.  
  1683. // Function to update text content (displayed URL)
  1684. const updateTextContent = (element, rule, newUrl) => {
  1685. if (rule.updateChildText || rule.updateTextWithoutOverwrite || rule.updateTextByOverwrite) {
  1686. try {
  1687. if (rule.multiElementsForUrlDisplay) {
  1688. updateMultiElementContent(element, rule, newUrl);
  1689. } else {
  1690. const targetElement = rule.childSelector ? element.querySelector(rule.childSelector) : element;
  1691. updateSingleElementText(targetElement, rule, newUrl);
  1692. }
  1693. } catch (error) {
  1694. console.error("Update Displayed URL Error: ", error);
  1695. }
  1696. }
  1697. };
  1698.  
  1699. // Function to update text for multi elements (e.g. DuckDuckGo, Brave)
  1700. const updateMultiElementContent = (targetElement, rule, newUrl) => {
  1701. if (!targetElement) {
  1702. console.error("Target DOM Element not found for Multi-Element Text update!");
  1703. return;
  1704. }
  1705. // Remove the "https://" protocol if containProtocol is false
  1706. newUrl = rule.containProtocol ? newUrl : removeProtocol(newUrl);
  1707. let formattedUrl = breadCumbFormat(newUrl, rule.containProtocol);
  1708. let urlParts = formattedUrl.split(' › ');
  1709.  
  1710. const spans = targetElement.querySelectorAll(rule.childSelector)
  1711.  
  1712. switch (rule.multiElementsForUrlDisplay) {
  1713. case 1:
  1714. parallelElements(urlParts, spans);
  1715. break;
  1716. case 2:
  1717. mixedElements(urlParts, spans, targetElement);
  1718. break;
  1719. case 3:
  1720. mixedElementsWithoutClear(urlParts, spans, targetElement);
  1721. break;
  1722. case 4:
  1723. fourGetSearchElements(newUrl, spans, targetElement);
  1724. }
  1725. };
  1726.  
  1727. // Case where URL parts are scattered into parallel elements
  1728. const parallelElements = (urlParts, elements) => {
  1729. if (elements && elements.length >= 2) {
  1730. elements.forEach(clearElementContent);
  1731. elements[0].textContent = urlParts[0]; // Update the first part
  1732. elements[1].textContent = ' › ' + urlParts.slice(1).join(' › '); // Update the second part
  1733. } else {
  1734. console.error("Script: Expected structure not found for Multi-Element (parallel elements) URL update!");
  1735. }
  1736. };
  1737.  
  1738. // Case where URL parts are scattered into non-parallel elements
  1739. const mixedElements = (urlParts, elements, parent) => {
  1740. if (elements && elements.length >= 1) {
  1741. elements.forEach(clearElementContent);
  1742. updateTextWithoutOverwriteChildNodes(parent, urlParts[0]); // Update the first part
  1743. elements[0].textContent = ' › ' + urlParts.slice(1).join(' › '); // Update the second part
  1744. } else {
  1745. console.error("Script: Expected structure not found for Multi-Element (mixed elements) URL update!");
  1746. }
  1747. };
  1748.  
  1749. // Same as case 2, but update elements without clearing their original contents
  1750. const mixedElementsWithoutClear = (urlParts, elements, parent) => {
  1751. if (elements && elements.length >= 1) {
  1752. updateTextWithoutOverwriteChildNodes(parent, urlParts[0]); // Update the first part
  1753. elements[0].textContent = ' › ' + urlParts.slice(1).join(' › '); // Update the second part
  1754. } else {
  1755. console.error("Script: Expected structure not found for Multi-Element (mixed elements with clear) URL update!");
  1756. }
  1757. };
  1758.  
  1759. // Case where search engine is 4get
  1760. const fourGetSearchElements = (newUrl, elements, parent) => {
  1761. // Convert NodeList to Array if necessary
  1762. const elementsArray = Array.isArray(elements) ? elements : Array.from(elements);
  1763.  
  1764. // Split the new URL into parts
  1765. const urlParts = splitUrlIntoParts(newUrl);
  1766.  
  1767. // Ensure the elements array length matches the number of URL parts
  1768. matchElementNumWithPartsFor4Get(urlParts, elementsArray, parent);
  1769.  
  1770. let prevCombinedLink = '';
  1771. // Update or add new elements based on the urlParts
  1772. urlParts.forEach((part, index) => {
  1773. let element = elementsArray[index];
  1774. if (!element) {
  1775. element = createPartElementFor4Get(parent);
  1776. elementsArray.push(element);
  1777. }
  1778. prevCombinedLink += part + '/';
  1779. element.href = prevCombinedLink;
  1780. element.textContent = part;
  1781. // Handle separators
  1782. if (index < urlParts.length - 1 && (!element.nextSibling || element.nextSibling.className !== 'separator')) {
  1783. let separator = createSeparatorElementFor4Get();
  1784. parent.insertBefore(separator, element.nextSibling);
  1785. }
  1786. });
  1787.  
  1788. // Remove any extra elements if the new URL has fewer parts than existing elements
  1789. while (elementsArray.length > urlParts.length) {
  1790. const elementToRemove = elementsArray.pop();
  1791. const separator = elementToRemove.nextSibling;
  1792. if (separator && separator.className === 'separator') {
  1793. separator.remove();
  1794. }
  1795. elementToRemove.remove();
  1796. }
  1797. };
  1798.  
  1799. // 4get specific fucntion
  1800. // Ensure the elements array length matches the number of URL parts, if not, add new < a > elements
  1801. const matchElementNumWithPartsFor4Get = (urlParts, elements, parent) => {
  1802. while (elements.length < urlParts.length) {
  1803. const newElement = createPartElementFor4Get(parent);
  1804. parent.appendChild(newElement);
  1805. elements.push(newElement);
  1806. }
  1807. };
  1808.  
  1809. // 4get specific fucntion
  1810. // Create a new <a> element that represents a URL component
  1811. const createPartElementFor4Get = () => {
  1812. const element = document.createElement('a');
  1813. element.className = 'part';
  1814. element.setAttribute('rel', 'noreferrer nofollow');
  1815. element.setAttribute('tabindex', '-1');
  1816. return element;
  1817. };
  1818.  
  1819. // 4get specific fucntion
  1820. // Create a new <span> element that represents a URL separator '/'
  1821. const createSeparatorElementFor4Get = () => {
  1822. const separator = document.createElement('span');
  1823. separator.className = 'separator';
  1824. return separator;
  1825. };
  1826.  
  1827. // Function to update text for a single element
  1828. const updateSingleElementText = (targetElement, rule, newUrl) => {
  1829. if (!targetElement) {
  1830. console.error("Target DOM Element not found for Single-Element Text update!");
  1831. return;
  1832. }
  1833. let formattedUrl = '';
  1834. switch (rule.urlDisplayMethod) {
  1835. case 1:
  1836. formattedUrl = breadCumbFormat(newUrl, rule.containProtocol);
  1837. break;
  1838. case 2:
  1839. formattedUrl = newUrl; // Full URL with protocol
  1840. break;
  1841. case 3:
  1842. formattedUrl = decodeURIComponent(removeProtocol(newUrl)); // Full URL without protocol
  1843. break;
  1844. }
  1845. if (rule.updateTextWithoutOverwrite) {
  1846. updateTextWithoutOverwriteChildNodes(targetElement, formattedUrl);
  1847. } else if (rule.updateTextByOverwrite) {
  1848. updateTextByOverwriteEverything(targetElement, formattedUrl);
  1849. } else {
  1850. targetElement.textContent = formattedUrl;
  1851. }
  1852. };
  1853.  
  1854. // Format URLs into Breadcrumb style, while leaving 'https://' intact
  1855. const breadCumbFormat = (url, containProtocol) => {
  1856. if (!containProtocol) {
  1857. url = removeProtocol(url);
  1858. }
  1859.  
  1860. const urlParts = splitUrlIntoParts(url, containProtocol);
  1861.  
  1862. // Join the URL parts with ' › '
  1863. const joinedUrl = urlParts.join(' › ');
  1864.  
  1865. // Decode the URL to convert encoded characters to their original form
  1866. return decodeURIComponent(joinedUrl);
  1867. };
  1868.  
  1869. // Function to update only the text node within an element, leave the child elements, if exist, intact
  1870. const updateTextWithoutOverwriteChildNodes = (element, newContent) => {
  1871. let currentIndex = 0;
  1872. const indexObject = { currentIndex };
  1873. collectNodes(element, node => {
  1874. if (currentIndex >= newContent.length) return; // Stop if we've used all the new content
  1875. replaceTextContent(node, oldText => replaceTextBasedOnIndex(oldText, newContent, indexObject));
  1876. });
  1877. };
  1878.  
  1879. // Function to collect all text nodes within an element
  1880. const collectNodes = (node, callback) => {
  1881. // View these elements as text node
  1882. const elementsToIncludeAsText = ['B'];
  1883. // Do not view these elements as text node
  1884. const elementsToExcludeAsText = ['H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'DIV', 'P'];
  1885.  
  1886. if (node.nodeType === Node.TEXT_NODE) {
  1887. callback(node);
  1888. } else if (node.nodeType === Node.ELEMENT_NODE && elementsToIncludeAsText.includes(node.tagName.toUpperCase())) {
  1889. callback(node);
  1890. } else if (node.nodeType === Node.ELEMENT_NODE && !elementsToExcludeAsText.includes(node.tagName.toUpperCase())) {
  1891. node.childNodes.forEach(child => collectNodes(child, callback));
  1892. }
  1893. };
  1894.  
  1895. // Function to replace the text content of a node
  1896. const replaceTextContent = (node, textUpdater) => {
  1897. if (node.nodeType === Node.TEXT_NODE) {
  1898. node.nodeValue = textUpdater(node.nodeValue);
  1899. } else if (node.innerHTML) { // For elements treated as text, like <b>
  1900. node.innerHTML = textUpdater(node.innerHTML);
  1901. }
  1902. };
  1903.  
  1904. // Function to replace text based on index
  1905. const replaceTextBasedOnIndex = (oldText, newContent, indexObject) => {
  1906. const newText = newContent.slice(indexObject.currentIndex, indexObject.currentIndex + oldText.length);
  1907. indexObject.currentIndex += oldText.length;
  1908. return newText;
  1909. };
  1910.  
  1911. // Function to update the content by overwriting everything
  1912. const updateTextByOverwriteEverything = (element, newContent) => {
  1913. clearElementContent(element);
  1914. element.textContent = newContent;
  1915. };
  1916.  
  1917. // Split URL into components, while preserving 'https://' in all occurrences
  1918. const splitUrlIntoParts = (url, containProtocol) => {
  1919. // Temporary replace 'https://' with a placeholder that is unlikely to be part of any URL
  1920. const placeholder = "HTTPS_PLACEHOLDER";
  1921. let tempUrl = url.replace(/https:\/\//g, placeholder);
  1922.  
  1923. // Split the URL by '/'
  1924. let parts = tempUrl.split('/');
  1925.  
  1926. // Replace the placeholder back with 'https://'
  1927. parts = parts.map(part => part.replace(new RegExp(placeholder, 'g'), 'https://'));
  1928.  
  1929. // Filter out any empty strings that may have resulted from the split
  1930. parts = parts.filter(part => part !== '');
  1931.  
  1932. // Ensure the first part always starts with 'https://', adjusting if necessary
  1933. if (containProtocol && parts.length > 0 && !parts[0].startsWith('https://')) {
  1934. parts[0] = 'https://' + parts[0];
  1935. }
  1936.  
  1937. return parts;
  1938. };
  1939.  
  1940. // Extract the top level domain from URL link
  1941. const extractTopLevelDomain = (url) => {
  1942. const parsedUrl = new URL(url);
  1943. return `${parsedUrl.protocol}//${parsedUrl.hostname}/`;
  1944. };
  1945.  
  1946. // Remove 'https://' from the URL link
  1947. const removeProtocol = (url) => {
  1948. return url.replace(/^https?:\/\//, '');
  1949. };
  1950.  
  1951. // Remove parameters (the part behind ?) in the URL link
  1952. const removeParameters = (url) => {
  1953. return url.split('?')[0];
  1954. };
  1955.  
  1956. // Remove tailing slash '/'
  1957. const removeTailingSlash = (url) => {
  1958. // Check if the URL ends with a slash and remove it if present
  1959. return url.endsWith('/') ? url.slice(0, -1) : url;
  1960. };
  1961.  
  1962. // Function to clear existing content of an element
  1963. const clearElementContent = (element) => {
  1964. element.textContent = '';
  1965. };
  1966.  
  1967. // Improved function to determine the search engine
  1968. const getSearchEngineInfo = () => {
  1969. try {
  1970. const host = window.location.host;
  1971. for (const engine in searchEngines) {
  1972. if (searchEngines[engine].hosts.some(instanceHost => host.includes(instanceHost))) {
  1973. // Default to 'body' if not specified
  1974. const selectors = searchEngines[engine].resultContainerSelectors || ['body'];
  1975. // Get the attribute if specified
  1976. const attribute = searchEngines[engine].attribute;
  1977. return {
  1978. engine,
  1979. selectors: selectors,
  1980. attribute: attribute
  1981. };
  1982. }
  1983. }
  1984. } catch (error) {
  1985. console.error("Error determining search engine: ", error);
  1986. }
  1987. };
  1988.  
  1989. // Function to observe and execute the URL modifier script
  1990. const observeToExecute = (engine, selector, engineInfo) => {
  1991. const resultContainers = document.querySelectorAll(selector);
  1992. if (resultContainers) {
  1993. resultContainers.forEach(resultContainer => {
  1994. // Observe changes in each result container
  1995. const observer = new MutationObserver(() => modifyUrls(engine, observer, resultContainer, engineInfo));
  1996. observer.observe(resultContainer, { childList: true, subtree: true });
  1997. modifyUrls(engine, observer, resultContainer, engineInfo);
  1998. });
  1999. }
  2000. };
  2001.  
  2002. // Run the script for the current search engine
  2003. try {
  2004. const engineInfo = getSearchEngineInfo();
  2005. if (engineInfo) {
  2006. engineInfo.selectors.forEach(containerSelector => {
  2007. observeToExecute(engineInfo.engine, containerSelector, engineInfo);
  2008. });
  2009. }
  2010. } catch (error) {
  2011. console.error("Error executing URL Modifier Script: ", error);
  2012. }
  2013. })();