隐私重定向器

将社交媒体平台重定向到其隐私友好的首页

目前为 2024-02-28 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Privacy Redirector
  3. // @name:bg Пренасочване на поверителността
  4. // @name:br Rediretor de privacidade
  5. // @name:cs Přesměrování soukromí
  6. // @name:de Datenschutz Umleiter
  7. // @name:da Omdirigeringsenhed for privatlivets fred
  8. // @name:et Privaatsuse ümbersuunaja
  9. // @name:es Redirección de privacidad
  10. // @name:fi Yksityisyydensuojan uudelleenohjaus
  11. // @name:fr Redirecteur de confidentialité
  12. // @name:el Επανακατευθυντής απορρήτου
  13. // @name:hu Adatvédelmi átirányító
  14. // @name:id Pengarah Privasi
  15. // @name:it Reindirizzatore di privacy
  16. // @name:ja プライバシーリダイレクト
  17. // @name:lt Privatumo nukreipiklis
  18. // @name:lv Konfidencialitātes pāradresētājs
  19. // @name:nl Privacy-omleiding
  20. // @name:pl Przekierownik prywatności
  21. // @name:pt Redirector de Privacidade
  22. // @name:ro Redirector de confidențialitate
  23. // @name:ru Перенаправление конфиденциальности
  24. // @name:sv Omdirigering av sekretess
  25. // @name:sl Preusmerjevalnik zasebnosti
  26. // @name:sk Presmerovanie súkromia
  27. // @name:tr Gizlilik Yönlendiricisi
  28. // @name:uk Редиректор конфіденційності
  29. // @name:zh 隐私重定向器
  30. // @name:zh-CN 隐私重定向器
  31. // @description Redirect social media platforms to their privacy respecting frontends
  32. // @description:bg Пренасочване на платформите за социални медии към заглавните им страници, съобразени с поверителността
  33. // @description:br Redirecionando as plataformas de mídia social para suas primeiras páginas de privacidade
  34. // @description:cs Přesměrování platforem sociálních médií na jejich titulní stránky šetrné k soukromí
  35. // @description:de Leitet von Social-Media-Plattformen auf deren jeweilige datenschutzfreundlicheren Frontends
  36. // @description:da Omdirigering af sociale medieplatforme til deres privatlivsvenlige forsider
  37. // @description:et Sotsiaalmeediaplatvormide ümbersuunamine nende privaatsussõbralikele esilehtedele
  38. // @description:es Redirigir las plataformas de medios sociales a sus portadas respetuosas con la privacidad
  39. // @description:fi Sosiaalisen median alustojen ohjaaminen yksityisyyden suojaa edistäville etusivuille.
  40. // @description:fr Rediriger les plateformes de médias sociaux vers leurs pages d'accueil respectueuses de la vie privée
  41. // @description:el Αναπροσανατολισμός των πλατφορμών κοινωνικής δικτύωσης στις μπροστινές σελίδες τους που είναι φιλικές προς το απόρρητο
  42. // @description:hu A közösségi médiaplatformok átirányítása az adatvédelem-barát kezdőlapokra
  43. // @description:id Mengarahkan platform media sosial ke halaman depan yang ramah privasi
  44. // @description:it Reindirizzare le piattaforme di social media verso le loro pagine frontali che rispettano la privacy
  45. // @description:ja ソーシャルメディアプラットフォームをプライバシーに配慮したフロントページにリダイレクトする
  46. // @description:lt Socialinės žiniasklaidos platformų nukreipimas į privatumą užtikrinančius pirmuosius puslapius
  47. // @description:lv Sociālo plašsaziņas līdzekļu platformu pāradresēšana uz to privātumam draudzīgajām pirmajām lapām.
  48. // @description:nl Sociale-mediaplatforms omleiden naar hun privacyvriendelijke voorpagina's
  49. // @description:pl Przekierowanie platform mediów społecznościowych na ich przyjazne dla prywatności strony tytułowe
  50. // @description:pt Redireccionar as plataformas de redes sociais para as suas primeiras páginas amigas da privacidade
  51. // @description:ro Redirecționarea platformelor de socializare către paginile lor de început care respectă viața privată
  52. // @description:ru Перенаправление платформ социальных сетей на их главные страницы, дружественные к конфиденциальности
  53. // @description:sv Omdirigera sociala medieplattformar till deras integritetsvänliga förstasidor.
  54. // @description:sl preusmeritev platform družabnih medijev na njihove naslovne strani, ki so prijazne do zasebnosti.
  55. // @description:sk Presmerovanie platforiem sociálnych médií na ich úvodné stránky, ktoré chránia súkromie
  56. // @description:tr Sosyal medya platformlarını, gizliliğe saygı duyan önyüzlerine yönlendirir
  57. // @description:uk Перенаправлення соціальних медіа-платформ на їхні головні сторінки, дружні до приватності
  58. // @description:zh 将社交媒体平台重定向到其隐私友好的首页
  59. // @description:zh-CN 将社交媒体平台重定向到其隐私友好的首页
  60. // @namespace https://github.com/dybdeskarphet/privacy-redirector
  61. // @author Ahmet Arda Kavakcı
  62. // @license GPLv3
  63. // @version 1.5.5
  64. // @supportURL https://github.com/dybdeskarphet/privacy-redirector
  65. // @run-at document-start
  66. // @match *://*.bandcamp.com/*
  67. // @match *://*.fandom.com/*
  68. // @match *://*.genius.com/*
  69. // @match *://*.google.com/*
  70. // @match *://*.imdb.com/*
  71. // @match *://*.imgur.com/*
  72. // @match *://*.imgur.io/*
  73. // @match *://*.instagram.com/*
  74. // @match *://*.medium.com/*
  75. // @match *://*.pinterest.com/*
  76. // @match *://*.quora.com/*
  77. // @match *://*.reddit.com/*
  78. // @match *://*.reuters.com/*
  79. // @match *://*.soundcloud.com/*
  80. // @match *://*.tiktok.com/*
  81. // @match *://*.twitch.tv/*
  82. // @match *://twitch.tv/*
  83. // @match *://*.twitter.com/*
  84. // @match *://*.wikipedia.org/*
  85. // @match *://*.youtube-nocookie.com/*
  86. // @match *://*.youtube.com/*
  87. // @match *://f4.bcbits.com/*
  88. // @match *://genius.com/*
  89. // @match *://i.pinimg.com/*
  90. // @match *://imgur.com/*
  91. // @match *://instagram.com/*
  92. // @match *://medium.com/*
  93. // @match *://news.ycombinator.com/*
  94. // @match *://reddit.com/*
  95. // @match *://stackoverflow.com/*
  96. // @match *://t4.bcbits.com/*
  97. // @match *://translate.google.com/*
  98. // @match *://twitter.com/*
  99. // @match *://www.goodreads.com/*
  100. // @match *://www.pixiv.net/*
  101. // @match *://youtube.com/*
  102. // @exclude *://*.youtube.com/redirect*
  103. // @exclude *://youtube.com/redirect*
  104. // ==/UserScript==
  105.  
  106. /*
  107. ___ _ _ ___ _____ _____
  108. / _ \| \ | | / _ \| ___| ___|
  109. | | | | \| |_____| | | | |_ | |_
  110. | |_| | |\ |_____| |_| | _| | _|
  111. \___/|_| \_| \___/|_| |_|
  112.  
  113. CHANGE THE RELEVANT VALUE TO "false" TO
  114. DISABLE THE REDIRECTION/FARSIDE FOR THAT
  115. PARTICULAR PLATFORM */
  116.  
  117. // REDIRECTON / FARSIDE
  118.  
  119. let bandcamp = [true, true];
  120. let fandom = [true, true];
  121. let genius = [true, true];
  122. let goodreads = [true, false];
  123. let google = [true, true];
  124. let gtranslate = [true, true];
  125. let hackernews = [true, true];
  126. let imdb = [true, true];
  127. let imgur = [true, false];
  128. let medium = [true, true];
  129. let pinterest = [true, true];
  130. let pixiv = [true, true];
  131. let quora = [true, false];
  132. let reddit = [true, false];
  133. let reuters = [true, true];
  134. let soundcloud = [true, true];
  135. let stackoverflow = [true, true];
  136. let tiktok = [true, false];
  137. let twitter = [true, true];
  138. let wikipedia = [true, false];
  139. let youtube = [true, false];
  140. let twitch = [true, true];
  141. let instagram = [true, true];
  142.  
  143. // PREFERRED FRONTEND
  144. let youtubeFrontend = "piped"; // accepts "invidious", "piped", "tubo"
  145. let youtubeMusicFrontend = "hyperpipe"; // accepts "hyperpipe", "invidious", "piped"
  146. let redditFrontend = "libreddit"; // accepts "libreddit", "teddit"
  147. let googleFrontend = "librey"; // accepts "librey", "searx", "searxng"
  148. let geniusFrontend = "intellectual"; // accepts dumb, intellectual
  149. let mediumFrontend = "scribe"; // accepts libmedium, scribe, mediumrip
  150. let hackernewsFrontend = "better"; // accepts better, worker
  151.  
  152. // OTHER SETTINGS
  153. let keepHistory = false; // keeps farside.link in the browser history
  154.  
  155. // // // // // // // // // // // // //
  156.  
  157. /*
  158. ___ _
  159. |_ _|_ __ ___| |_ __ _ _ __ ___ ___ ___
  160. | || '_ \/ __| __/ _` | '_ \ / __/ _ \/ __|
  161. | || | | \__ \ || (_| | | | | (_| __/\__ \
  162. |___|_| |_|___/\__\__,_|_| |_|\___\___||___/
  163.  
  164. LIST OF INSTANCES TO USE IF FARSIDE IS NOT ENABLED
  165. */
  166.  
  167. const Instances = {
  168. anonymousoverflow: [
  169. "code.whatever.social",
  170. "ao.vern.cc",
  171. "overflow.smnz.de",
  172. "overflow.lunar.icu",
  173. "overflow.adminforge.de",
  174. "overflow.projectsegfau.lt",
  175. "ao.bloat.cat",
  176. "anonoverflow.frontendfriendly.xyz",
  177. "ao.owo.si",
  178. "overflow.datura.network",
  179. "overflow.freedit.eu",
  180. "ao.rootdo.org",
  181. "anonoverflow.hyperreal.coffee",
  182. "a.opnxng.com",
  183. "overflow.sudovanilla.com",
  184. "anonymousoverflow.privacyfucking.rocks",
  185. "exchange.seitan-ayoub.lol",
  186. "overflow.r4fo.com",
  187. ],
  188. hyperpipe: [
  189. "hyperpipe.surge.sh",
  190. "hyperpipe.onrender.com",
  191. "hyperpipe.esmailelbob.xyz",
  192. "music.adminforge.de",
  193. "music.pfcd.me",
  194. "hyperpipe.projectsegfau.lt",
  195. "hp.ggtyler.dev",
  196. "hyperpipe.lunar.icu",
  197. "music.seitan-ayoub.lol",
  198. ],
  199. proxigram: [
  200. "proxigram.privacyfrontends.repl.co",
  201. "proxigram.protokolla.fi",
  202. "proxigram.kyun.li",
  203. "proxigram.lunar.icu",
  204. "ig.opnxng.com",
  205. ],
  206. biblioreads: [
  207. "biblioreads.eu.org",
  208. "biblioreads.vercel.app",
  209. "biblioreads.mooo.com",
  210. "bl.vern.cc",
  211. "biblioreads.lunar.icu",
  212. "biblioreads.privacyfucking.rocks",
  213. "read.seitan-ayoub.lol",
  214. ],
  215. binternet: [
  216. "binternet.ahwx.org",
  217. "bn.bloat.cat",
  218. "bn.opnxng.com",
  219. "binternet.privacyfucking.rocks",
  220. "bn.vern.cc",
  221. "binternet.esmailelbob.xyz",
  222. ],
  223. breezewiki: [
  224. "breezewiki.com",
  225. "antifandom.com",
  226. "breezewiki.pussthecat.org",
  227. "bw.hamstro.dev",
  228. "bw.projectsegfau.lt",
  229. "breeze.hostux.net",
  230. "bw.artemislena.eu",
  231. "nerd.whatever.social",
  232. "breezewiki.frontendfriendly.xyz",
  233. "breeze.nohost.network",
  234. "z.opnxng.com",
  235. "breezewiki.hyperreal.coffee",
  236. "breezewiki.catsarch.com",
  237. "breeze.mint.lgbt",
  238. "breezewiki.woodland.cafe",
  239. "breezewiki.lunar.icu",
  240. "fandom.adminforge.de",
  241. ],
  242. dumb: [
  243. "dumb.privacydev.net",
  244. "db.vern.cc",
  245. "sing.whatever.social",
  246. "dumb.lunar.icu",
  247. "dumb.esmailelbob.xyz",
  248. ],
  249. intellectual: [
  250. "intellectual.insprill.net",
  251. "in.bloat.cat",
  252. "intellectual.privacyfucking.rocks",
  253. "intellectual.frontendfriendly.xyz",
  254. ],
  255. invidious: [
  256. "yewtu.be",
  257. "vid.puffyan.us",
  258. "yt.artemislena.eu",
  259. "invidious.flokinet.to",
  260. "invidious.projectsegfau.lt",
  261. "invidious.slipfox.xyz",
  262. "invidious.privacydev.net",
  263. "vid.priv.au",
  264. "iv.ggtyler.dev",
  265. "invidious.lunar.icu",
  266. "inv.tux.pizza",
  267. "invidious.protokolla.fi",
  268. "proxied.invidious.fi",
  269. "onion.tube",
  270. "invidious.no-logs.com",
  271. "invidious.io.lol",
  272. "iv.nboeck.de",
  273. "invidious.private.coffee",
  274. "invidious.asir.dev",
  275. "iv.datura.network",
  276. "invidious.fdn.fr",
  277. "invidious.perennialte.ch",
  278. "yt.cdaut.de",
  279. "invidious.einfachzocken.eu",
  280. "yt.drgnz.club",
  281. ],
  282. piped: [
  283. "piped.video",
  284. "cf.piped.video",
  285. "fl.piped.video",
  286. "do.piped.video",
  287. "az.piped.video",
  288. "piped.mha.fi",
  289. "piped.garudalinux.org",
  290. "watch.leptons.xyz",
  291. "piped.lunar.icu",
  292. "piped.r4fo.com",
  293. "piped.privacydev.net",
  294. "piped.smnz.de",
  295. "piped.adminforge.de",
  296. "piped.hostux.net",
  297. "piped.astartes.nl",
  298. "piped.osphost.fi",
  299. "piped.simpleprivacy.fr",
  300. "pi.ggtyler.dev",
  301. "piped.seitan-ayoub.lol",
  302. "yt.owo.si",
  303. "piped.12a.app",
  304. "piped.minionflo.net",
  305. ],
  306. libmedium: [
  307. "libmedium.batsense.net",
  308. "md.vern.cc",
  309. "medium.hostux.net",
  310. "read.sudovanilla.com",
  311. "libmedium.privacyfucking.rocks",
  312. "libmedium.frontendfriendly.xyz",
  313. "libmedium.esmailelbob.xyz",
  314. ],
  315. libreddit: [
  316. "redditor.fly.dev",
  317. "libreddit.kavin.rocks",
  318. "libreddit.strongthany.cc",
  319. "libreddit.northboot.xyz",
  320. "libreddit.kylrth.com",
  321. "libreddit.tiekoetter.com",
  322. "l.opnxng.com",
  323. "libreddit.projectsegfau.lt",
  324. "libreddit.privacydev.net",
  325. "libreddit.frontendfriendly.xyz",
  326. "libreddit.oxymagnesium.com",
  327. "libreddit.freedit.eu",
  328. "libreddit.mha.fi",
  329. "lr.artemislena.eu",
  330. "libreddit.nohost.network",
  331. "lr.aeong.one",
  332. "libreddit.lunar.icu",
  333. "libreddit.r4fo.com",
  334. "snoo.habedieeh.re",
  335. "libreddit.tux.pizza",
  336. "libreddit.nerdyfam.tech",
  337. "libreddit.perennialte.ch",
  338. "libreddit.baczek.me",
  339. "libreddit.private.coffee",
  340. "lr.seitan-ayoub.lol",
  341. "l.bloat.cat",
  342. ],
  343. libremdb: [
  344. "libremdb.iket.me",
  345. "libremdb.pussthecat.org",
  346. "ld.vern.cc",
  347. "libremdb.esmailelbob.xyz",
  348. "binge.whatever.social",
  349. "libremdb.lunar.icu",
  350. "libremdb.jeikobu.net",
  351. "libremdb.nerdyfam.tech",
  352. "libremdb.tux.pizza",
  353. "libremdb.frontendfriendly.xyz",
  354. "d.opnxng.com",
  355. "libremdb.catsarch.com",
  356. ],
  357. librey: [
  358. "search.ahwx.org",
  359. "ly.owo.si",
  360. "librey.danyaal.xyz",
  361. "librey.org",
  362. "librex.supernets.org",
  363. "search.davidovski.xyz",
  364. "librex.uk.to",
  365. "search.funami.tech",
  366. "librex.nohost.network",
  367. "search.pabloferreiro.es",
  368. "librex.yogeshlamichhane.com.np",
  369. "librey.baczek.me",
  370. "lx.benike.me",
  371. "search.seitan-ayoub.lol",
  372. ],
  373. lingva: [
  374. "lingva.ml",
  375. "lingva.thedaviddelta.com",
  376. "lingva.frontendfriendly.xyz",
  377. "lingva.retiolus.net",
  378. "translate.plausibility.cloud",
  379. "lingva.lunar.icu",
  380. "lingva.garudalinux.org",
  381. "lingva.seitan-ayoub.lol",
  382. ],
  383. mediumrip: ["medium.rip"],
  384. neuters: [
  385. "neuters.de",
  386. "neuters.privacyfucking.rocks",
  387. ],
  388. nitter: [
  389. "nitter.net",
  390. "nitter.unixfox.eu",
  391. "nitter.esmailelbob.xyz",
  392. "nitter.poast.org",
  393. "nitter.privacydev.net",
  394. "nitter.projectsegfau.lt",
  395. "nitter.soopy.moe",
  396. "nitter.rawbit.ninja",
  397. "nitter.freedit.eu",
  398. "nitter.nohost.network",
  399. "nitter.no-logs.com",
  400. "nitter.io.lol",
  401. "nitter.woodland.cafe",
  402. "nitter.perennialte.ch",
  403. "nitter.salastil.com",
  404. "n.opnxng.com",
  405. "nitter.ktachibana.party",
  406. ],
  407. pixivfe: [],
  408. proxitok: [
  409. "proxitok.pabloferreiro.es",
  410. "proxitok.pussthecat.org",
  411. "tok.habedieeh.re",
  412. "proxitok.privacydev.net",
  413. "tok.artemislena.eu",
  414. "tok.adminforge.de",
  415. "tik.hostux.net",
  416. "cringe.whatever.social",
  417. "proxitok.lunar.icu",
  418. "proxitok.privacy.com.de",
  419. "proxitok.r4fo.com",
  420. "cringe.seitan-ayoub.lol",
  421. "cringe.datura.network",
  422. "tt.opnxng.com",
  423. "proxitok.tinfoil-hat.net",
  424. "tiktok.wpme.pl",
  425. ],
  426. quetre: [
  427. "quetre.iket.me",
  428. "qr.vern.cc",
  429. "quetre.pussthecat.org",
  430. "quetre.privacydev.net",
  431. "ask.habedieeh.re",
  432. "quetre.blackdrgn.nl",
  433. "quetre.lunar.icu",
  434. "quetre.frontendfriendly.xyz",
  435. "q.opnxng.com",
  436. "quetre.rootdo.org",
  437. "quora.seitan-ayoub.lol",
  438. "quetre.esmailelbob.xyz",
  439. "quetre.catsarch.com",
  440. "ask.sudovanilla.org",
  441. "quetre.smnz.de",
  442. ],
  443. rimgo: [
  444. "rimgo.totaldarkness.net",
  445. "imgur.artemislena.eu",
  446. "rimgo.lunar.icu",
  447. "imgur.010032.xyz",
  448. "rimgo.kling.gg",
  449. "rimgo.projectsegfau.lt",
  450. "rimgo.nohost.network",
  451. "rimgo.catsarch.com",
  452. "rimgo.quantenzitrone.eu",
  453. "rimgo.frylo.net",
  454. ],
  455. scribe: [
  456. "scribe.rip",
  457. "scribe.citizen4.eu",
  458. "scribe.bus-hit.me",
  459. "scribe.projectsegfau.lt",
  460. "scribe.rawbit.ninja",
  461. "m.opnxng.com",
  462. ],
  463. teddit: [
  464. "i.opnxng.com",
  465. "teddit.hostux.net",
  466. "teddit.net",
  467. "teddit.rawbit.ninja",
  468. "teddit.pussthecat.org",
  469. "teddit.zaggy.nl",
  470. "t.sneed.network",
  471. "td.vern.cc",
  472. ],
  473. tent: ["tent.sny.sh", "tent.bloat.cat", "tn.vern.cc"],
  474. tubo: ["tubo.migalmoreno.com"],
  475. wikiless: [
  476. "wikiless.tiekoetter.com",
  477. "wikiless.funami.tech",
  478. "wl.vern.cc",
  479. "wiki.froth.zone",
  480. "wikiless.northboot.xyz",
  481. "wikiless.rawbit.ninja",
  482. "wiki.adminforge.de",
  483. "wikiless.rootdo.org",
  484. "w.sneed.network",
  485. "wikiless.r4fo.com",
  486. "wiki.seitan-ayoub.lol",
  487. "wikiless.esmailelbob.xyz",
  488. "wikiless.ditatompel.com",
  489. ],
  490. safetwitch: [
  491. "safetwitch.drgns.space",
  492. "safetwitch.drgns.space",
  493. "safetwitch.projectsegfau.lt",
  494. "safetwitch.datura.network",
  495. "ttv.vern.cc",
  496. "safetwitch.frontendfriendly.xyz",
  497. "ttv.femboy.band",
  498. "twitch.seitan-ayoub.lol",
  499. "st.ggtyler.dev",
  500. "safetwitch.lunar.icu",
  501. "twitch.sudovanilla.com",
  502. "safetwitch.r4fo.com",
  503. "safetwitch.ducks.party",
  504. "safetwitch.nogafam.fr",
  505. "safetwitch.privacyredirect.com",
  506. ],
  507. searx: [
  508. "search.bus-hit.me",
  509. "search.projectsegfau.lt",
  510. "northboot.xyz",
  511. "opnxng.com",
  512. ],
  513. searxng: [
  514. "search.sapti.me",
  515. "priv.au",
  516. "search.demoniak.ch",
  517. "www.gruble.de",
  518. "search.lvkaszus.pl",
  519. "searx.divided-by-zero.eu",
  520. "xo.wtf",
  521. "freesearch.club",
  522. "baresearch.org",
  523. "searx.perennialte.ch",
  524. "searx.techsaviours.org",
  525. "search.mdosch.de",
  526. "searx.kutay.dev",
  527. "searx.si",
  528. "searx.namejeff.xyz",
  529. "search.ononoki.org",
  530. "etsi.me",
  531. "searx.work",
  532. "search.smnz.de",
  533. "searx.prvcy.eu",
  534. "searx.headpat.exchange",
  535. ],
  536. hackernews: {
  537. better: "better-hackernews.vercel.app",
  538. worker: "news.workers.tools",
  539. },
  540. };
  541.  
  542. let farsideInstance = keepHistory ? "farside.link/_" : "farside.link";
  543.  
  544. // // // // // // // // // // // // //
  545.  
  546. const hash = window.location.hash,
  547. scheme = `${window.location.protocol}//`;
  548.  
  549. let debug_mode = false;
  550.  
  551. if (debug_mode) {
  552. alert(
  553. "\n== DEBUG MODE IS ON ==" +
  554. "\nIf you're seeing this" +
  555. "\nset the debug_mode value to" +
  556. "\nfalse for Privacy Redirector." +
  557. "\n======================" +
  558. "\n\nHostname: " +
  559. window.location.hostname +
  560. "\nPath: " +
  561. window.location.pathname +
  562. "\nQuery: " +
  563. window.location.search +
  564. "\nHash: " +
  565. hash
  566. );
  567. }
  568.  
  569. let selectedInstance = "",
  570. newURL = "";
  571.  
  572. const getrandom = async (instances) =>
  573. instances[Math.floor(Math.random() * instances.length)];
  574.  
  575. async function redirectInstagram() {
  576. if (instagram[0]) {
  577. window.stop();
  578. let pathname = window.location.pathname;
  579. let search = window.location.search;
  580. let params = new URLSearchParams(search);
  581.  
  582. selectedInstance = await getrandom(Instances.proxigram);
  583.  
  584. switch (true) {
  585. case pathname.startsWith("/accounts/login/"):
  586. case pathname.startsWith("/accounts/signup/"):
  587. pathname = pathname.replace(/^\/accounts\/(login|signup)\/[a-z]*/, "");
  588. params.delete("next");
  589. search = params.size ? `?${params}` : "";
  590. break;
  591. case pathname.startsWith("/reel/"):
  592. case pathname.startsWith("/tv/"):
  593. pathname = pathname.replace(/^\/(reel|tv)\//, "/p/");
  594. break;
  595. case pathname.endsWith("/reels/"):
  596. pathname = pathname.replace("/reels", "");
  597. break;
  598. }
  599. newURL = `${scheme}${selectedInstance}${pathname}${search}${hash}`;
  600. window.location.replace(newURL);
  601. }
  602. }
  603.  
  604. async function redirectTwitter() {
  605. if (twitter[0]) {
  606. window.stop();
  607.  
  608. const pathname = window.location.pathname;
  609. let searchpath = `${pathname}${window.location.search}`;
  610.  
  611. selectedInstance = twitter[1]
  612. ? `${farsideInstance}/nitter`
  613. : await getrandom(Instances.nitter);
  614.  
  615. if (pathname === "/i/flow/login")
  616. searchpath = searchpath.replace(
  617. "/i/flow/login?redirect_after_login=",
  618. ""
  619. );
  620.  
  621. if (searchpath.includes("%")) searchpath = decodeURIComponent(searchpath);
  622.  
  623. newURL = `${scheme}${selectedInstance}${searchpath}${hash}`;
  624. window.location.replace(newURL);
  625. }
  626. }
  627.  
  628. async function redirectReddit() {
  629. if (reddit[0] && !window.location.pathname.startsWith("/domain")) {
  630. window.stop();
  631. let pathname = window.location.pathname;
  632. let search = window.location.search;
  633.  
  634. selectedInstance = reddit[1]
  635. ? `${farsideInstance}/${redditFrontend}`
  636. : await getrandom(Instances[redditFrontend]);
  637.  
  638. if (pathname === "/media" && search) {
  639. const params = new URLSearchParams(search);
  640. const mediaURL = new URL(params.get("url"));
  641. if (["i.redd.it", "preview.redd.it"].includes(mediaURL.hostname)) {
  642. pathname = `/img${mediaURL.pathname}`;
  643. search = mediaURL.search;
  644. }
  645. }
  646. newURL = `${scheme}${selectedInstance}${pathname}${search}${hash}`;
  647.  
  648. window.location.replace(newURL);
  649. }
  650. }
  651.  
  652. async function redirectYoutube(frontend) {
  653. if (youtube[0]) {
  654. window.stop();
  655. let searchpath = `${window.location.pathname}${window.location.search}`;
  656. if (frontend !== "tubo") {
  657. selectedInstance =
  658. youtube[1] && frontend !== "hyperpipe"
  659. ? `${farsideInstance}/${frontend}`
  660. : await getrandom(Instances[frontend]);
  661. } else {
  662. selectedInstance = await getrandom(Instances.tubo);
  663.  
  664. searchpath = `/stream?url=${window.location.href}`;
  665. if (
  666. window.location.pathname.startsWith("/@") ||
  667. window.location.pathname.startsWith("/channel")
  668. )
  669. searchpath = `/channel?url=${window.location.href}`;
  670. }
  671. newURL = `${scheme}${selectedInstance}${searchpath}${hash}`;
  672. window.location.replace(newURL);
  673. }
  674. }
  675.  
  676. async function redirectTiktok() {
  677. if (tiktok[0]) {
  678. window.stop();
  679. let pathname = window.location.pathname;
  680. selectedInstance = tiktok[1]
  681. ? `${farsideInstance}/proxitok`
  682. : await getrandom(Instances.proxitok);
  683.  
  684. await Promise.any(
  685. [
  686. ["/@/", "/@placeholder/"],
  687. ["/discover/", "/tag/"],
  688. ["/foryou", "/trending"],
  689. ].map(async ([key, value]) => {
  690. if (pathname.startsWith(key)) pathname = pathname.replace(key, value);
  691. })
  692. );
  693.  
  694. newURL = `${scheme}${selectedInstance}${pathname}${window.location.search}${hash}`;
  695. window.location.replace(newURL);
  696. }
  697. }
  698.  
  699. async function redirectImgur() {
  700. if (imgur[0]) {
  701. window.stop();
  702.  
  703. selectedInstance = imgur[1]
  704. ? `${farsideInstance}/rimgo`
  705. : await getrandom(Instances.rimgo);
  706.  
  707. newURL = `${scheme}${selectedInstance}${window.location.pathname}${window.location.search}${hash}`;
  708.  
  709. window.location.replace(newURL);
  710. }
  711. }
  712.  
  713. async function redirectMedium(frontend) {
  714. if (medium[0]) {
  715. let pathname = window.location.pathname;
  716. const host_path = `${window.location.hostname}${pathname}`;
  717.  
  718. if (
  719. (/^.+?\.medium\.com\/.+/.test(host_path) ||
  720. /^\/@?[a-z0-9\-\_]+\//.test(pathname) ||
  721. host_path === "medium.com/") &&
  722. !(
  723. /^\/(tag|m|hc)\//.test(pathname) ||
  724. /\/(about|followers|following)/.test(pathname)
  725. )
  726. ) {
  727. window.stop();
  728. selectedInstance =
  729. medium[1] && frontend === "scribe"
  730. ? `${farsideInstance}/scribe`
  731. : await getrandom(Instances[frontend]);
  732. const username = window.location.hostname.replace(/\.?medium\.com/, "");
  733. if (username) pathname = `/${username}${pathname}`;
  734. newURL = `${scheme}${selectedInstance}${pathname}${window.location.search}${hash}`;
  735. window.location.replace(newURL);
  736. }
  737. }
  738. }
  739.  
  740. async function redirectHackerNews() {
  741. if (hackernews[0]) {
  742. let pathname = window.location.pathname;
  743. if (
  744. ["/newest", "/item", "/user", "/ask", "/show", "/jobs", "/"].includes(
  745. pathname
  746. )
  747. ) {
  748. if (
  749. hackernewsFrontend === "better" &&
  750. window.location.pathname === "/newest"
  751. )
  752. pathname = "/new";
  753. selectedInstance = Instances.hackernews[hackernewsFrontend];
  754. } else if (
  755. ["/best", "/news", "/submitted", "/threads", "/classic"].includes(
  756. pathname
  757. )
  758. ) {
  759. selectedInstance = Instances.hackernews.worker;
  760. }
  761. if (selectedInstance) {
  762. window.stop();
  763. newURL = `${scheme}${selectedInstance}${pathname}${window.location.search}`;
  764. window.location.replace(newURL);
  765. }
  766. }
  767. }
  768.  
  769. async function redirectGTranslate() {
  770. if (gtranslate[0]) {
  771. window.stop();
  772.  
  773. selectedInstance = gtranslate[1]
  774. ? `${farsideInstance}/lingva`
  775. : await getrandom(Instances.lingva);
  776.  
  777. let pathname = window.location.pathname;
  778. if (window.location.search) {
  779. const params = new URLSearchParams(window.location.search);
  780. pathname = `/${params.get("sl")}/${params.get("tl")}/${params.get(
  781. "text"
  782. )}`;
  783. } else if (/^\/\w+\/\w+\/.*/.test(pathname)) {
  784. pathname = pathname.replace(/\+/g, " ");
  785. }
  786. newURL = `${scheme}${selectedInstance}${pathname}`;
  787. window.location.replace(newURL);
  788. }
  789. }
  790.  
  791. async function redirectReuters() {
  792. if (reuters[0]) {
  793. window.stop();
  794. selectedInstance = await getrandom(Instances.neuters);
  795. newURL = `${scheme}${selectedInstance}${window.location.pathname}${window.location.search}${hash}`;
  796. window.location.replace(newURL);
  797. }
  798. }
  799.  
  800. async function redirectWikipedia() {
  801. if (wikipedia[0]) {
  802. window.stop();
  803. let langCode = /^([a-z\-]+)\./.exec(window.location.hostname)[1];
  804.  
  805. selectedInstance = wikipedia[1]
  806. ? `${farsideInstance}/wikiless`
  807. : await getrandom(Instances.wikiless);
  808.  
  809. if (langCode === "www") langCode = "en";
  810. newURL = `${scheme}${selectedInstance}${window.location.pathname}?lang=${langCode}${hash}`;
  811. window.location.replace(newURL);
  812. }
  813. }
  814.  
  815. async function redirectImdb() {
  816. if (imdb[0]) {
  817. window.stop();
  818.  
  819. selectedInstance = imdb[1]
  820. ? `${farsideInstance}/libremdb`
  821. : await getrandom(Instances.libremdb);
  822.  
  823. newURL = `${scheme}${selectedInstance}${window.location.pathname}${window.location.search}${hash}`;
  824.  
  825. window.location.replace(newURL);
  826. }
  827. }
  828.  
  829. async function redirectQuora() {
  830. if (quora[0]) {
  831. window.stop();
  832.  
  833. selectedInstance = quora[1]
  834. ? `${farsideInstance}/quetre`
  835. : await getrandom(Instances.quetre);
  836.  
  837. newURL = `${scheme}${selectedInstance}${window.location.pathname}${window.location.search}${hash}`;
  838.  
  839. window.location.replace(newURL);
  840. }
  841. }
  842.  
  843. async function redirectFandom() {
  844. if (fandom[0]) {
  845. window.stop();
  846. const fandomName = window.location.hostname.replace(/\..+/, "");
  847. selectedInstance = await getrandom(Instances.breezewiki);
  848.  
  849. let pathname = window.location.pathname;
  850. if (fandomName !== "www") pathname = `/${fandomName}${pathname}`;
  851. newURL = `${scheme}${selectedInstance}${pathname}${window.location.search}${hash}`;
  852.  
  853. window.location.replace(newURL);
  854. }
  855. }
  856.  
  857. async function redirectGoogle() {
  858. if (
  859. google[0] &&
  860. window.location.hostname.startsWith("www") &&
  861. window.location.pathname.startsWith("/search")
  862. ) {
  863. window.stop();
  864.  
  865. selectedInstance = google[1]
  866. ? `${farsideInstance}/${googleFrontend}`
  867. : (selectedInstance = await getrandom(Instances[googleFrontend]));
  868.  
  869. let pathname = window.location.pathname;
  870. if (googleFrontend === "librey" && pathname === "/search")
  871. pathname += ".php";
  872. const params = new URLSearchParams(window.location.search);
  873. const query = params.entries().q;
  874. const search = query ? `?q=${query}` : window.location.search;
  875. newURL = `${scheme}${selectedInstance}${pathname}${search}${hash}`;
  876. window.location.replace(newURL);
  877. }
  878. }
  879.  
  880. async function redirectGoodreads() {
  881. if (goodreads[0]) {
  882. window.stop();
  883.  
  884. selectedInstance = await getrandom(Instances.biblioreads);
  885.  
  886. if (window.location.pathname.startsWith("/search")) {
  887. const params = new URLSearchParams(search);
  888. search = `/${params.get("q")}`;
  889. }
  890. newURL = `${scheme}${selectedInstance}${window.location.pathname}${search}${hash}`;
  891. window.location.replace(newURL);
  892. }
  893. }
  894.  
  895. async function redirectStackoverflow() {
  896. if (
  897. stackoverflow[0] &&
  898. (window.location.pathname.startsWith("/questions/") ||
  899. window.location.pathname === "/")
  900. ) {
  901. window.stop();
  902. selectedInstance = stackoverflow[1]
  903. ? `${farsideInstance}/anonymousoverflow`
  904. : await getrandom(Instances.anonymousoverflow);
  905.  
  906. newURL = `${scheme}${selectedInstance}${window.location.pathname}${window.location.search}${hash}`;
  907. window.location.replace(newURL);
  908. }
  909. }
  910.  
  911. async function redirectBandcamp() {
  912. if (bandcamp[0]) {
  913. // thanks to libredirect
  914.  
  915. selectedInstance = await getrandom(Instances.tent);
  916. const params = new URLSearchParams(window.location.search);
  917. const artist = window.location.hostname.replace(/\..+/, "");
  918. const regex = /^\/(.+?)\/(.+)/.exec(window.location.pathname);
  919. const audio = /^\/stream\/([a-f0-9]+)\/(.+)\/([0-9]+)/.exec(
  920. window.location.pathname
  921. );
  922. const image = /^\/img\/(.+)/.exec(window.location.pathname);
  923. let searchpath = "";
  924.  
  925. switch (true) {
  926. case window.location.pathname === "/search":
  927. searchpath = `/search.php?query=${params.get("q")}`;
  928. break;
  929. case window.location.hostname.search(/(daily)?\.bandcamp\.com/) > 0:
  930. if (window.location.pathname === "/") {
  931. searchpath = `/artist.php?name=${artist}`;
  932. } else if (regex.length > 2) {
  933. searchpath = `/release.php?artist=${artist}&type=${regex[1]}&name=${regex[2]}`;
  934. }
  935. break;
  936. case window.location.hostname === "f4.bcbits.com":
  937. if (image.length > 1) searchpath = `/image.php?file=${image[1]}`;
  938. break;
  939. case window.location.hostname === "t4.bcbits.com":
  940. if (audio.length > 3)
  941. searchpath = `/audio.php?directory=${audio[1]}&format=${
  942. audio[2]
  943. }&file=${audio[3]}&token=${params.get("token")}`;
  944. break;
  945. default:
  946. return;
  947. }
  948. window.stop();
  949. newURL = `${scheme}${selectedInstance}${searchpath}`;
  950. window.location.replace(newURL);
  951. }
  952. }
  953.  
  954. async function redirectGenius() {
  955. if (genius[0]) {
  956. const pathname = window.location.pathname;
  957. selectedInstance = await getrandom(Instances[geniusFrontend]);
  958.  
  959. await Promise.any(
  960. [
  961. ["lyrics", pathname.endsWith("-lyrics")],
  962. ["album", pathname.startsWith("/albums/")],
  963. ["artist", pathname.startsWith("/artists/")],
  964. [, ["/", "/search"].includes(pathname)],
  965. ].map(async ([key, value]) => {
  966. if (value) {
  967. const searchpath =
  968. geniusFrontend === "intellectual" && key
  969. ? `/${key}?path=${pathname.slice(1)}`
  970. : `${pathname}${window.location.search}`;
  971. window.stop();
  972. newURL = `${scheme}${selectedInstance}${searchpath}${hash}`;
  973. window.location.replace(newURL);
  974. }
  975. })
  976. );
  977. }
  978. }
  979.  
  980. async function redirectPinterest() {
  981. if (pinterest[0]) {
  982. selectedInstance = await getrandom(Instances.binternet);
  983.  
  984. let searchpath = "";
  985. if (window.location.hostname === "i.pinimg.com") {
  986. searchpath = `/image_proxy.php?url=${window.location.href}`;
  987. } else if (window.location.pathname.startsWith("/search")) {
  988. searchpath = `${window.location.pathname
  989. .replace("search", "search.php")
  990. .replace("/pins/", "")}${window.location.search}`;
  991. } else if (window.location.pathname !== "/") return;
  992.  
  993. window.stop();
  994. newURL = `${scheme}${selectedInstance}${searchpath}`;
  995. window.location.replace(newURL);
  996. }
  997. }
  998.  
  999. async function redirectSoundcloud() {
  1000. if (soundcloud[0]) {
  1001. window.stop();
  1002. selectedInstance = await getrandom(Instances.tubo);
  1003.  
  1004. let searchpath = "/kiosk?serviceId=1";
  1005. if (window.location.pathname !== "/")
  1006. searchpath = `/stream?url=${window.location.href}`;
  1007. newURL = `${scheme}${selectedInstance}${searchpath}`;
  1008. window.location.replace(newURL);
  1009. }
  1010. }
  1011.  
  1012. async function redirectPixiv() {
  1013. if (pixiv[0]) {
  1014. window.stop();
  1015. selectedInstance = await getrandom(Instances.pixivfe);
  1016.  
  1017. const pathname = window.location.pathname.replace(/^\/\w{2}\//, "/");
  1018. newURL = `${scheme}${selectedInstance}${pathname}${window.location.search}`;
  1019. window.location.replace(newURL);
  1020. }
  1021. }
  1022.  
  1023. async function redirectTwitch() {
  1024. if (twitch[0]) {
  1025. window.stop();
  1026. selectedInstance = await getrandom(Instances.safetwitch);
  1027.  
  1028. const pathname =
  1029. window.location.pathname == "/search"
  1030. ? window.location.pathname + "/"
  1031. : window.location.pathname;
  1032.  
  1033. let searchpath =
  1034. window.location.pathname == "/search"
  1035. ? window.location.search.replace("term", "query")
  1036. : window.location.search;
  1037.  
  1038. newURL = `${scheme}${selectedInstance}${pathname}${searchpath}`;
  1039. window.location.replace(newURL);
  1040. }
  1041. }
  1042.  
  1043. const urlHostname = window.location.hostname;
  1044.  
  1045. switch (urlHostname) {
  1046. case "www.instagram.com":
  1047. redirectInstagram();
  1048. break;
  1049.  
  1050. case "twitter.com":
  1051. case "mobile.twitter.com":
  1052. redirectTwitter();
  1053. break;
  1054.  
  1055. case "www.youtube.com":
  1056. case "m.youtube.com":
  1057. case "www.youtube-nocookie.com":
  1058. redirectYoutube(youtubeFrontend);
  1059. break;
  1060.  
  1061. case "www.tiktok.com":
  1062. redirectTiktok();
  1063. break;
  1064.  
  1065. case "music.youtube.com":
  1066. redirectYoutube(youtubeMusicFrontend);
  1067. break;
  1068.  
  1069. case "news.ycombinator.com":
  1070. redirectHackerNews();
  1071. break;
  1072.  
  1073. case "translate.google.com":
  1074. redirectGTranslate();
  1075. break;
  1076.  
  1077. case "www.reuters.com":
  1078. redirectReuters();
  1079. break;
  1080.  
  1081. case "www.imdb.com":
  1082. case "m.imdb.com":
  1083. redirectImdb();
  1084. break;
  1085.  
  1086. case "www.quora.com":
  1087. redirectQuora();
  1088. break;
  1089.  
  1090. case "www.google.com":
  1091. redirectGoogle();
  1092. break;
  1093.  
  1094. case "www.goodreads.com":
  1095. redirectGoodreads();
  1096. break;
  1097.  
  1098. case "genius.com":
  1099. redirectGenius();
  1100. break;
  1101.  
  1102. case "stackoverflow.com":
  1103. redirectStackoverflow();
  1104. break;
  1105.  
  1106. case "f4.bcbits.com":
  1107. case "t4.bcbits.com":
  1108. redirectBandcamp();
  1109. break;
  1110.  
  1111. case "i.pinimg.com":
  1112. redirectPinterest();
  1113. break;
  1114.  
  1115. case "soundcloud.com":
  1116. case "m.soundcloud.com":
  1117. redirectSoundcloud();
  1118. break;
  1119.  
  1120. case "www.pixiv.net":
  1121. redirectPixiv();
  1122. break;
  1123.  
  1124. case "twitch.tv":
  1125. case "www.twitch.tv":
  1126. redirectTwitch();
  1127. break;
  1128.  
  1129. case urlHostname.includes("reddit.com") ? urlHostname : 0:
  1130. redirectReddit();
  1131. break;
  1132.  
  1133. case urlHostname.includes("medium.com") ? urlHostname : 0:
  1134. redirectMedium(mediumFrontend);
  1135. break;
  1136.  
  1137. case urlHostname.includes("imgur.com") ? urlHostname : 0:
  1138. case urlHostname.includes("imgur.io") ? urlHostname : 0:
  1139. redirectImgur();
  1140. break;
  1141.  
  1142. case urlHostname.includes("wikipedia.org") ? urlHostname : 0:
  1143. redirectWikipedia();
  1144. break;
  1145.  
  1146. case urlHostname.includes("fandom.com") ? urlHostname : 0:
  1147. redirectFandom();
  1148. break;
  1149.  
  1150. case urlHostname.includes("bandcamp.com") ? urlHostname : 0:
  1151. redirectBandcamp();
  1152. break;
  1153.  
  1154. case urlHostname.includes("pinterest.com") ? urlHostname : 0:
  1155. redirectPinterest();
  1156. break;
  1157. }
  1158.  
  1159. // export module for the test in github action
  1160. typeof module !== 'undefined' ? module.exports = {Instances: Instances} : true;
  1161.  

QingJ © 2025

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