Privacy Redirector

Redirect social media platforms to their privacy respecting frontends

As of 05/11/2023. See the latest version.

  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.0
  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 *://i.pinimg.com/*
  77. // @match *://*.quora.com/*
  78. // @match *://*.reddit.com/*
  79. // @match *://*.reuters.com/*
  80. // @match *://*.tiktok.com/*
  81. // @match *://*.twitter.com/*
  82. // @match *://*.wikipedia.org/*
  83. // @match *://*.youtube-nocookie.com/*
  84. // @match *://*.youtube.com/*
  85. // @match *://*.soundcloud.com/*
  86. // @match *://f4.bcbits.com/*
  87. // @match *://genius.com/*
  88. // @match *://imgur.com/*
  89. // @match *://instagram.com/*
  90. // @match *://medium.com/*
  91. // @match *://news.ycombinator.com/*
  92. // @match *://reddit.com/*
  93. // @match *://stackoverflow.com/*
  94. // @match *://t4.bcbits.com/*
  95. // @match *://translate.google.com/*
  96. // @match *://twitter.com/*
  97. // @match *://www.goodreads.com/*
  98. // @match *://youtube.com/*
  99. // @exclude *://*.youtube.com/redirect*
  100. // @exclude *://youtube.com/redirect*
  101. // ==/UserScript==
  102.  
  103. /*
  104. ___ _ _ ___ _____ _____
  105. / _ \| \ | | / _ \| ___| ___|
  106. | | | | \| |_____| | | | |_ | |_
  107. | |_| | |\ |_____| |_| | _| | _|
  108. \___/|_| \_| \___/|_| |_|
  109.  
  110. CHANGE THE RELEVANT VALUE TO "false" TO
  111. DISABLE THE REDIRECTION/FARSIDE FOR THAT
  112. PARTICULAR PLATFORM */
  113.  
  114. // REDIRECTON / FARSIDE
  115.  
  116. let bandcamp = [true, true];
  117. let fandom = [true, true];
  118. let genius = [true, true];
  119. let goodreads = [true, false];
  120. let google = [true, true];
  121. let gtranslate = [true, true];
  122. let hackernews = [true, true];
  123. let imdb = [true, true];
  124. let imgur = [true, false];
  125. let medium = [true, true];
  126. let pinterest = [true, true];
  127. let quora = [true, false];
  128. let reddit = [true, false];
  129. let reuters = [true, true];
  130. let soundcloud = [true, true];
  131. let stackoverflow = [true, true];
  132. let tiktok = [true, false];
  133. let twitter = [true, true];
  134. let wikipedia = [true, false];
  135. let youtube = [true, false];
  136. let instagram = [true, true];
  137.  
  138. // PREFERRED FRONTEND
  139. let youtubeFrontend = "piped"; // accepts "invidious", "piped", "tubo"
  140. let youtubeMusicFrontend = "hyperpipe"; // accepts "hyperpipe", "invidious", "piped"
  141. let redditFrontend = "libreddit"; // accepts "libreddit", "teddit"
  142. let googleFrontend = "librey"; // accepts "librey", "searx", "searxng"
  143. let geniusFrontend = "intellectual"; // accepts dumb, intellectual
  144. let hackernewsFrontend = "better"; // accepts better, worker
  145.  
  146. // OTHER SETTINGS
  147. let keepHistory = false; // keeps farside.link in the browser history
  148.  
  149. // // // // // // // // // // // // //
  150.  
  151. /*
  152. ___ _
  153. |_ _|_ __ ___| |_ __ _ _ __ ___ ___ ___
  154. | || '_ \/ __| __/ _` | '_ \ / __/ _ \/ __|
  155. | || | | \__ \ || (_| | | | | (_| __/\__ \
  156. |___|_| |_|___/\__\__,_|_| |_|\___\___||___/
  157.  
  158. LIST OF INSTANCES TO USE IF FARSIDE IS NOT ENABLED
  159. */
  160.  
  161. const Instances = {
  162. anonymousoverflow: [
  163. "code.whatever.social",
  164. "overflow.smnz.de",
  165. "overflow.lunar.icu",
  166. "overflow.adminforge.de",
  167. "overflow.hostux.net",
  168. "overflow.projectsegfau.lt",
  169. "code.whateveritworks.org",
  170. "ao.bloatcat.tk",
  171. "anonoverflow.frontendfriendly.xyz",
  172. "ao.owo.si",
  173. "overflow.datura.network",
  174. "ao.ftw.lol",
  175. "anonoverflow.hyperreal.coffee",
  176. "overflow.sudovanilla.com",
  177. ],
  178. hyperpipe: [
  179. "hyperpipe.surge.sh",
  180. "hyperpipe.esmailelbob.xyz",
  181. "music.adminforge.de",
  182. "music.pfcd.me",
  183. "listen.whateveritworks.org",
  184. "hyperpipe.drgns.space",
  185. "hyperpipe.lunar.icu",
  186. ],
  187. proxigram: [
  188. "proxigram.privacyfrontends.repl.co",
  189. "proxigram.protokolla.fi",
  190. "proxigram.kyun.li",
  191. "proxigram.drgns.space",
  192. "ig.opnxng.com",
  193. ],
  194. biblioreads: [
  195. "biblioreads.eu.org",
  196. "biblioreads.vercel.app",
  197. "biblioreads.lunar.icu",
  198. "read.whateveritworks.org",
  199. "biblioreads.privacyfucking.rocks",
  200. "read.seitan-ayoub.lol",
  201. ],
  202. binternet: [
  203. "binternet.ahwx.org",
  204. "binternet.revvy.de",
  205. "binternet.bloatcat.tk",
  206. "bn.opnxng.com",
  207. ],
  208. breezewiki: [
  209. "breezewiki.com",
  210. "antifandom.com",
  211. "breezewiki.pussthecat.org",
  212. "bw.hamstro.dev",
  213. "bw.projectsegfau.lt",
  214. "breeze.hostux.net",
  215. "bw.artemislena.eu",
  216. "nerd.whatever.social",
  217. "breezewiki.frontendfriendly.xyz",
  218. "breeze.nohost.network",
  219. "breeze.whateveritworks.org",
  220. "z.opnxng.com",
  221. "breezewiki.hyperreal.coffee",
  222. "breezewiki.catsarch.com",
  223. "breeze.mint.lgbt",
  224. "breezewiki.woodland.cafe",
  225. ],
  226. dumb: ["sing.whatever.social", "dumb.lunar.icu", "dumb.privacydev.net"],
  227. intellectual: [
  228. "intellectual.insprill.net",
  229. "in.bloatcat.tk",
  230. "intellectual.privacyfucking.rocks",
  231. ],
  232. invidious: [
  233. "yewtu.be",
  234. "vid.puffyan.us",
  235. "yt.artemislena.eu",
  236. "invidious.flokinet.to",
  237. "invidious.projectsegfau.lt",
  238. "invidious.slipfox.xyz",
  239. "invidious.privacydev.net",
  240. "vid.priv.au",
  241. "iv.ggtyler.dev",
  242. "invidious.lunar.icu",
  243. "inv.zzls.xyz",
  244. "inv.tux.pizza",
  245. "invidious.protokolla.fi",
  246. "proxied.invidious.fi",
  247. "onion.tube",
  248. "inv.citw.lgbt",
  249. "yt.oelrichsgarcia.de",
  250. "invidious.no-logs.com",
  251. "invidious.io.lol",
  252. "iv.nboeck.de",
  253. "invidious.asir.dev",
  254. "iv.datura.network",
  255. "invidious.fdn.fr",
  256. "anontube.lvkaszus.pl",
  257. "invidious.perennialte.ch",
  258. "yt.cdaut.de",
  259. "invidious.drgns.space",
  260. ],
  261. piped: [
  262. "piped.video",
  263. "cf.piped.video",
  264. "fl.piped.video",
  265. "do.piped.video",
  266. "piped.syncpundit.io",
  267. "piped.mha.fi",
  268. "piped.lunar.icu",
  269. "piped.rafo.tech",
  270. "il.ax",
  271. "piped.projectsegfau.lt",
  272. "watch.whatever.social",
  273. "piped.privacydev.net",
  274. "piped.smnz.de",
  275. "piped.adminforge.de",
  276. "piped.hostux.net",
  277. "piped.yt",
  278. "piped.astartes.nl",
  279. "piped.osphost.fi",
  280. "piped.drgns.space",
  281. "pi.ggtyler.dev",
  282. "piped.seitan-ayoub.lol",
  283. "piped.12a.app",
  284. ],
  285. libreddit: [
  286. "libreddit.kavin.rocks",
  287. "libreddit.strongthany.cc",
  288. "libreddit.northboot.xyz",
  289. "libreddit.hu",
  290. "libreddit.kylrth.com",
  291. "libreddit.tiekoetter.com",
  292. "l.opnxng.com",
  293. "libreddit.privacydev.net",
  294. "libreddit.oxymagnesium.com",
  295. "libreddit.freedit.eu",
  296. "libreddit.mha.fi",
  297. "lr.artemislena.eu",
  298. "lr.aeong.one",
  299. "libreddit.lunar.icu",
  300. "snoo.habedieeh.re",
  301. "libreddit.kutay.dev",
  302. "libreddit.tux.pizza",
  303. ],
  304. libremdb: [
  305. "libremdb.iket.me",
  306. "libremdb.pussthecat.org",
  307. "binge.whatever.social",
  308. "libremdb.lunar.icu",
  309. "libremdb.jeikobu.net",
  310. "binge.whateveritworks.org",
  311. "libremdb.nerdyfam.tech",
  312. "libremdb.tux.pizza",
  313. "libremdb.frontendfriendly.xyz",
  314. "d.opnxng.com",
  315. ],
  316. librey: [
  317. "search.ahwx.org",
  318. "search2.ahwx.org",
  319. "librex.zzls.xyz",
  320. "ly.owo.si",
  321. "librey.org",
  322. "librex.supernets.org",
  323. "search.davidovski.xyz",
  324. "librey.bloatcat.tk",
  325. "search.funami.tech",
  326. "librex.retro-hax.net",
  327. "librex.nohost.network",
  328. "search.pabloferreiro.es",
  329. "librex.yogeshlamichhane.com.np",
  330. "librey.baczek.me",
  331. "lx.benike.me",
  332. "search.seitan-ayoub.lol",
  333. ],
  334. lingva: [
  335. "lingva.frontendfriendly.xyz",
  336. "lingva.retiolus.net",
  337. "translate.plausibility.cloud",
  338. "lingva.lunar.icu",
  339. ],
  340. nitter: [
  341. "nitter.net",
  342. "nitter:nitter@nitter.nixnet.services",
  343. "nitter.unixfox.eu",
  344. "nitter.mint.lgbt",
  345. "nitter.esmailelbob.xyz",
  346. "nitter.poast.org",
  347. "nitter.cz",
  348. "nitter.projectsegfau.lt",
  349. "nitter.soopy.moe",
  350. "nitter.d420.de",
  351. "nitter.nohost.network",
  352. "nitter.x86-64-unknown-linux-gnu.zip",
  353. "nitter.woodland.cafe",
  354. "nitter.dafriser.be",
  355. "nitter.perennialte.ch",
  356. "nitter.salastil.com",
  357. "n.populas.no",
  358. "nitter.uni-sonia.com",
  359. "n.opnxng.com",
  360. "nitter.ktachibana.party",
  361. ],
  362. proxitok: [
  363. "proxitok.pabloferreiro.es",
  364. "proxitok.pussthecat.org",
  365. "tok.habedieeh.re",
  366. "tok.adminforge.de",
  367. "tik.hostux.net",
  368. "cringe.whatever.social",
  369. "cringe.whateveritworks.org",
  370. "cringe.datura.network",
  371. "tt.opnxng.com",
  372. "proxitok.tinfoil-hat.net",
  373. "tiktok.wpme.pl",
  374. ],
  375. quetre: [
  376. "quetre.iket.me",
  377. "quetre.privacydev.net",
  378. "questions.whateveritworks.org",
  379. "quetre.frontendfriendly.xyz",
  380. "q.opnxng.com",
  381. "quetre.ftw.lol",
  382. "quora.seitan-ayoub.lol",
  383. "ask.sudovanilla.com",
  384. "quetre.drgns.space",
  385. ],
  386. rimgo: [
  387. "imgur.artemislena.eu",
  388. "ri.zzls.xyz",
  389. "rimgo.lunar.icu",
  390. "rimgo.kling.gg",
  391. "rimgo.projectsegfau.lt",
  392. "rimgo.nohost.network",
  393. "rimgo.drgns.space",
  394. "rimgo.quantenzitrone.eu",
  395. ],
  396. scribe: [
  397. "scribe.rip",
  398. "scribe.citizen4.eu",
  399. "scribe.bus-hit.me",
  400. "scribe.rawbit.ninja",
  401. "m.opnxng.com",
  402. ],
  403. teddit: [
  404. "i.opnxng.com",
  405. "reddit.lol",
  406. "teddit.bus-hit.me",
  407. "teddit.hostux.net",
  408. "teddit.net",
  409. "teddit.no-logs.com",
  410. "teddit.projectsegfau.lt",
  411. "teddit.pussthecat.org",
  412. "teddit.zaggy.nl",
  413. ],
  414. tent: ["tent.sny.sh", "tent.bloatcat.tk"],
  415. tubo: ["tubo.migalmoreno.com"],
  416. wikiless: [
  417. "wikiless.tiekoetter.com",
  418. "wikiless.funami.tech",
  419. "wikiless.rawbit.ninja",
  420. "wiki.adminforge.de",
  421. "wikiless.rafo.tech",
  422. "wiki.seitan-ayoub.lol",
  423. "wikiless.ftw.lol",
  424. "wl.ftw.lol",
  425. ],
  426. searx: [
  427. "search.bus-hit.me",
  428. "search.projectsegfau.lt",
  429. "northboot.xyz",
  430. "opnxng.com",
  431. ],
  432. searxng: [
  433. "search.sapti.me",
  434. "priv.au",
  435. "www.gruble.de",
  436. "search.lvkaszus.pl",
  437. "searx.divided-by-zero.eu",
  438. "searx.perennialte.ch",
  439. "search.mdosch.de",
  440. "searx.kutay.dev",
  441. "searx.si",
  442. "searx.namejeff.xyz",
  443. "search.whateveritworks.org",
  444. "searx.work",
  445. "search.smnz.de",
  446. "searx.prvcy.eu",
  447. "searx.headpat.exchange",
  448. ],
  449. hackernews: {
  450. better: "better-hackernews.vercel.app",
  451. worker: "news.workers.tools",
  452. },
  453. };
  454.  
  455. let farsideInstance = keepHistory ? "farside.link/_" : "farside.link";
  456.  
  457. // // // // // // // // // // // // //
  458.  
  459. const hash = window.location.hash,
  460. scheme = `${window.location.protocol}//`;
  461.  
  462. let debug_mode = false;
  463.  
  464. if (debug_mode) {
  465. alert(
  466. "\n== DEBUG MODE IS ON ==" +
  467. "\nIf you're seeing this" +
  468. "\nset the debug_mode value to" +
  469. "\nfalse for Privacy Redirector." +
  470. "\n======================" +
  471. "\n\nHostname: " +
  472. window.location.hostname +
  473. "\nPath: " +
  474. window.location.pathname +
  475. "\nQuery: " +
  476. window.location.search +
  477. "\nHash: " +
  478. hash
  479. );
  480. }
  481.  
  482. let selectedInstance = "",
  483. newURL = "";
  484.  
  485. const getrandom = async (instances) =>
  486. instances[Math.floor(Math.random() * instances.length)];
  487.  
  488. async function redirectInstagram() {
  489. if (instagram[0]) {
  490. window.stop();
  491. let pathname = window.location.pathname;
  492. let search = window.location.search;
  493. let params = new URLSearchParams(search);
  494.  
  495. selectedInstance = await getrandom(Instances.proxigram);
  496.  
  497. switch (true) {
  498. case pathname.startsWith("/accounts/login/"):
  499. case pathname.startsWith("/accounts/signup/"):
  500. pathname = pathname.replace(/^\/accounts\/(login|signup)\/[a-z]*/, "");
  501. params.delete("next");
  502. search = params.size ? `?${params}` : "";
  503. break;
  504. case pathname.startsWith("/reel/"):
  505. case pathname.startsWith("/tv/"):
  506. pathname = pathname.replace(/^\/(reel|tv)\//, "/p/");
  507. break;
  508. case pathname.endsWith("/reels/"):
  509. pathname = pathname.replace("/reels", "");
  510. break;
  511. }
  512. newURL = `${scheme}${selectedInstance}${pathname}${search}${hash}`;
  513. window.location.replace(newURL);
  514. }
  515. }
  516.  
  517. async function redirectTwitter() {
  518. if (twitter[0]) {
  519. window.stop();
  520.  
  521. let newPathName = "";
  522. let newQuery = "";
  523.  
  524. selectedInstance = twitter[1]
  525. ? `${farsideInstance}/nitter`
  526. : await getrandom(Instances.nitter);
  527.  
  528. newURL = `${scheme}${selectedInstance}${window.location.pathname}${window.location.search}${hash}`;
  529. if (window.location.pathname.startsWith("/i/flow/login")) {
  530. newPathName = window.location.pathname.replace("/i/flow/login", "");
  531. newQuery = window.location.search.replace(
  532. "?redirect_after_login=%2F",
  533. "/"
  534. );
  535. newURL = `${scheme}${selectedInstance}${newPathName}${newQuery}${hash}`;
  536. }
  537. window.location.replace(newURL);
  538. }
  539. }
  540.  
  541. async function redirectReddit() {
  542. if (reddit[0] && !window.location.pathname.startsWith("/domain")) {
  543. window.stop();
  544.  
  545. selectedInstance = reddit[1]
  546. ? `${farsideInstance}/${redditFrontend}`
  547. : await getrandom(Instances[redditFrontend]);
  548.  
  549. newURL = `${scheme}${selectedInstance}${window.location.pathname}${window.location.search}${hash}`;
  550.  
  551. window.location.replace(newURL);
  552. }
  553. }
  554.  
  555. async function redirectYoutube(frontend) {
  556. if (youtube[0]) {
  557. window.stop();
  558. if (frontend !== "tubo") {
  559. selectedInstance =
  560. youtube[1] && frontend !== "hyperpipe"
  561. ? `${farsideInstance}/${frontend}`
  562. : await getrandom(Instances[frontend]);
  563.  
  564. newURL = `${scheme}${selectedInstance}${window.location.pathname}${window.location.search}${hash}`;
  565. } else {
  566. selectedInstance = await getrandom(Instances.tubo);
  567.  
  568. newURL = `${scheme}${selectedInstance}/stream?url=${window.location.href}`;
  569. if (
  570. window.location.pathname.startsWith("/@") ||
  571. window.location.pathname.startsWith("/channel")
  572. ) {
  573. newURL = `${scheme}${selectedInstance}/channel?url=${window.location.href}`;
  574. }
  575. }
  576. window.location.replace(newURL);
  577. }
  578. }
  579.  
  580. async function redirectTiktok() {
  581. if (tiktok[0]) {
  582. window.stop();
  583. let pathname = window.location.pathname;
  584. selectedInstance = tiktok[1]
  585. ? `${farsideInstance}/proxitok`
  586. : await getrandom(Instances.proxitok);
  587.  
  588. if (pathname.startsWith("/foryou")) {
  589. pathname = pathname.replace("/foryou", "/trending");
  590. } else if (pathname.startsWith("/discover/")) {
  591. pathname = pathname.replace("discover", "tag");
  592. }
  593. newURL = `${scheme}${selectedInstance}${pathname}${window.location.search}${hash}`;
  594. window.location.replace(newURL);
  595. }
  596. }
  597.  
  598. async function redirectImgur() {
  599. if (imgur[0]) {
  600. window.stop();
  601.  
  602. selectedInstance = imgur[1]
  603. ? `${farsideInstance}/rimgo`
  604. : await getrandom(Instances.rimgo);
  605.  
  606. newURL = `${scheme}${selectedInstance}${window.location.pathname}${window.location.search}${hash}`;
  607.  
  608. window.location.replace(newURL);
  609. }
  610. }
  611.  
  612. async function redirectMedium() {
  613. if (medium[0]) {
  614. const host_path = `${window.location.hostname}${window.location.pathname}`;
  615.  
  616. if (
  617. (/^.+?\.medium\.com\/.+/.test(host_path) ||
  618. /^\/@?[a-z0-9\-\_]+\//.test(window.location.pathname) ||
  619. host_path === "medium.com/") &&
  620. !(
  621. /^\/(tag|m|hc)\//.test(window.location.pathname) ||
  622. /\/(about|followers|following)/.test(window.location.pathname)
  623. )
  624. ) {
  625. window.stop();
  626. selectedInstance = medium[1]
  627. ? `${farsideInstance}/scribe`
  628. : await getrandom(Instances.scribe);
  629. newURL = `${scheme}${selectedInstance}${window.location.pathname}${window.location.search}${hash}`;
  630. window.location.replace(newURL);
  631. }
  632. }
  633. }
  634.  
  635. async function redirectHackerNews() {
  636. if (hackernews[0]) {
  637. let pathname = window.location.pathname;
  638. if (
  639. ["/newest", "/item", "/user", "/ask", "/show", "/jobs", "/"].includes(
  640. pathname
  641. )
  642. ) {
  643. if (
  644. hackernewsFrontend === "better" &&
  645. window.location.pathname === "/newest"
  646. ) {
  647. pathname = "/new";
  648. }
  649. selectedInstance = Instances.hackernews[hackernewsFrontend];
  650. } else if (
  651. ["/best", "/news", "/submitted", "/threads", "/classic"].includes(
  652. pathname
  653. )
  654. ) {
  655. selectedInstance = Instances.hackernews.worker;
  656. }
  657. if (selectedInstance) {
  658. window.stop();
  659. newURL = `${scheme}${selectedInstance}${pathname}${window.location.search}`;
  660. window.location.replace(newURL);
  661. }
  662. }
  663. }
  664.  
  665. async function redirectGTranslate() {
  666. if (gtranslate[0]) {
  667. window.stop();
  668.  
  669. selectedInstance = gtranslate[1]
  670. ? `${farsideInstance}/lingva`
  671. : await getrandom(Instances.lingva);
  672.  
  673. newURL = `${scheme}${selectedInstance}`;
  674. if (window.location.search) {
  675. const params = new URLSearchParams(window.location.search);
  676. newURL += `/${params.get("sl")}/${params.get("tl")}/${params.get(
  677. "text"
  678. )}`;
  679. } else if (/^\/\w+\/\w+\/.*/.test(window.location.pathname)) {
  680. newURL += window.location.pathname.replace(/\+/g, " ");
  681. }
  682. window.location.replace(newURL);
  683. }
  684. }
  685.  
  686. async function redirectReuters() {
  687. if (reuters[0]) {
  688. window.stop();
  689. location.hostname = "neuters.de";
  690. }
  691. }
  692.  
  693. async function redirectWikipedia() {
  694. if (wikipedia[0]) {
  695. window.stop();
  696. let langCode = /^([a-z\-]+)\./.exec(window.location.hostname)[1];
  697.  
  698. selectedInstance = wikipedia[1]
  699. ? `${farsideInstance}/wikiless`
  700. : await getrandom(Instances.wikiless);
  701.  
  702. if (langCode === "www") langCode = "en";
  703. newURL = `${scheme}${selectedInstance}${window.location.pathname}?lang=${langCode}${hash}`;
  704. window.location.replace(newURL);
  705. }
  706. }
  707.  
  708. async function redirectImdb() {
  709. if (imdb[0]) {
  710. window.stop();
  711.  
  712. selectedInstance = imdb[1]
  713. ? `${farsideInstance}/libremdb`
  714. : await getrandom(Instances.libremdb);
  715.  
  716. newURL = `${scheme}${selectedInstance}${window.location.pathname}${window.location.search}${hash}`;
  717.  
  718. window.location.replace(newURL);
  719. }
  720. }
  721.  
  722. async function redirectQuora() {
  723. if (quora[0]) {
  724. window.stop();
  725.  
  726. selectedInstance = quora[1]
  727. ? `${farsideInstance}/quetre`
  728. : await getrandom(Instances.quetre);
  729.  
  730. newURL = `${scheme}${selectedInstance}${window.location.pathname}${window.location.search}${hash}`;
  731.  
  732. window.location.replace(newURL);
  733. }
  734. }
  735.  
  736. async function redirectFandom() {
  737. if (fandom[0]) {
  738. selectedInstance = await getrandom(Instances.breezewiki);
  739. const fandomName = window.location.hostname.replace(/\..+/, "");
  740. window.stop();
  741.  
  742. newURL = `${scheme}${selectedInstance}`;
  743. if (fandomName !== "www") {
  744. newURL += `/${fandomName}${window.location.pathname}${window.location.search}${hash}`;
  745. }
  746.  
  747. window.location.replace(newURL);
  748. }
  749. }
  750.  
  751. async function redirectGoogle() {
  752. if (
  753. google[0] &&
  754. window.location.hostname.startsWith("www") &&
  755. window.location.pathname.startsWith("/search")
  756. ) {
  757. window.stop();
  758.  
  759. selectedInstance = google[1]
  760. ? `${farsideInstance}/${googleFrontend}`
  761. : (selectedInstance = await getrandom(Instances[googleFrontend]));
  762.  
  763. let pathname = window.location.pathname;
  764. if (googleFrontend === "librey" && pathname === "/search")
  765. pathname += ".php";
  766. const params = new URLSearchParams(window.location.search);
  767. const query = params.entries().q;
  768. const search = query ? `?q=${query}` : window.location.search;
  769. newURL = `${scheme}${selectedInstance}${pathname}${search}${hash}`;
  770. window.location.replace(newURL);
  771. }
  772. }
  773.  
  774. async function redirectGoodreads() {
  775. if (goodreads[0]) {
  776. window.stop();
  777.  
  778. selectedInstance = await getrandom(Instances.biblioreads);
  779.  
  780. newURL = `${scheme}${selectedInstance}${window.location.pathname}${window.location.search}${hash}`;
  781. if (window.location.pathname.startsWith("/search")) {
  782. const params = new URLSearchParams(window.location.search);
  783. newURL = `${scheme}${selectedInstance}${
  784. window.location.pathname
  785. }/${params.get("q")}${hash}`;
  786. }
  787. window.location.replace(newURL);
  788. }
  789. }
  790.  
  791. async function redirectStackoverflow() {
  792. if (
  793. stackoverflow[0] &&
  794. (window.location.pathname.startsWith("/questions/") ||
  795. window.location.pathname === "/")
  796. ) {
  797. window.stop();
  798. selectedInstance = stackoverflow[1]
  799. ? `${farsideInstance}/anonymousoverflow`
  800. : await getrandom(Instances.anonymousoverflow);
  801.  
  802. newURL = `${scheme}${selectedInstance}${window.location.pathname}${window.location.search}${hash}`;
  803. window.location.replace(newURL);
  804. }
  805. }
  806.  
  807. async function redirectBandcamp() {
  808. if (bandcamp[0]) {
  809. // thanks to libredirect
  810.  
  811. selectedInstance = await getrandom(Instances.tent);
  812. const params = new URLSearchParams(window.location.search);
  813.  
  814. if (
  815. `${window.location.hostname}${window.location.pathname}` ===
  816. "bandcamp.com/search"
  817. ) {
  818. newURL = `${scheme}${selectedInstance}/search.php?query=${params.get(
  819. "q"
  820. )}`;
  821. }
  822.  
  823. if (window.location.hostname.search(/(daily)?\.bandcamp\.com/) > 0) {
  824. const artist = window.location.hostname.replace(/\..+/, "");
  825. if (window.location.pathname === "/") {
  826. newURL = `${scheme}${selectedInstance}/artist.php?name=${artist}`;
  827. } else {
  828. const regex = /^\/(.+?)\/(.+)/.exec(window.location.pathname);
  829. if (regex) {
  830. const type = regex[1];
  831. const name = regex[2];
  832. newURL = `${scheme}${selectedInstance}/release.php?artist=${artist}&type=${type}&name=${name}`;
  833. }
  834. }
  835. }
  836.  
  837. if (window.location.hostname === "f4.bcbits.com") {
  838. const image = /^\/img\/(.+)/.exec(window.location.pathname)[1];
  839. newURL = `${scheme}${selectedInstance}/image.php?file=${image}`;
  840. }
  841.  
  842. if (window.location.hostname === "t4.bcbits.com") {
  843. const regex = /^\/stream\/([a-f0-9]+)\/(.+)\/([0-9]+)/.exec(
  844. window.location.pathname
  845. );
  846. if (regex) {
  847. const directory = regex[1];
  848. const format = regex[2];
  849. const file = regex[3];
  850. const token = params.get("token");
  851. newURL = `${scheme}${selectedInstance}/audio.php?directory=${directory}&format=${format}&file=${file}&token=${token}`;
  852. }
  853. }
  854.  
  855. if (newURL) window[(stop(), location.replace(newURL))];
  856. }
  857. }
  858.  
  859. async function redirectGenius() {
  860. if (genius[0]) {
  861. const searchpath = `${window.location.pathname}${window.location.search}`;
  862.  
  863. selectedInstance = await getrandom(Instances[geniusFrontend]);
  864. switch (geniusFrontend) {
  865. case "dumb":
  866. newURL = `${scheme}${selectedInstance}${searchpath}${hash}`;
  867. break;
  868. case "intellectual":
  869. if (window.location.pathname.endsWith("-lyrics")) {
  870. newURL = `${scheme}${selectedInstance}/lyrics?path=${searchpath.slice(
  871. 1
  872. )}${hash}`;
  873. } else if (window.location.pathname.startsWith("/albums/")) {
  874. newURL = `${scheme}${selectedInstance}${searchpath.replace(
  875. "/albums",
  876. "/album?path=albums"
  877. )}${hash}`;
  878. } else if (window.location.pathname.startsWith("/artists/")) {
  879. newURL = `${scheme}${selectedInstance}${searchpath.replace(
  880. "/artists",
  881. "/artist?path=artists"
  882. )}${hash}`;
  883. }
  884. break;
  885. }
  886.  
  887. if (newURL) window[(stop(), location.replace(newURL))];
  888. }
  889. }
  890.  
  891. async function redirectPinterest() {
  892. if (pinterest[0]) {
  893. selectedInstance = await getrandom(Instances.binternet);
  894.  
  895. if (window.location.hostname === "i.pinimg.com") {
  896. newURL = `${scheme}${selectedInstance}/image_proxy.php?url=${window.location.href}`;
  897. } else if (window.location.pathname.startsWith("/search")) {
  898. newURL = `${scheme}${selectedInstance}${window.location.pathname
  899. .replace("search", "search.php")
  900. .replace("/pins/", "")}${window.location.search}${hash}`;
  901. } else if (window.location.pathname === "/") {
  902. newURL = `${scheme}${selectedInstance}`;
  903. }
  904.  
  905. if (newURL) window[(stop(), location.replace(newURL))];
  906. }
  907. }
  908.  
  909. async function redirectSoundcloud() {
  910. if (soundcloud[0]) {
  911. window.stop();
  912. selectedInstance = await getrandom(Instances.tubo);
  913.  
  914. newURL = `${scheme}${selectedInstance}/kiosk?serviceId=1`;
  915. if (window.location.pathname !== "/") {
  916. newURL = `${scheme}${selectedInstance}/stream?url=${window.location.href}`;
  917. }
  918. window.location.replace(newURL);
  919. }
  920. }
  921.  
  922. const urlHostname = window.location.hostname;
  923.  
  924. switch (urlHostname) {
  925. case "www.instagram.com":
  926. redirectInstagram();
  927. break;
  928.  
  929. case "twitter.com":
  930. case "mobile.twitter.com":
  931. redirectTwitter();
  932. break;
  933.  
  934. case "www.youtube.com":
  935. case "m.youtube.com":
  936. case "www.youtube-nocookie.com":
  937. redirectYoutube(youtubeFrontend);
  938. break;
  939.  
  940. case "www.tiktok.com":
  941. redirectTiktok();
  942. break;
  943.  
  944. case "music.youtube.com":
  945. redirectYoutube(youtubeMusicFrontend);
  946. break;
  947.  
  948. case "news.ycombinator.com":
  949. redirectHackerNews();
  950. break;
  951.  
  952. case "translate.google.com":
  953. redirectGTranslate();
  954. break;
  955.  
  956. case "www.reuters.com":
  957. redirectReuters();
  958. break;
  959.  
  960. case "www.imdb.com":
  961. case "m.imdb.com":
  962. redirectImdb();
  963. break;
  964.  
  965. case "www.quora.com":
  966. redirectQuora();
  967. break;
  968.  
  969. case "www.google.com":
  970. redirectGoogle();
  971. break;
  972.  
  973. case "www.goodreads.com":
  974. redirectGoodreads();
  975. break;
  976.  
  977. case "genius.com":
  978. redirectGenius();
  979. break;
  980.  
  981. case "stackoverflow.com":
  982. redirectStackoverflow();
  983. break;
  984.  
  985. case "f4.bcbits.com":
  986. case "t4.bcbits.com":
  987. redirectBandcamp();
  988. break;
  989.  
  990. case "i.pinimg.com":
  991. redirectPinterest();
  992. break;
  993.  
  994. case "soundcloud.com":
  995. case "m.soundcloud.com":
  996. redirectSoundcloud();
  997. break;
  998.  
  999. case urlHostname.includes("reddit.com") ? urlHostname : 0:
  1000. redirectReddit();
  1001. break;
  1002.  
  1003. case urlHostname.includes("medium.com") ? urlHostname : 0:
  1004. redirectMedium();
  1005. break;
  1006.  
  1007. case urlHostname.includes("imgur.com") ? urlHostname : 0:
  1008. case urlHostname.includes("imgur.io") ? urlHostname : 0:
  1009. redirectImgur();
  1010. break;
  1011.  
  1012. case urlHostname.includes("wikipedia.org") ? urlHostname : 0:
  1013. redirectWikipedia();
  1014. break;
  1015.  
  1016. case urlHostname.includes("fandom.com") ? urlHostname : 0:
  1017. redirectFandom();
  1018. break;
  1019.  
  1020. case urlHostname.includes("bandcamp.com") ? urlHostname : 0:
  1021. redirectBandcamp();
  1022. break;
  1023.  
  1024. case urlHostname.includes("pinterest.com") ? urlHostname : 0:
  1025. redirectPinterest();
  1026. break;
  1027. }