URL Modifier for Search Engines

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

目前为 2024-02-06 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name URL Modifier for Search Engines
  3. // @namespace http://tampermonkey.net/
  4. // @version 2.4.2
  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 *://www.nona.de/?*
  347. // @match *://www.exalead.com/search/web/results/?*
  348. // @match *://search.seznam.cz/?*
  349. // @match *://gibiru.com/results.html?*
  350. // @match *://www.lukol.com/s.php?*
  351. // @match *://search.givewater.com/serp?*
  352. // @match *://results.excite.com/serp?*
  353. // @match *://www.webcrawler.com/serp?*
  354. // @match *://www.metacrawler.com/serp?*
  355. // @match *://www.dogpile.com/serp?*
  356.  
  357. // @grant none
  358. // @run-at document-end
  359. // @license GPL-2.0-only
  360. // ==/UserScript==
  361.  
  362. (function() {
  363. 'use strict';
  364.  
  365. // Define URL modification rules with precompiled regex
  366. const urlModificationRules = [
  367. // {
  368. // matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?(?:https?:\/\/)(?:[\w-]+\.|)((?:imdb|imgur|instagram|medium|odysee|quora|reddit|tiktok|twitter|wikipedia|youtube)\.(?:[a-z]+).*?)(?:$|\/RK=.*|&sa=.*)/),
  369. // replaceWith: 'https://farside.link/$1'
  370. // },
  371. {
  372. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/((?!test)[a-z]+)\.?m?\.wikipedia\.org\/(?:[a-z]+|wiki)\/(?!Special:Search)(.*?)(?:$|\/RK=.*|&sa=.*)/),
  373. replaceWith: 'https://www.wikiwand.com/$1/$2'
  374. },
  375. {
  376. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/zh\.?m?\.wikipedia\.org\/(?:zh-hans|wiki)\/(.*?)(?:$|\/RK=.*|&sa=.*)/),
  377. replaceWith: 'https://www.wikiwand.com/zh-hans/$1'
  378. },
  379. {
  380. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/wikipedia\.org\/(?:[a-z]+|wiki)\/(?!Special:Search)(.*?)(?:$|\/RK=.*|&sa=.*)/),
  381. replaceWith: 'https://www.wikiwand.com/en/$1'
  382. },
  383. {
  384. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/(?:old|www)\.reddit\.com\/((?:r|u)\/.*?)(?:$|\/RK=.*|&sa=.*)/),
  385. replaceWith: 'https://safereddit.com/$1'
  386. // replaceWith: 'https://lr.vern.cc/$1'
  387. },
  388. {
  389. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/www\.quora\.com\/((?=.*-)[\w-]+|profile\/.*?)(?:$|\/RK=.*|&sa=.*)/),
  390. replaceWith: 'https://quetre.iket.me/$1'
  391. },
  392. {
  393. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/twitter\.com\/([A-Za-z_][\w]+)(\/status\/(?:\d+))?(?:.*?)(?:$|\/RK=.*|&sa=.*)/),
  394. replaceWith: 'https://nitter.catsarch.com/$1$2'
  395. },
  396. {
  397. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/stackoverflow\.com(\/questions\/\d+\/[\w-]+)(?:.*?)(?:$|\/RK=.*|&sa=.*)/),
  398. replaceWith: 'https://ao.vern.cc$1'
  399. },
  400. {
  401. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/((?:(?:[\w.-]+)?medium(?:\.[\w-]+)?|towardsdatascience|betterprogramming|.*?plainenglish|.*?gitconnected|aninjusticemag|betterhumans|uxdesign|uxplanet)\.\w+\/(?=.*-)(?:.*?|[\w@.]+\/[\w-]+))(?:\?source=.*)?(?:$|\/RK=.*|&sa=.*)/),
  402. replaceWith: 'https://freedium.cfd/https://$1'
  403. },
  404. {
  405. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/(?:www\.|m\.)?youtube\.com\/((?:@|watch\?|playlist\?|channel\/|user\/|shorts\/).*?)(?:$|\/RK=.*|&sa=.*)/),
  406. replaceWith: 'https://vid.puffyan.us/$1'
  407. // replaceWith: 'https://piped.video/$1'
  408. },
  409. {
  410. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/music\.youtube\.com\/((?:playlist\?|watch\?|channel\/|browse\/).*?)(?:$|\/RK=.*|&sa=.*)/),
  411. replaceWith: 'https://hyperpipe.surge.sh/$1'
  412. },
  413. {
  414. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/www\.twitch\.tv\/(\w+)(?:.*?)(?:$|\/RK=.*|&sa=.*)/),
  415. replaceWith: 'https://ttv.vern.cc/$1'
  416. },
  417. {
  418. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/(?:m|www)\.imdb\.com\/((?:title|name)\/\w+)(?:.*?)(?:$|\/RK=.*|&sa=.*)/),
  419. replaceWith: 'https://ld.vern.cc/$1'
  420. },
  421. {
  422. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/www\.goodreads\.com\/((?:(?:[a-z]+\/)?book\/show|work\/quotes|series|author\/show)\/[\w.-]+)(?:.*?)(?:$|\/RK=.*|&sa=.*)/),
  423. replaceWith: 'https://bl.vern.cc/$1'
  424. },
  425. {
  426. // only support English Fandom sites
  427. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/((?!www|community).*?)\.fandom\.com\/wiki\/(.*?)(?:$|\/RK=.*|&sa=.*)/),
  428. replaceWith: 'https://antifandom.com/$1/wiki/$2'
  429. },
  430. {
  431. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/www\.urbandictionary\.com\/(define\.php\?term=.*?)(?:$|\/RK=.*|&sa=.*)/),
  432. replaceWith: 'https://rd.vern.cc/$1'
  433. },
  434. {
  435. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/www\.reuters\.com\/((?=.*\/)(?=.*-).*?)(?:$|\/RK=.*|&sa=.*)/),
  436. replaceWith: 'https://nu.vern.cc/$1'
  437. },
  438. {
  439. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/(www\.ft\.com\/content\/[\w-]+)(?:.*?)(?:$|\/RK=.*|&sa=.*)/),
  440. replaceWith: 'https://archive.today/https://$1'
  441. },
  442. {
  443. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/(www\.bloomberg\.com\/(?:(?:[a-z]+\/)?news|opinion)\/.*?)(?:$|\/RK=.*|&sa=.*)/),
  444. replaceWith: 'https://archive.today/https://$1'
  445. },
  446. {
  447. 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=.*)/),
  448. replaceWith: 'https://text.npr.org/$1'
  449. },
  450. {
  451. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/news\.ycombinator\.com\/item\?id=(\d+)(?:.*?)(?:$|\/RK=.*|&sa=.*)/),
  452. replaceWith: 'https://www.hckrnws.com/stories/$1'
  453. },
  454. {
  455. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/(?:[a-z]+)\.slashdot\.org(.*?)(?:$|\/RK=.*|&sa=.*)/),
  456. replaceWith: 'https://slashdot.org$1'
  457. },
  458. {
  459. 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)?)(?:.*)/),
  460. replaceWith: 'https://arxiv.org/abs/$1'
  461. },
  462. {
  463. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/(ieeexplore\.ieee\.org\/document\/\d+)\/(?:.*?)(?:$|\/RK=.*|&sa=.*)/),
  464. replaceWith: 'https://$1'
  465. },
  466. {
  467. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/github\.ink(.*?)(?:$|\/RK=.*|&sa=.*)/),
  468. replaceWith: 'https://github.com$1'
  469. },
  470. {
  471. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/www\.snopes\.com(.*?)(?:$|\/RK=.*|&sa=.*)/),
  472. replaceWith: 'https://sd.vern.cc$1'
  473. },
  474. {
  475. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/www\.instructables\.com\/(.*?)(?:$|\/RK=.*|&sa=.*)/),
  476. replaceWith: 'https://ds.vern.cc/$1'
  477. // replaceWith: 'https://structables.private.coffee/$1'
  478. },
  479. {
  480. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/genius\.com\/((?=[\w-]+lyrics|search\?q=).*?)(?:$|\/RK=.*|&sa=.*)/),
  481. replaceWith: 'https://dm.vern.cc/$1'
  482. },
  483. {
  484. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/(.*?)\.bandcamp\.com\/(?:$|\/RK=.*|&sa=.*)/),
  485. replaceWith: 'https://tn.vern.cc/artist.php?name=$1'
  486. },
  487. {
  488. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/(.*?)\.bandcamp\.com\/(.*?)\/(.*?)(?:$|\/RK=.*|&sa=.*)/),
  489. replaceWith: 'https://tn.vern.cc/release.php?artist=$1&type=$2&name=$3'
  490. },
  491. {
  492. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/bandcamp\.com\/search\?q=(.*?)(?:$|\/RK=.*|&sa=.*)/),
  493. replaceWith: 'https://tn.vern.cc/search.php?query=$1'
  494. },
  495. {
  496. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/f4\.bcbits\.com\/img\/(.*?)(?:$|\/RK=.*|&sa=.*)/),
  497. replaceWith: 'https://tn.vern.cc/image.php?file=$1'
  498. },
  499. {
  500. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/t4\.bcbits\.com\/stream\/(.*?)\/(.*?)\/(.*?)\?token=(.*?)(?:$|\/RK=.*|&sa=.*)/),
  501. replaceWith: 'https://tn.vern.cc/audio.php?directory=$1&format=$2&file=$3&token=$4'
  502. },
  503. {
  504. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/(?:\w+\.)?imgur.com\/((?:a\/)?(?!gallery)[\w.]+)(?:.*?)(?:$|\/RK=.*|&sa=.*)/),
  505. replaceWith: 'https://rimgo.totaldarkness.net/$1'
  506. },
  507. {
  508. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/www\.pixiv\.net\/(?:[a-z]+\/)?(artworks\/\d+|tags\/\w+|users\/\d+).*/),
  509. replaceWith: 'https://pixivfe.exozy.me/$1'
  510. },
  511. {
  512. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/knowyourmeme\.com\/(.*?)(?:$|\/RK=.*|&sa=.*)/),
  513. replaceWith: 'https://mm.vern.cc/$1'
  514. },
  515. {
  516. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/tenor\.com\/((?:view|search)\/.*?)(?:$|\/RK=.*|&sa=.*)/),
  517. replaceWith: 'https://sp.vern.cc/$1'
  518. },
  519. {
  520. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))?https?:\/\/(?:\w+\.)?ifunny\.co\/(picture\/.*?)(?:$|\/RK=.*|&sa=.*)/),
  521. replaceWith: 'https://uf.vern.cc/$1'
  522. },
  523. {
  524. matchRegex: new RegExp(/^(?:.*?(?:\/RU=|&q=|&as=))https?:\/\/(.*?)(?:$|\/RK=.*|&sa=.*)/),
  525. replaceWith: 'https://$1'
  526. },
  527. // Add more rules here as needed
  528. ];
  529.  
  530. // Define enhanced selector rules for each search engine
  531. const selectorRules = {
  532. 'google': [
  533. {
  534. selector: 'div.MjjYud div.yuRUbf div span a',
  535. childSelector: 'div.byrV5b cite',
  536. updateChildText: true,
  537. containProtocol: true,
  538. urlDisplayMethod: 1
  539. },
  540. {
  541. // selector for sub-results
  542. selector: 'div.MjjYud div.HiHjCd a'
  543. },
  544. {
  545. // selector for sidebar links
  546. selector: 'div.TQc1id#rhs a'
  547. }
  548. ],
  549. 'yahoo': [
  550. {
  551. parentSelector: 'div#left div#web ol li div div.compTitle h3.title',
  552. linkNodeSelector: 'a',
  553. textNodeSelector: 'span.p-abs',
  554. childSelector: 'span',
  555. updateChildText: true,
  556. containProtocol: false,
  557. multiElementsForUrlDisplay: 2
  558. },
  559. {
  560. selector: 'div#left div#web ol li div ul.compArticleList a'
  561. },
  562. {
  563. selector: 'div#left div#web ol li div div.compGenericCardList a'
  564. },
  565. {
  566. selector: 'div#right ol.cardReg.searchRightTop a'
  567. }
  568. ],
  569. 'yahoojp': [
  570. {
  571. parentSelector: 'div.sw-CardBase div.sw-Card__title',
  572. linkNodeSelector: 'a.sw-Card__titleInner',
  573. textNodeSelector: 'div.sw-Card__titleCiteWrapper cite ol',
  574. childSelector: 'li',
  575. updateChildText: true,
  576. containProtocol: true,
  577. multiElementsForUrlDisplay: 1
  578. },
  579. {
  580. selector: 'div.sw-CardBase p.Algo__osl a'
  581. },
  582. {
  583. selector: 'div.sw-CardBase div.sw-Card.AnswerKnowledgePanel__title div.sw-Tooltip__balloonInner a',
  584. updateTextByOverwrite: true,
  585. urlDisplayMethod: 2
  586. },
  587. {
  588. selector: 'div.sw-CardBase div.sw-Card.AnswerKnowledgePanel__title a'
  589. },
  590. {
  591. selector: 'div.sw-CardBase div.sw-Card.AnswerKnowledgePanel__info a'
  592. }
  593. ],
  594. 'yandex': [
  595. {
  596. selector: 'ul#search-result li div.Organic-Subtitle div a',
  597. updateChildText: true,
  598. containProtocol: false,
  599. urlDisplayMethod: 1,
  600. },
  601. {
  602. selector: 'ul#search-result li div.Organic div a',
  603. }
  604. ],
  605. 'searx': [
  606. {
  607. selector: 'article.result a.url_wrapper',
  608. childSelector: 'span span',
  609. updateChildText: true,
  610. containProtocol: true,
  611. multiElementsForUrlDisplay: 1
  612. },
  613. {
  614. selector: 'article.result h3 a'
  615. },
  616. {
  617. selector: 'aside.infobox div.urls ul li a'
  618. }
  619. ],
  620. 'startpage': [
  621. {
  622. selector: 'a.w-gl__result-url.result-link',
  623. updateTextByOverwrite: true,
  624. urlDisplayMethod: 2
  625. },
  626. {
  627. selector: 'a.w-gl__result-title.result-link'
  628. },
  629. {
  630. selector: 'div.sx-kp-main a'
  631. }
  632. ],
  633. 'brave': [
  634. {
  635. selector: 'div.snippet a.h',
  636. childSelector: 'div.site cite.snippet-url span',
  637. updateChildText: true,
  638. containProtocol: false,
  639. multiElementsForUrlDisplay: 1
  640. },
  641. {
  642. selector: 'div#discussions.snippet a',
  643. },
  644. {
  645. selector: 'div#infobox-snippet.snippet a'
  646. }
  647. ],
  648. 'duckduckgo': [
  649. {
  650. selector: 'a.eVNpHGjtxRBq_gLOfGDr.LQNqh2U1kzYxREs65IJu'
  651. },
  652. {
  653. selector: 'a.Rn_JXVtoPVAFyGkcaXyK',
  654. childSelector: 'span',
  655. updateChildText: true,
  656. containProtocol: true,
  657. multiElementsForUrlDisplay: 1
  658. },
  659. {
  660. // Selector for sub-results
  661. selector: 'ul.b269SZlC2oyR13Fcc4Iy li a.f3uDrYrWF3Exrfp1m3Og'
  662. },
  663. {
  664. selector: 'div.react-module div section div a'
  665. }
  666. ],
  667. 'ghostery': [
  668. {
  669. selector: 'li.result h2 a'
  670. },
  671. {
  672. selector: 'li.result div.snippet div.address a.url',
  673. updateTextByOverwrite: true,
  674. urlDisplayMethod: 2
  675. }
  676. ],
  677. 'presearch': [
  678. {
  679. selector: 'div.relative div.w-auto a',
  680. childSelector: 'div',
  681. updateChildText: true,
  682. urlDisplayMethod: 3,
  683. },
  684. {
  685. selector: 'div.relative div.inline-block a'
  686. }
  687. ],
  688. 'metager': [
  689. {
  690. selector: 'h2.result-title a'
  691. },
  692. {
  693. selector: 'div.result-subheadline a',
  694. updateTextByOverwrite: true,
  695. urlDisplayMethod: 3
  696. },
  697. {
  698. selector: 'div.quicktip div.quicktip-headline h1 a'
  699. },
  700. {
  701. selector: 'div.quicktip div.quicktip-detail h2 a'
  702. }
  703. ],
  704. '4get': [
  705. {
  706. selector: 'div.text-result a.hover'
  707. },
  708. {
  709. selector: 'div.text-result div.sublinks a'
  710. },
  711. {
  712. selector: 'div.right-wrapper div.answer-wrapper div.answer div.answer-title a.answer-title'
  713. }
  714. ],
  715. 'librey': [
  716. {
  717. selector: 'div.text-result-wrapper a',
  718. updateTextWithoutOverwrite: true,
  719. useTopLevelDomain: true,
  720. urlDisplayMethod: 2
  721. },
  722. {
  723. selector: 'p.special-result-container a',
  724. updateTextWithoutOverwrite: true,
  725. urlDisplayMethod: 2
  726. },
  727. ],
  728. 'stract': [
  729. {
  730. selector: 'div.grid div div.flex div div a.text-link'
  731. },
  732. {
  733. selector: 'div.grid div div.flex div div div a',
  734. updateTextByOverwrite: true,
  735. urlDisplayMethod: 2
  736. },
  737. {
  738. selector: 'div.mb-5.text-xl a'
  739. },
  740. {
  741. selector: 'div.text-sm a.text-link'
  742. }
  743. ],
  744. 'etools': [
  745. {
  746. // searchSubmit.do
  747. selector: 'td.record a.title'
  748. },
  749. {
  750. // mobileSearch.do
  751. selector: 'p a.title'
  752. }
  753. ],
  754. 'mojeek': [
  755. {
  756. selector: 'ul.results-standard li h2 a.title'
  757. },
  758. {
  759. selector: 'ul.results-standard li a.ob',
  760. childSelector: 'span.url',
  761. updateChildText: true,
  762. containProtocol: true,
  763. urlDisplayMethod: 1
  764. },
  765. {
  766. selector: 'div.infobox p a'
  767. },
  768. {
  769. selector: 'div.results.news-results li a'
  770. },
  771. {
  772. selector: 'div.right-col div.results ul li a'
  773. }
  774. ],
  775. 'yep': [
  776. {
  777. selector: 'div.css-102xgmn-card div div a',
  778. childSelector: 'div span',
  779. updateChildText: true,
  780. containProtocol: false,
  781. urlDisplayMethod: 1
  782. }
  783. ],
  784. 'torry': [
  785. {
  786. selector: 'div.searpList p a.toranclick',
  787. updateTextByOverwrite: true,
  788. urlDisplayMethod: 2
  789. },
  790. {
  791. selector: 'div.searpList div h2 a.toranclick',
  792. },
  793. {
  794. selector: 'div.searpList ul li a',
  795. }
  796. ],
  797. 'qwant': [
  798. {
  799. selector: 'div._35zId._3A7p7 a.external'
  800. },
  801. {
  802. selector: 'div._35zId._3WA-c a.external',
  803. childSelector: 'span',
  804. updateChildText: true,
  805. containProtocol: false,
  806. multiElementsForUrlDisplay: 1
  807. },
  808. {
  809. // Selector for sub-results
  810. selector: 'div._12BMd div._2-LMx._2E8gc._16lFV.Ks7KS.tCpbb.m_hqb a.external'
  811. },
  812. {
  813. selector: 'div._3McWE.is-sidebar a.external'
  814. }
  815. ],
  816. 'ecosia': [
  817. {
  818. selector: 'div.mainline__result-wrapper div.result__header div.result__info a',
  819. childSelector: 'span span',
  820. updateChildText: true,
  821. containProtocol: true,
  822. multiElementsForUrlDisplay: 1
  823. },
  824. {
  825. selector: 'div.mainline__result-wrapper div.result__header div.result__title a'
  826. },
  827. {
  828. selector: 'div.mainline__result-wrapper div ul li a'
  829. },
  830. {
  831. selector: 'aside.sidebar article div.entity-links ul li a'
  832. },
  833. {
  834. selector: 'aside.sidebar article div.entity__content p a'
  835. }
  836. ],
  837. 'oscobo': [
  838. {
  839. selector: 'div.result a',
  840. childSelector: 'span.siteTitleWrap span.favicons',
  841. updateTextWithoutOverwrite: true,
  842. containProtocol: true,
  843. urlDisplayMethod: 1
  844. }
  845. ],
  846. 'good': [
  847. {
  848. selector: 'div.content div.margin-bottom--small.box a.link--search',
  849. childSelector: 'p.url',
  850. updateTextByOverwrite: true,
  851. urlDisplayMethod: 2
  852. },
  853. {
  854. selector: 'div.sx-kp-top a'
  855. },
  856. {
  857. selector: 'div.sx-kp-tab-content-wrap section ul.sx-kp-social-links a'
  858. },
  859. {
  860. selector: 'div.sx-kp-tab-content-wrap section div.sx-kp-attributions a'
  861. }
  862. ],
  863. 'alltheinternet': [
  864. {
  865. parentSelector: 'div.gs-webResult.gs-result',
  866. linkNodeSelector: 'a.gs-title',
  867. textNodeSelector: 'div.gsc-url-top div.gs-visibleUrl-long',
  868. updateTextByOverwrite: true,
  869. urlDisplayMethod: 2
  870. }
  871. ],
  872. 'aol': [
  873. {
  874. parentSelector: 'div#left div#web ol li div div.compTitle',
  875. linkNodeSelector: 'h3.title a',
  876. textNodeSelector: 'div span',
  877. updateTextByOverwrite: true,
  878. urlDisplayMethod: 3
  879. },
  880. {
  881. selector: 'div#left div#web ol li div div.compList a'
  882. },
  883. {
  884. selector: 'div#right ol.cardReg.searchRightTop a'
  885. }
  886. ],
  887. 'onesearch': [
  888. {
  889. parentSelector: 'div#left div#web ol li div div.compTitle',
  890. linkNodeSelector: 'h3.title a',
  891. textNodeSelector: 'div span',
  892. updateTextByOverwrite: true,
  893. urlDisplayMethod: 3
  894. },
  895. {
  896. selector: 'div#left div#web ol li div div.compList a'
  897. },
  898. {
  899. selector: 'div#right ol.cardReg.searchRightTop a'
  900. }
  901. ],
  902. 'info': [
  903. {
  904. parentSelector: 'div.web-yahoo__result',
  905. linkNodeSelector: 'a.web-yahoo__title',
  906. textNodeSelector: 'span.web-yahoo__url',
  907. updateTextWithoutOverwrite: true,
  908. urlDisplayMethod: 2
  909. },
  910. {
  911. selector: 'div.sidebar-results a'
  912. }
  913. ],
  914. 'oceanhero': [
  915. {
  916. selector: 'div div div a',
  917. childSelector: 'span cite',
  918. updateChildText: true,
  919. containProtocol: false,
  920. urlDisplayMethod: 1
  921. },
  922. {
  923. selector: 'section div ul li a'
  924. },
  925. {
  926. selector: 'div div div p a'
  927. }
  928. ],
  929. 'swisscows': [
  930. {
  931. selector: 'article.item-web a.site',
  932. updateTextWithoutOverwrite: true,
  933. containProtocol: false,
  934. urlDisplayMethod: 1
  935. },
  936. {
  937. selector: 'article.item-web a'
  938. }
  939. ],
  940. 'lilo': [
  941. {
  942. selector: 'div.lilo-text-result div p a.has-text-grey-darker',
  943. childSelector: 'span',
  944. updateChildText: true,
  945. containProtocol: true,
  946. multiElementsForUrlDisplay: 2
  947. },
  948. {
  949. selector: 'div.lilo-text-result div a.has-text-primary'
  950. },
  951. {
  952. selector: 'div.column.is-two-fifths a'
  953. }
  954. ],
  955. 'entireweb': [
  956. {
  957. parentSelector: 'div.web-result',
  958. linkNodeSelector: 'a.web-result-title',
  959. textNodeSelector: 'div.web-result-domain',
  960. updateTextWithoutOverwrite: true,
  961. urlDisplayMethod: 3
  962. },
  963. {
  964. selector: 'div#infobox-list.card div.card-body a'
  965. },
  966. {
  967. parentSelector: 'div.gsc-webResult.gsc-result',
  968. linkNodeSelector: 'a.gs-title',
  969. textNodeSelector: 'div.gsc-url-top',
  970. updateTextByOverwrite: true,
  971. containProtocol: false,
  972. urlDisplayMethod: 1
  973. }
  974. ],
  975. 'gmx': [
  976. {
  977. selector: 'div.eMd a.eMdhl'
  978. },
  979. {
  980. selector: 'div.eMd a.eMdu',
  981. childSelector: 'span',
  982. updateChildText: true,
  983. containProtocol: true,
  984. multiElementsForUrlDisplay: 2
  985. },
  986. ],
  987. 'youcare': [
  988. {
  989. selector: 'div.search-result-item-text a.search-result-item-text__title'
  990. },
  991. {
  992. selector: 'div.search-result-item-text div div a.search-result-item-text-sitename'
  993. },
  994. {
  995. selector: 'div.search-result-item-text div div a.search-result-item-text__header-url',
  996. updateTextWithoutOverwrite: true,
  997. containProtocol: true,
  998. urlDisplayMethod: 1
  999. },
  1000. {
  1001. selector: "div.search-results-view__side a"
  1002. }
  1003. ],
  1004. 'lycos': [
  1005. {
  1006. parentSelector: 'div.results li.result-item',
  1007. linkNodeSelector: 'a.result-link',
  1008. textNodeSelector: 'span.result-url',
  1009. updateTextByOverwrite: true,
  1010. urlDisplayMethod: 3
  1011. },
  1012. {
  1013. selector: 'div.col-aside a'
  1014. }
  1015. ],
  1016. 'alohafind': [
  1017. {
  1018. parentSelector: 'div.gsc-webResult.gsc-result',
  1019. linkNodeSelector: 'a.gs-title',
  1020. textNodeSelector: 'div.gs-visibleUrl-short',
  1021. updateTextByOverwrite: true,
  1022. urlDisplayMethod: 3
  1023. }
  1024. ],
  1025. 'spot': [
  1026. {
  1027. selector: 'div.result h4 a'
  1028. },
  1029. {
  1030. selector: 'div.result a.external-link',
  1031. updateTextByOverwrite: true,
  1032. urlDisplayMethod: 2
  1033. },
  1034. {
  1035. selector: 'div.infobox div.footer div.links a'
  1036. }
  1037. ],
  1038. 'nona': [
  1039. {
  1040. selector: 'section.result-section article.teaser div.teaser__container a.teaser__topline',
  1041. updateTextByOverwrite: true,
  1042. urlDisplayMethod: 2
  1043. },
  1044. {
  1045. selector: 'section.result-section article.teaser div.teaser__container a.teaser__link'
  1046. },
  1047. {
  1048. selector: 'section.result-section article.entity-teaser div.entity-teaser__wrapper a'
  1049. }
  1050. ],
  1051. 'exalead': [
  1052. {
  1053. selector: 'li.media div.media-body a.ellipsis',
  1054. updateTextByOverwrite: true,
  1055. urlDisplayMethod: 3
  1056. },
  1057. {
  1058. selector: 'li.media div.media-body a'
  1059. }
  1060. ],
  1061. 'seznam': [
  1062. {
  1063. selector: 'div.f2c528 h3 a'
  1064. },
  1065. {
  1066. selector: 'div.f2c528 a.d5e75c',
  1067. updateTextByOverwrite: true,
  1068. urlDisplayMethod: 3
  1069. },
  1070. ],
  1071. 'gibiru': [
  1072. {
  1073. parentSelector: 'div.gs-webResult.gs-result',
  1074. linkNodeSelector: 'a.gs-title',
  1075. textNodeSelector: 'div.gsc-url-top div.gs-visibleUrl-breadcrumb',
  1076. childSelector: 'span',
  1077. updateChildText: true,
  1078. containProtocol: false,
  1079. multiElementsForUrlDisplay: 1
  1080. }
  1081. ],
  1082. 'lukol': [
  1083. {
  1084. parentSelector: 'div.gsc-webResult.gsc-result',
  1085. linkNodeSelector: 'a.gs-title',
  1086. textNodeSelector: 'div.gsc-url-bottom div.gs-visibleUrl-long',
  1087. updateTextByOverwrite: true,
  1088. urlDisplayMethod: 2
  1089. }
  1090. ],
  1091. 'givewater': [
  1092. {
  1093. parentSelector: 'div.web-bing__result',
  1094. linkNodeSelector: 'a.web-bing__title',
  1095. textNodeSelector: 'span.web-bing__url',
  1096. updateTextByOverwrite: true,
  1097. urlDisplayMethod: 2
  1098. }
  1099. ],
  1100. 'excite': [
  1101. {
  1102. parentSelector: 'div.web-bing__result',
  1103. linkNodeSelector: 'a.web-bing__title',
  1104. textNodeSelector: 'span.web-bing__url',
  1105. updateTextByOverwrite: true,
  1106. urlDisplayMethod: 2
  1107. }
  1108. ],
  1109. 'webcrawler': [
  1110. {
  1111. parentSelector: 'div.web-bing__result',
  1112. linkNodeSelector: 'a.web-bing__title',
  1113. textNodeSelector: 'span.web-bing__url',
  1114. updateTextByOverwrite: true,
  1115. urlDisplayMethod: 2
  1116. }
  1117. ],
  1118. 'metacrawler': [
  1119. {
  1120. parentSelector: 'div.web-bing__result',
  1121. linkNodeSelector: 'a.web-bing__title',
  1122. textNodeSelector: 'span.web-bing__url',
  1123. updateTextByOverwrite: true,
  1124. urlDisplayMethod: 2
  1125. }
  1126. ],
  1127. 'dogpile': [
  1128. {
  1129. parentSelector: 'div.web-bing__result',
  1130. linkNodeSelector: 'a.web-bing__title',
  1131. textNodeSelector: 'span.web-bing__url',
  1132. updateTextByOverwrite: true,
  1133. urlDisplayMethod: 2
  1134. }
  1135. ]
  1136. // Additional search engines can be defined here...
  1137. };
  1138.  
  1139. // User-defined list of search engine instance URLs
  1140. const searchEngines = {
  1141. 'google': {
  1142. hosts: ['google.com'],
  1143. // search results container
  1144. // you can ignore this parameter if you don't want to set it, just delete it
  1145. // defult value is 'body'
  1146. resultContainerSelectors: ['div.GyAeWb#rcnt']
  1147. },
  1148. 'yahoo': {
  1149. hosts: ['search.yahoo.com'],
  1150. resultContainerSelectors: ['div#results div#cols']
  1151. },
  1152. 'yahoojp': {
  1153. hosts: ['search.yahoo.co.jp'],
  1154. resultContainerSelectors: ['div#contents div#contents__wrap']
  1155. },
  1156. 'yandex': {
  1157. hosts: [
  1158. 'yandex.com',
  1159. 'yandex.ru'
  1160. ],
  1161. resultContainerSelectors: ['div.main__container']
  1162. },
  1163. 'searx': {
  1164. hosts: [
  1165. 'search.disroot.org',
  1166. 'searx.tiekoetter.com',
  1167. 'search.bus-hit.me',
  1168. 'search.inetol.net',
  1169. 'priv.au',
  1170. 'searx.be',
  1171. 'searxng.site',
  1172. 'search.hbubli.cc',
  1173. 'search.im-in.space',
  1174. 'opnxng.com',
  1175. 'search.upinmars.com',
  1176. 'search.sapti.me',
  1177. 'freesearch.club',
  1178. 'xo.wtf',
  1179. 'www.gruble.de',
  1180. 'searx.tuxcloud.net',
  1181. 'baresearch.org',
  1182. 'searx.daetalytica.io',
  1183. 'etsi.me',
  1184. 'search.leptons.xyz',
  1185. 'search.rowie.at',
  1186. 'search.mdosch.de',
  1187. 'searx.catfluori.de',
  1188. 'searx.si',
  1189. 'searx.namejeff.xyz',
  1190. 'search.itstechtime.com',
  1191. 's.mble.dk',
  1192. 'searx.kutay.dev',
  1193. 'ooglester.com',
  1194. 'searx.ox2.fr',
  1195. 'searx.techsaviours.org',
  1196. 'searx.perennialte.ch',
  1197. 's.trung.fun',
  1198. 'search.in.projectsegfau.lt',
  1199. 'search.projectsegfau.lt',
  1200. 'darmarit.org',
  1201. 'searx.lunar.icu',
  1202. 'nyc1.sx.ggtyler.dev',
  1203. 'search.rhscz.eu',
  1204. 'paulgo.io',
  1205. 'northboot.xyz',
  1206. 'searx.zhenyapav.com',
  1207. 'searxng.ch',
  1208. 'copp.gg',
  1209. 'searx.sev.monster',
  1210. 'searx.oakleycord.dev',
  1211. 'searx.juancord.xyz',
  1212. 'searx.work',
  1213. 'search.ononoki.org',
  1214. 'search.demoniak.ch',
  1215. 'searx.cthd.icu',
  1216. 'searx.fmhy.net',
  1217. 'searx.headpat.exchange',
  1218. 'sex.finaltek.net',
  1219. 'search.gcomm.ch',
  1220. 'search.smnz.de',
  1221. 'searx.ankha.ac',
  1222. 'search.lvkaszus.pl',
  1223. 'searx.nobulart.com',
  1224. 'sx.t-1.org',
  1225. 'www.jabber-germany.de',
  1226. 'sx.catgirl.cloud'
  1227. ],
  1228. resultContainerSelectors: [
  1229. 'main#main_results'
  1230. // 'maindiv#main_results div#urls'
  1231. // 'div#sidebar div#infoboxes'
  1232. ]
  1233. },
  1234. 'startpage': {
  1235. hosts: ['startpage.com'],
  1236. resultContainerSelectors: [
  1237. 'div.show-results',
  1238. ]
  1239. },
  1240. 'brave': {
  1241. hosts: ['search.brave.com'],
  1242. resultContainerSelectors: [
  1243. 'main.main-column',
  1244. 'aside.sidebar'
  1245. ]
  1246. },
  1247. 'duckduckgo': {
  1248. hosts: ['duckduckgo.com'],
  1249. resultContainerSelectors: [
  1250. 'section[data-testid="mainline"][data-area="mainline"]',
  1251. 'section[data-testid="sidebar"][data-area="sidebar"]'
  1252. ]
  1253. },
  1254. 'ghostery': {
  1255. hosts: ['ghosterysearch.com'],
  1256. resultContainerSelectors: ['section.results']
  1257. },
  1258. 'presearch': {
  1259. hosts: ['presearch.com'],
  1260. resultContainerSelectors: ['div.w-full']
  1261. },
  1262. 'metager': {
  1263. hosts: [
  1264. 'metager.org',
  1265. 'metager.de'
  1266. ],
  1267. resultContainerSelectors: [
  1268. 'div#results',
  1269. 'div#additions-container'
  1270. ]
  1271. },
  1272. '4get': {
  1273. hosts: [
  1274. '4get.ca',
  1275. '4get.silly.computer',
  1276. '4get.plunked.party',
  1277. '4get.konakona.moe',
  1278. '4get.sijh.net',
  1279. '4get.hbubli.cc',
  1280. '4get.perennialte.ch',
  1281. '4get.zzls.xyz',
  1282. '4getus.zzls.xyz',
  1283. '4get.seitan-ayoub.lol',
  1284. '4get.dcs0.hu',
  1285. '4get.psily.garden',
  1286. '4get.lvkaszus.pl',
  1287. '4get.kizuki.lol'
  1288. ],
  1289. resultContainerSelectors: ['div#overflow']
  1290. },
  1291. 'librey': {
  1292. hosts: [
  1293. 'search.ahwx.org',
  1294. 'search2.ahwx.org',
  1295. 'search3.ahwx.org',
  1296. 'ly.owo.si',
  1297. 'librey.franklyflawless.org',
  1298. 'librey.org',
  1299. 'search.davidovski.xyz',
  1300. 'search.milivojevic.in.rs',
  1301. 'glass.prpl.wtf',
  1302. 'librex.uk.to',
  1303. 'librey.ix.tc',
  1304. 'search.funami.tech',
  1305. 'librex.retro-hax.net',
  1306. 'librex.nohost.network',
  1307. 'search.pabloferreiro.es',
  1308. 'librey.baczek.me',
  1309. 'lx.benike.me',
  1310. 'search.seitan-ayoub.lol',
  1311. 'librey.myroware.net',
  1312. 'librey.nezumi.party',
  1313. 'search.zeroish.xyz',
  1314. 'search.zeroish.xyz'
  1315. ],
  1316. resultContainerSelectors: [
  1317. 'div.text-result-container',
  1318. 'p.special-result-container'
  1319. ]
  1320. },
  1321. 'stract': {
  1322. hosts: ['stract.com'],
  1323. resultContainerSelectors: [
  1324. 'div.col-start-1',
  1325. 'div.row-start-2'
  1326. ]
  1327. },
  1328. 'etools': {
  1329. hosts: ['etools.ch'],
  1330. // resultContainerSelectors: ['table.result']
  1331. },
  1332. 'mojeek': {
  1333. hosts: ['mojeek.com'],
  1334. resultContainerSelectors: ['div.container.serp-results']
  1335. },
  1336. 'yep': {
  1337. hosts: ['yep.com']
  1338. },
  1339. 'torry': {
  1340. hosts: ['torry.io'],
  1341. resultContainerSelectors: ['div.searpListouterappend'],
  1342. attribute: 'data-target'
  1343. },
  1344. 'qwant': {
  1345. hosts: ['qwant.com'],
  1346. resultContainerSelectors: ['div._35zId']
  1347. },
  1348. 'ecosia': {
  1349. hosts: ['ecosia.org'],
  1350. resultContainerSelectors: [
  1351. 'section.mainline.web__mainline',
  1352. 'aside.sidebar.web__sidebar'
  1353. ]
  1354. },
  1355. 'oscobo': {
  1356. hosts: ['search.becovi.com'],
  1357. resultContainerSelectors: ['div#results.col']
  1358. },
  1359. 'good': {
  1360. hosts: ['good-search.org'],
  1361. resultContainerSelectors: [
  1362. 'div.grid__item.two-thirds',
  1363. 'div.grid__item.one-third'
  1364. ]
  1365. },
  1366. 'alltheinternet': {
  1367. hosts: ['alltheinternet.com']
  1368. },
  1369. 'aol': {
  1370. hosts: ['search.aol.com'],
  1371. resultContainerSelectors: ['div#results div#cols']
  1372. },
  1373. 'onesearch': {
  1374. hosts: ['onesearch.com'],
  1375. resultContainerSelectors: ['div#results div#cols']
  1376. },
  1377. 'info': {
  1378. hosts: ['info.com'],
  1379. resultContainerSelectors: ['div.layout__body']
  1380. },
  1381. 'oceanhero': {
  1382. hosts: ['oceanhero.today']
  1383. },
  1384. 'swisscows': {
  1385. hosts: ['swisscows.com'],
  1386. resultContainerSelectors: ['section.container.page-results']
  1387. },
  1388. 'lilo': {
  1389. hosts: ['search.lilo.org'],
  1390. resultContainerSelectors: ['div.container#content']
  1391. },
  1392. 'entireweb': {
  1393. hosts: ['search.entireweb.com'],
  1394. resultContainerSelectors: ['div.container.search-container']
  1395. },
  1396. 'gmx': {
  1397. hosts: ['search.gmx.com']
  1398. },
  1399. 'youcare': {
  1400. hosts: ['youcare.world']
  1401. },
  1402. 'lycos': {
  1403. hosts: ['search.lycos.com'],
  1404. resultContainerSelectors: ['div.content.con-search']
  1405. },
  1406. 'alohafind': {
  1407. hosts: ['alohafind.com'],
  1408. resultContainerSelectors: ['section.layout']
  1409. },
  1410. 'spot': {
  1411. hosts: ['spot.ecloud.global'],
  1412. resultContainerSelectors: ['div.container.contents']
  1413. },
  1414. 'nona': {
  1415. hosts: ['nona.de'],
  1416. resultContainerSelectors: ['main.search-results div.container']
  1417. },
  1418. 'exalead': {
  1419. hosts: ['exalead.com'],
  1420. resultContainerSelectors: ['ul.media-list']
  1421. },
  1422. 'seznam': {
  1423. hosts: ['search.seznam.cz'],
  1424. resultContainerSelectors: ['div.PageWrapper.SearchPage#searchpage-root'],
  1425. },
  1426. 'gibiru': {
  1427. hosts: ['gibiru.com'],
  1428. resultContainerSelectors: ['div.container#web-results'],
  1429. },
  1430. 'lukol': {
  1431. hosts: ['lukol.com']
  1432. },
  1433. 'givewater': {
  1434. hosts: ['search.givewater.com'],
  1435. resultContainerSelectors: ['div.mainline-results']
  1436. },
  1437. 'excite': {
  1438. hosts: ['results.excite.com'],
  1439. resultContainerSelectors: ['div.mainline-results']
  1440. },
  1441. 'webcrawler': {
  1442. hosts: ['webcrawler.com'],
  1443. resultContainerSelectors: ['div.web-bing'],
  1444. },
  1445. 'metacrawler': {
  1446. hosts: ['metacrawler.com'],
  1447. resultContainerSelectors: ['div.web-bing'],
  1448. },
  1449. 'dogpile': {
  1450. hosts: ['dogpile.com'],
  1451. resultContainerSelectors: ['div.web-bing'],
  1452. }
  1453. // ... more search engines
  1454. };
  1455.  
  1456. // Function to modify URLs and optionally text
  1457. const modifyUrls = (engine, observer, resultContainer, engineInfo) => {
  1458. try {
  1459. const selectors = selectorRules[engine];
  1460. if (selectors) {
  1461. // Disconnect the observer to prevent recursive triggering
  1462. observer.disconnect();
  1463.  
  1464. // Modify results
  1465. selectors.forEach(rule => {
  1466. if (rule.selector) {
  1467. processElements(rule.selector, rule, engineInfo);
  1468. } else if (rule.parentSelector) {
  1469. processParentElements(rule.parentSelector, rule, engineInfo);
  1470. }
  1471. });
  1472.  
  1473. // Reconnect the observer after DOM modifications are done
  1474. observer.observe(resultContainer, { childList: true, subtree: true });
  1475. }
  1476. } catch (error) {
  1477. console.error("URL Modification Error: ", error);
  1478. }
  1479. };
  1480.  
  1481. // Function to process elements specified by `selector`
  1482. const processElements = (selector, rule, engineInfo) => {
  1483. const elements = document.querySelectorAll(selector);
  1484. const additionalAttribute = engineInfo.attribute; // Get the additional attribute if specified
  1485. if (elements.length > 0) {
  1486. elements.forEach(element => {
  1487. for (let i = 0; i < urlModificationRules.length; i++) {
  1488. try {
  1489. const urlRule = urlModificationRules[i];
  1490. let urlToModify = additionalAttribute ? element.getAttribute(additionalAttribute) : element.href;
  1491. urlToModify = decodeURIComponent(urlToModify);
  1492. // update attribute
  1493. if (urlToModify && urlRule.matchRegex.test(urlToModify)) {
  1494. // Generate redirected URL
  1495. let newUrl = urlToModify.replace(urlRule.matchRegex, urlRule.replaceWith);
  1496. newUrl = rule.useTopLevelDomain ? extractTopLevelDomain(newUrl) : newUrl;
  1497. if (element.href) {
  1498. element.href = newUrl;
  1499. } else if (additionalAttribute) {
  1500. element.setAttribute(additionalAttribute, newUrl);
  1501. }
  1502. updateTextContent(element, rule, removeTailingSlash(removeParameters(newUrl)));
  1503. break;
  1504. }
  1505. } catch (error) {
  1506. console.error("Update Link/Text Error: ", error);
  1507. }
  1508. }
  1509. });
  1510. }
  1511. };
  1512.  
  1513. // Function to process elements specified by `parentSelector`
  1514. const processParentElements = (selector, rule, engineInfo) => {
  1515. const elements = document.querySelectorAll(selector);
  1516. const additionalAttribute = engineInfo.attribute; // Get the additional attribute if specified
  1517. if (elements.length > 0) {
  1518. elements.forEach(element => {
  1519. const linkElement = element.querySelector(rule.linkNodeSelector);
  1520. const textElement = element.querySelector(rule.textNodeSelector);
  1521.  
  1522. for (let i = 0; i < urlModificationRules.length; i++) {
  1523. try {
  1524. const urlRule = urlModificationRules[i];
  1525. let urlToModify = additionalAttribute ? element.getAttribute(additionalAttribute) : linkElement.href;
  1526. urlToModify = decodeURIComponent(urlToModify);
  1527. // update attribute
  1528. if (urlToModify && urlRule.matchRegex.test(urlToModify)) {
  1529. // Generate redirected URL
  1530. let newUrl = urlToModify.replace(urlRule.matchRegex, urlRule.replaceWith);
  1531. newUrl = rule.useTopLevelDomain ? extractTopLevelDomain(newUrl) : newUrl;
  1532. if (linkElement.href) {
  1533. linkElement.href = newUrl;
  1534. } else if (additionalAttribute) {
  1535. linkElement.setAttribute(additionalAttribute, newUrl);
  1536. }
  1537. updateTextContent(textElement, rule, removeTailingSlash(removeParameters(newUrl)));
  1538. break;
  1539. }
  1540. } catch (error) {
  1541. console.error("Update Link/Text Error: ", error);
  1542. }
  1543. }
  1544. });
  1545. }
  1546. };
  1547.  
  1548. // Function to update text content (displayed URL)
  1549. const updateTextContent = (element, rule, newUrl) => {
  1550. if (rule.updateChildText || rule.updateTextWithoutOverwrite || rule.updateTextByOverwrite) {
  1551. try {
  1552. if (rule.multiElementsForUrlDisplay) {
  1553. updateMultiElementContent(element, rule, newUrl);
  1554. } else {
  1555. const targetElement = rule.childSelector ? element.querySelector(rule.childSelector) : element;
  1556. updateSingleElementText(targetElement, rule, newUrl);
  1557. }
  1558. } catch (error) {
  1559. console.error("Update Displayed URL Error: ", error);
  1560. }
  1561. }
  1562. };
  1563.  
  1564. // Function to update text for multi elements (e.g. DuckDuckGo, Brave)
  1565. const updateMultiElementContent = (targetElement, rule, newUrl) => {
  1566. if (!targetElement) {
  1567. console.error("Target DOM Element not found for Multi-Element Text update!");
  1568. return;
  1569. }
  1570. // Remove the "https://" protocol if containProtocol is false
  1571. newUrl = rule.containProtocol ? newUrl : removeProtocol(newUrl);
  1572. let formattedUrl = breadCumbFormat(newUrl, rule.containProtocol);
  1573. let urlParts = formattedUrl.split(' › ');
  1574.  
  1575. const spans = targetElement.querySelectorAll(rule.childSelector)
  1576.  
  1577. switch (rule.multiElementsForUrlDisplay) {
  1578. case 1:
  1579. parallelElements(urlParts, spans);
  1580. break;
  1581. case 2:
  1582. mixedElements(urlParts, spans, targetElement);
  1583. break;
  1584. case 3:
  1585. mixedElementsWithoutClear(urlParts, spans, targetElement);
  1586. break;
  1587. }
  1588. };
  1589.  
  1590. const parallelElements = (urlParts, elements) => {
  1591. if (elements && elements.length >= 2) {
  1592. elements.forEach(clearElementContent);
  1593. elements[0].textContent = urlParts[0]; // Update the first part
  1594. elements[1].textContent = ' › ' + urlParts.slice(1).join(' › '); // Update the second part
  1595. } else {
  1596. console.error("Script: Expected structure not found for Multi-Element (parallel elements) URL update!");
  1597. }
  1598. };
  1599.  
  1600. const mixedElements = (urlParts, elements, parent) => {
  1601. if (elements && elements.length >= 1) {
  1602. elements.forEach(clearElementContent);
  1603. updateTextWithoutOverwriteChildNodes(parent, urlParts[0]); // Update the first part
  1604. elements[0].textContent = ' › ' + urlParts.slice(1).join(' › '); // Update the second part
  1605. } else {
  1606. console.error("Script: Expected structure not found for Multi-Element (mixed elements) URL update!");
  1607. }
  1608. };
  1609.  
  1610. const mixedElementsWithoutClear = (urlParts, elements, parent) => {
  1611. if (elements && elements.length >= 1) {
  1612. updateTextWithoutOverwriteChildNodes(parent, urlParts[0]); // Update the first part
  1613. elements[0].textContent = ' › ' + urlParts.slice(1).join(' › '); // Update the second part
  1614. } else {
  1615. console.error("Script: Expected structure not found for Multi-Element (mixed elements with clear) URL update!");
  1616. }
  1617. };
  1618.  
  1619. // Function to update text for a single element
  1620. const updateSingleElementText = (targetElement, rule, newUrl) => {
  1621. if (!targetElement) {
  1622. console.error("Target DOM Element not found for Single-Element Text update!");
  1623. return;
  1624. }
  1625. let formattedUrl = '';
  1626. switch (rule.urlDisplayMethod) {
  1627. case 1:
  1628. formattedUrl = breadCumbFormat(newUrl, rule.containProtocol);
  1629. break;
  1630. case 2:
  1631. formattedUrl = newUrl; // Full URL with protocol
  1632. break;
  1633. case 3:
  1634. formattedUrl = decodeURIComponent(removeProtocol(newUrl)); // Full URL without protocol
  1635. break;
  1636. }
  1637. if (rule.updateTextWithoutOverwrite) {
  1638. updateTextWithoutOverwriteChildNodes(targetElement, formattedUrl);
  1639. } else if (rule.updateTextByOverwrite) {
  1640. updateTextByOverwriteEverything(targetElement, formattedUrl);
  1641. } else {
  1642. targetElement.textContent = formattedUrl;
  1643. }
  1644. };
  1645.  
  1646. // Function for Method 1 (Breadcrumb style URLs), leaving 'https://' intact
  1647. const breadCumbFormat = (url, containProtocol) => {
  1648. if (!containProtocol) {
  1649. url = removeProtocol(url);
  1650. }
  1651. // Split the URL while keeping 'https://' intact; Replace the second occurrence of 'https://' with 'https', if exists
  1652. // Replace the first occurrence of 'https://' with a placeholder
  1653. url = url.replace('https://', 'https › ');
  1654. // Deal with the second 'https://'
  1655. let secondHttpsIndex = url.indexOf('https://');
  1656. if (secondHttpsIndex !== -1) {
  1657. url = url.substring(0, secondHttpsIndex) + 'https › ' + url.substring(secondHttpsIndex + 8);
  1658. }
  1659. // Split the URL with '/'
  1660. let parts = url.split('/');
  1661. // Restore the first 'https://' in the URL
  1662. parts[0] = parts[0].replace('https › ', 'https://');
  1663.  
  1664. // Join the URL parts with ' › '
  1665. let joinedUrl = parts.join(' › ');
  1666.  
  1667. // Decode the URL to convert encoded characters to their original form
  1668. return decodeURIComponent(joinedUrl);
  1669. };
  1670.  
  1671. // Function to update only the text node within an element, leave the child elements, if exist, intact
  1672. const updateTextWithoutOverwriteChildNodes = (element, newContent) => {
  1673. let currentIndex = 0;
  1674. const indexObject = { currentIndex };
  1675. collectNodes(element, node => {
  1676. if (currentIndex >= newContent.length) return; // Stop if we've used all the new content
  1677. replaceTextContent(node, oldText => replaceTextBasedOnIndex(oldText, newContent, indexObject));
  1678. });
  1679. };
  1680.  
  1681. const collectNodes = (node, callback) => {
  1682. // View these elements as text node
  1683. const elementsToIncludeAsText = ['B'];
  1684. // Do not view these elements as text node
  1685. const elementsToExcludeAsText = ['H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'DIV', 'P'];
  1686.  
  1687. if (node.nodeType === Node.TEXT_NODE) {
  1688. callback(node);
  1689. } else if (node.nodeType === Node.ELEMENT_NODE && elementsToIncludeAsText.includes(node.tagName.toUpperCase())) {
  1690. callback(node);
  1691. } else if (node.nodeType === Node.ELEMENT_NODE && !elementsToExcludeAsText.includes(node.tagName.toUpperCase())) {
  1692. node.childNodes.forEach(child => collectNodes(child, callback));
  1693. }
  1694. };
  1695.  
  1696. const replaceTextContent = (node, textUpdater) => {
  1697. if (node.nodeType === Node.TEXT_NODE) {
  1698. node.nodeValue = textUpdater(node.nodeValue);
  1699. } else if (node.innerHTML) { // For elements treated as text, like <b>
  1700. node.innerHTML = textUpdater(node.innerHTML);
  1701. }
  1702. };
  1703.  
  1704. const replaceTextBasedOnIndex = (oldText, newContent, indexObject) => {
  1705. const newText = newContent.slice(indexObject.currentIndex, indexObject.currentIndex + oldText.length);
  1706. indexObject.currentIndex += oldText.length;
  1707. return newText;
  1708. };
  1709.  
  1710. // Function to update the content by overwriting everything
  1711. const updateTextByOverwriteEverything = (element, newContent) => {
  1712. clearElementContent(element);
  1713. element.textContent = newContent;
  1714. };
  1715.  
  1716. // Extract the top level domain from URL link
  1717. const extractTopLevelDomain = (url) => {
  1718. const parsedUrl = new URL(url);
  1719. return `${parsedUrl.protocol}//${parsedUrl.hostname}/`;
  1720. };
  1721.  
  1722. // Remove 'https://' from the URL link
  1723. const removeProtocol = (url) => {
  1724. return url.replace(/^https?:\/\//, '');
  1725. };
  1726.  
  1727. // Remove parameters (the part behind ?) in the URL link
  1728. const removeParameters = (url) => {
  1729. return url.split('?')[0];
  1730. };
  1731.  
  1732. // Remove tailing slash '/'
  1733. const removeTailingSlash = (url) => {
  1734. // Check if the URL ends with a slash and remove it if present
  1735. return url.endsWith('/') ? url.slice(0, -1) : url;
  1736. };
  1737.  
  1738. // Function to clear existing content of an element
  1739. const clearElementContent = (element) => {
  1740. element.textContent = '';
  1741. };
  1742.  
  1743. // Improved function to determine the search engine
  1744. const getSearchEngineInfo = () => {
  1745. try {
  1746. const host = window.location.host;
  1747. for (const engine in searchEngines) {
  1748. if (searchEngines[engine].hosts.some(instanceHost => host.includes(instanceHost))) {
  1749. // Default to 'body' if not specified
  1750. const selectors = searchEngines[engine].resultContainerSelectors || ['body'];
  1751. // Get the attribute if specified
  1752. const attribute = searchEngines[engine].attribute;
  1753. return {
  1754. engine,
  1755. selectors: selectors,
  1756. attribute: attribute
  1757. };
  1758. }
  1759. }
  1760. } catch (error) {
  1761. console.error("Error determining search engine: ", error);
  1762. }
  1763. };
  1764.  
  1765. const observeToExecute = (engine, selector, engineInfo) => {
  1766. const resultContainers = document.querySelectorAll(selector);
  1767. if (resultContainers) {
  1768. resultContainers.forEach(resultContainer => {
  1769. // Observe changes in each result container
  1770. const observer = new MutationObserver(() => modifyUrls(engine, observer, resultContainer, engineInfo));
  1771. observer.observe(resultContainer, { childList: true, subtree: true });
  1772. modifyUrls(engine, observer, resultContainer, engineInfo);
  1773. });
  1774. }
  1775. };
  1776.  
  1777. // Run the script for the current search engine
  1778. try {
  1779. const engineInfo = getSearchEngineInfo();
  1780. if (engineInfo) {
  1781. engineInfo.selectors.forEach(containerSelector => {
  1782. observeToExecute(engineInfo.engine, containerSelector, engineInfo);
  1783. });
  1784. }
  1785. } catch (error) {
  1786. console.error("Error executing URL Modifier Script: ", error);
  1787. }
  1788. })();