Advertisement
Guest User

privacy redirector qutebrowser

a guest
Nov 13th, 2023
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 32.09 KB | None | 0 0
  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.4.8
  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 *://*.instagram.com/*
  73. // @match *://*.medium.com/*
  74. // @match *://*.pinterest.com/*
  75. // @match *://i.pinimg.com/*
  76. // @match *://*.quora.com/*
  77. // @match *://*.reddit.com/*
  78. // @match *://*.reuters.com/*
  79. // @match *://*.twitter.com/*
  80. // @match *://*.wikipedia.org/*
  81. // @match *://*.youtube-nocookie.com/*
  82. // @match *://*.youtube.com/*
  83. // @match *://*.soundcloud.com/*
  84. // @match *://f4.bcbits.com/*
  85. // @match *://genius.com/*
  86. // @match *://imgur.com/*
  87. // @match *://instagram.com/*
  88. // @match *://medium.com/*
  89. // @match *://news.ycombinator.com/*
  90. // @match *://reddit.com/*
  91. // @match *://stackoverflow.com/*
  92. // @match *://t4.bcbits.com/*
  93. // @match *://translate.google.com/*
  94. // @match *://twitter.com/*
  95. // @match *://www.goodreads.com/*
  96. // @match *://youtube.com/*
  97. // ==/UserScript==
  98.  
  99. /*
  100. ___ _ _ ___ _____ _____
  101. / _ \| \ | | / _ \| ___| ___|
  102. | | | | \| |_____| | | | |_ | |_
  103. | |_| | |\ |_____| |_| | _| | _|
  104. \___/|_| \_| \___/|_| |_|
  105.  
  106. CHANGE THE RELEVANT VALUE TO "false" TO
  107. DISABLE THE REDIRECTION/FARSIDE FOR THAT
  108. PARTICULAR PLATFORM */
  109.  
  110. // REDIRECTON / FARSIDE
  111.  
  112. let bandcamp = [true, true];
  113. let fandom = [true, true];
  114. let genius = [true, true];
  115. let goodreads = [true, false];
  116. let google = [true, true];
  117. let gtranslate = [true, true];
  118. let hackernews = [true, true];
  119. let imdb = [true, true];
  120. let imgur = [true, true];
  121. let medium = [true, true];
  122. let pinterest = [true, true];
  123. let quora = [true, true];
  124. let reddit = [false, true];
  125. let reuters = [true, true];
  126. let soundcloud = [true, true];
  127. let stackoverflow = [true, true];
  128. let twitter = [true, true];
  129. let wikipedia = [true, true];
  130. let youtube = [true, true];
  131. // REDIRECTON / FARSIDE / WARNING
  132. let instagram = [true, false, true];
  133.  
  134. // PREFERRED FRONTEND
  135. let youtubeFrontend = "invidious"; // accepts "invidious", "piped", "tubo"
  136. let youtubeMusicFrontend = "beatbump"; // accepts "beatbump", "invidious", "piped"
  137. let redditFrontend = "libreddit"; // accepts "libreddit", "teddit"
  138. let googleFrontend = "searxng"; // accepts "searx", "searxng"
  139. let geniusFrontend = "intellectual"; // accept dumb, intellectual
  140.  
  141. // OTHER SETTINGS
  142. let keepHistory = false; // keeps farside.link in the browser history
  143.  
  144. // // // // // // // // // // // // //
  145.  
  146. /*
  147. ___ _
  148. |_ _|_ __ ___| |_ __ _ _ __ ___ ___ ___
  149. | || '_ \/ __| __/ _` | '_ \ / __/ _ \/ __|
  150. | || | | \__ \ || (_| | | | | (_| __/\__ \
  151. |___|_| |_|___/\__\__,_|_| |_|\___\___||___/
  152.  
  153. LIST OF INSTANCES TO USE IF FARSIDE IS NOT ENABLED
  154. */
  155.  
  156. let anonymousoverflowInstances = [
  157. "code.whatever.social",
  158. "ao.vern.cc",
  159. "overflow.smnz.de",
  160. "overflow.lunar.icu",
  161. ];
  162.  
  163. let beatbumpInstances = ["beatbump.ml", "bb.eu.projectsegfau.lt"];
  164.  
  165. let bibliogramInstances = ["ig.tokhmi.xyz", "bibliogram.froth.zone"];
  166.  
  167. let biblioreadsInstances = [
  168. "biblioreads.ml",
  169. "biblioreads.ga",
  170. "biblioreads.netlify.app",
  171. ];
  172.  
  173. let binternetInstances = [
  174. "binternet.ahwx.org",
  175. "binternet.revvy.de",
  176. "binternet.bloatcat.tk",
  177. "bn.vern.cc",
  178. "pinterest.foxhaven.cyou",
  179. ];
  180.  
  181. let breezewikiInstances = [
  182. "breezewiki.com",
  183. "breezewiki.pussthecat.org",
  184. "antifandom.com",
  185. "bw.hamstro.dev",
  186. ];
  187.  
  188. let dumbInstances = [
  189. "dm.vern.cc",
  190. "sing.whatever.social",
  191. "dumb.lunar.icu",
  192. "dumb.privacydev.net",
  193. ];
  194.  
  195. let intellectualInstances = ["intellectual.insprill.net"];
  196.  
  197. let invidiousInstances = [
  198. "vid.puffyan.us",
  199. "yt.artemislena.eu",
  200. "invidious.projectsegfau.lt",
  201. ];
  202.  
  203. let pipedInstances = [
  204. "pipedapi.video",
  205. "pipedapi.tokhmi.xyz",
  206. "piped.projectsegfau.lt",
  207. "piped.privacydev.net",
  208. ];
  209.  
  210. let libredditInstances = [
  211. "libreddit.invak.id",
  212. "libreddit.de",
  213. "libreddit.kavin.rocks",
  214. "libreddit.kutay.dev",
  215. ];
  216.  
  217. let libremdbInstances = [
  218. "libremdb.pussthecat.org",
  219. "libremdb.iket.me",
  220. "libremdb.lunar.icu",
  221. "binge.whatever.social",
  222. ];
  223.  
  224. let lingvaInstances = [
  225. "lingva.ml",
  226. "translate.igna.wtf",
  227. "translate.plausibility.cloud",
  228. "translate.projectsegfau.lt",
  229. ];
  230.  
  231. let nitterInstances = [
  232. "nitter.net",
  233. "nitter.lacontrevoie.fr",
  234. "nitter.fdn.fr",
  235. "nitter.1d4.us",
  236. "nitter.kavin.rocks",
  237. ];
  238.  
  239. let quetreInstances = [
  240. "quetre.iket.me",
  241. "quora.vern.cc",
  242. "quetre.pussthecat.org",
  243. "quetre.tokhmi.xyz",
  244. ];
  245.  
  246. let rimgoInstances = [
  247. "rimgo.pussthecat.org",
  248. "rimgo.totaldarkness.net",
  249. "rimgo.bus-hit.me",
  250. "imgur.artemislena.eu",
  251. ];
  252.  
  253. let scribeInstances = [
  254. "scribe.rip",
  255. "scribe.nixnet.services",
  256. "scribe.citizen4.eu",
  257. "scribe.bus-hit.me",
  258. ];
  259.  
  260. let tedditInstances = [
  261. "teddit.pussthecat.org",
  262. "teddit.ggc-project.de",
  263. "teddit.domain.glass",
  264. "teddit.zaggy.nl",
  265. ];
  266.  
  267. let tentInstances = ["tent.sny.sh", "tent.bloatcat.tk", "tn.vern.cc"];
  268.  
  269. let tuboInstances = ["tubo.migalmoreno.com"];
  270.  
  271. let wikilessInstances = [
  272. "wikiless.org",
  273. "wikiless.tiekoetter.com",
  274. "wikiless.funami.tech",
  275. "wl.vern.cc",
  276. ];
  277.  
  278. let searxInstances = [
  279. "search.bus-hit.me",
  280. "search.projectsegfau.lt",
  281. "northboot.xyz",
  282. "opnxng.com",
  283. ];
  284.  
  285. let searxngInstances = [
  286. "baresearch.org",
  287. "dynabyte.ca",
  288. "search.bus-hit.me",
  289. "search.leptons.xyz",
  290. ];
  291.  
  292. let farsideInstance = "farside.link";
  293.  
  294. // // // // // // // // // // // // //
  295.  
  296. let debug_mode = false;
  297.  
  298. if (debug_mode == true) {
  299. alert(
  300. "\n== DEBUG MODE IS ON ==" +
  301. "\nIf you're seeing this" +
  302. "\nset the debug_mode value to" +
  303. "\nfalse for Privacy Redirctor." +
  304. "\n======================" +
  305. "\n\nHostname: " +
  306. window.location.hostname +
  307. "\nPath: " +
  308. window.location.pathname +
  309. "\nQuery: " +
  310. window.location.search +
  311. "\nHash: " +
  312. window.location.hash
  313. );
  314. }
  315.  
  316. if (keepHistory == true) farsideInstance = farsideInstance + "/_";
  317.  
  318. function redirectInstagram() {
  319. if (instagram[0] == true) {
  320. var selectedInstance = "";
  321. var newPathName = "";
  322. var newQuery = "";
  323. var tempURL = "";
  324.  
  325. function displayWarning() {
  326. if (instagram[2] == true) {
  327. alert(
  328. "Bibliogram is discontinued, you may want to disable the redirection." +
  329. "\n\nIf you don't want to see this warning, set Instagram's 'WARNING' to 'false' or set 'REDIRETON' to 'false' to turn off the Instagram redirect completely."
  330. );
  331. }
  332. }
  333.  
  334. if (instagram[1] == false) {
  335. selectedInstance =
  336. bibliogramInstances[
  337. Math.floor(Math.random() * bibliogramInstances.length)
  338. ];
  339. } else {
  340. selectedInstance = `${farsideInstance}/bibliogram`;
  341. }
  342.  
  343. if (window.location.pathname.startsWith("/accounts/login/")) {
  344. newPathName = window.location.pathname.replace("/accounts/login/", "");
  345. newQuery = window.location.search.replace("?next=", "");
  346. tempURL = `${window.location.protocol}//${selectedInstance}${newPathName}${newQuery}${window.location.hash}`;
  347. } else {
  348. tempURL = `${window.location.protocol}//${selectedInstance}${window.location.pathname}${window.location.search}${window.location.hash}`;
  349. }
  350.  
  351. if (tempURL.includes("/p/")) {
  352. displayWarning();
  353. window.stop();
  354. let newURL = `${tempURL}`;
  355. window.location.replace(newURL);
  356. } else if (tempURL.includes("/reels/")) {
  357. displayWarning();
  358. window.stop();
  359. let newURL = tempURL.replace("/reels/", "/p/");
  360. window.location.replace(newURL);
  361. }
  362. }
  363. }
  364.  
  365. function redirectTwitter() {
  366. if (twitter[0] == true) {
  367. window.stop();
  368.  
  369. var selectedInstance = "";
  370. var newPathName = "";
  371. var newQuery = "";
  372.  
  373. if (twitter[1] == false) {
  374. selectedInstance =
  375. nitterInstances[Math.floor(Math.random() * nitterInstances.length)];
  376. } else {
  377. selectedInstance = `${farsideInstance}/nitter`;
  378. }
  379.  
  380. if (window.location.pathname.startsWith("/i/flow/login")) {
  381. newPathName = window.location.pathname.replace("/i/flow/login", "");
  382. newQuery = window.location.search.replace(
  383. "?redirect_after_login=%2F",
  384. "/"
  385. );
  386. let newURL = `${window.location.protocol}//${selectedInstance}${newPathName}${newQuery}${window.location.hash}`;
  387. window.location.replace(newURL);
  388. } else {
  389. let newURL = `${window.location.protocol}//${selectedInstance}${window.location.pathname}${window.location.search}${window.location.hash}`;
  390. window.location.replace(newURL);
  391. }
  392. }
  393. }
  394.  
  395. function redirectReddit() {
  396. if (reddit[0] == true) {
  397. window.stop();
  398. var selectedInstance = "";
  399.  
  400. if (reddit[1] == false) {
  401. selectedInstance = eval(redditFrontend + "Instances")[
  402. Math.floor(Math.random() * eval(redditFrontend + "Instances.length"))
  403. ];
  404. } else {
  405. selectedInstance = `${farsideInstance}/${redditFrontend}`;
  406. }
  407.  
  408. let newURL = `${window.location.protocol}//${selectedInstance}${window.location.pathname}${window.location.search}${window.location.hash}`;
  409.  
  410. window.location.replace(newURL);
  411. }
  412. }
  413.  
  414. function redirectYoutube() {
  415. if (youtube[0] == true) {
  416. window.stop();
  417. var selectedInstance = "";
  418.  
  419. if (youtubeFrontend != "tubo") {
  420. if (youtube[1] == false) {
  421. selectedInstance = eval(youtubeFrontend + "Instances")[
  422. Math.floor(Math.random() * eval(youtubeFrontend + "Instances.length"))
  423. ];
  424. } else {
  425. selectedInstance = `${farsideInstance}/${youtubeFrontend}`;
  426. }
  427.  
  428. let newURL = `${window.location.protocol}//${selectedInstance}${window.location.pathname}${window.location.search}${window.location.hash}`;
  429.  
  430. window.location.replace(newURL);
  431. } else {
  432. selectedInstance =
  433. tuboInstances[Math.floor(Math.random() * tuboInstances.length)];
  434.  
  435. if (
  436. window.location.pathname.startsWith("/@") ||
  437. window.location.pathname.startsWith("/channel")
  438. ) {
  439. let newURL = `${window.location.protocol}//${selectedInstance}/channel?url=${window.location.href}`;
  440. window.location.replace(newURL);
  441. } else {
  442. let newURL = `${window.location.protocol}//${selectedInstance}/stream?url=${window.location.href}`;
  443. window.location.replace(newURL);
  444. }
  445. }
  446. }
  447. }
  448.  
  449. // function redirectTiktok() {
  450. // if (tiktok[0] == true) {
  451. // window.stop();
  452. // var selectedInstance = "";
  453. //
  454. // if (tiktok[1] == false) {
  455. // selectedInstance =
  456. // proxitokInstances[Math.floor(Math.random() * proxitokInstances.length)];
  457. // } else {
  458. // selectedInstance = `${farsideInstance}/proxitok`;
  459. // }
  460. //
  461. // if (window.location.pathname.startsWith("/discover")) {
  462. // let newURL = `${
  463. // window.location.protocol
  464. // }//${selectedInstance}${window.location.pathname.replace(
  465. // "discover",
  466. // "tag"
  467. // )}${window.location.hash}`;
  468. //
  469. // window.location.replace(newURL);
  470. // } else if (
  471. // window.location.pathname.search(/[a-z][a-z]\-[A-Z][A-Z]/g) != -1
  472. // ) {
  473. // let newURL = `${window.location.protocol}//${selectedInstance}${window.location.pathname}${window.location.search}${window.location.hash}`;
  474. //
  475. // window.location.replace(newURL);
  476. // } else {
  477. // let newURL = `${window.location.protocol}//${selectedInstance}${window.location.pathname}${window.location.search}${window.location.hash}`;
  478. //
  479. // window.location.replace(newURL);
  480. // }
  481. // }
  482. // }
  483.  
  484. function redirectImgur() {
  485. if (imgur[0] == true) {
  486. window.stop();
  487.  
  488. var selectedInstance = "";
  489.  
  490. if (imgur[1] == false) {
  491. selectedInstance =
  492. rimgoInstances[Math.floor(Math.random() * rimgoInstances.length)];
  493. } else {
  494. selectedInstance = `${farsideInstance}/rimgo`;
  495. }
  496.  
  497. let newURL = `${window.location.protocol}//${selectedInstance}${window.location.pathname}${window.location.search}${window.location.hash}`;
  498.  
  499. window.location.replace(newURL);
  500. }
  501. }
  502.  
  503. function redirectMedium() {
  504. if (medium[0] == true || window.location.pathname != "/") {
  505. window.stop();
  506. var selectedInstance = "";
  507.  
  508. if (medium[1] == false) {
  509. selectedInstance =
  510. scribeInstances[Math.floor(Math.random() * scribeInstances.length)];
  511. } else {
  512. selectedInstance = `${farsideInstance}/scribe`;
  513. }
  514.  
  515. let newURL = `${window.location.protocol}//${selectedInstance}${window.location.pathname}${window.location.search}${window.location.hash}`;
  516.  
  517. window.location.replace(newURL);
  518. }
  519. }
  520.  
  521. function redirectYoutubeMusic() {
  522. if (youtube[0] == true) {
  523. window.stop();
  524.  
  525. var beatbumpInstance =
  526. beatbumpInstances[Math.floor(Math.random() * beatbumpInstances.length)];
  527.  
  528. if (window.location.pathname.startsWith("/watch")) {
  529. if (youtube[1] == false) {
  530. selectedInstance = eval(youtubeFrontend + "Instances")[
  531. Math.floor(Math.random() * eval(youtubeFrontend + "Instances.length"))
  532. ];
  533. } else {
  534. selectedInstance = `${farsideInstance}/${youtubeFrontend}`;
  535. }
  536.  
  537. let newURL = `${window.location.protocol}//${selectedInstance}${window.location.pathname}${window.location.search}${window.location.hash}`;
  538.  
  539. window.location.replace(newURL);
  540. } else {
  541. let newURL = `${window.location.protocol}//${beatbumpInstance}${window.location.pathname}${window.location.search}${window.location.hash}`;
  542. window.location.replace(newURL);
  543. }
  544. }
  545. }
  546.  
  547. function redirectHackerNews() {
  548. if (
  549. hackernews[0] == true &&
  550. window.location.pathname != "/user" &&
  551. window.location.pathname != "/item"
  552. ) {
  553. window.stop();
  554. let newURL = `${window.location.protocol}//hn.algolia.com`;
  555. window.location.replace(newURL);
  556. }
  557. }
  558.  
  559. function redirectGTranslate() {
  560. if (gtranslate[0] == true) {
  561. window.stop();
  562. var selectedInstance = "";
  563.  
  564. if (gtranslate[1] == false) {
  565. selectedInstance =
  566. lingvaInstances[Math.floor(Math.random() * lingvaInstances.length)];
  567. } else {
  568. selectedInstance = `${farsideInstance}/lingva`;
  569. }
  570.  
  571. if (window.location.search != "") {
  572. let newURL =
  573. window.location.protocol +
  574. "//" +
  575. selectedInstance +
  576. window.location.pathname +
  577. window.location.search
  578. .replace(/\?hl=tr/, "")
  579. .replace(/.sl=/, "")
  580. .replace("&tl=", "/")
  581. .replace("&text=", "/")
  582. .replace("&op=translate", "") +
  583. window.location.hash;
  584.  
  585. window.location.replace(newURL);
  586. } else {
  587. let newURL = window.location.protocol + "//" + selectedInstance;
  588. window.location.replace(newURL);
  589. }
  590. }
  591. }
  592.  
  593. function redirectReuters() {
  594. if (reuters[0] == true) {
  595. window.stop();
  596. location.hostname = "neuters.de";
  597. }
  598. }
  599.  
  600. function redirectWikipedia() {
  601. if (wikipedia[0] == true) {
  602. window.stop();
  603. let langCodeIndex = window.location.hostname.search(/^[a-z][a-z]\./);
  604. var selectedInstance = "";
  605.  
  606. if (wikipedia[1] == false) {
  607. selectedInstance =
  608. wikilessInstances[Math.floor(Math.random() * wikilessInstances.length)];
  609. } else {
  610. selectedInstance = `${farsideInstance}/wikiless`;
  611. }
  612.  
  613. if (langCodeIndex != -1) {
  614. let newURL =
  615. window.location.protocol +
  616. "//" +
  617. selectedInstance +
  618. window.location.pathname +
  619. "?lang=" +
  620. window.location.hostname[langCodeIndex] +
  621. window.location.hostname[langCodeIndex + 1] +
  622. window.location.hash;
  623. window.location.replace(newURL);
  624. } else {
  625. let newURL = `${window.location.protocol}//${selectedInstance}${window.location.pathname}?lang=en${window.location.hash}`;
  626. window.location.replace(newURL);
  627. }
  628. }
  629. }
  630.  
  631. function redirectImdb() {
  632. if (imdb[0] == true) {
  633. window.stop();
  634. var selectedInstance = "";
  635.  
  636. if (imdb[1] == false) {
  637. selectedInstance =
  638. libremdbInstances[Math.floor(Math.random() * libremdbInstances.length)];
  639. } else {
  640. selectedInstance = `${farsideInstance}/libremdb`;
  641. }
  642.  
  643. let newURL = `${window.location.protocol}//${selectedInstance}${window.location.pathname}${window.location.search}${window.location.hash}`;
  644.  
  645. window.location.replace(newURL);
  646. }
  647. }
  648.  
  649. function redirectQuora() {
  650. if (quora[0] == true) {
  651. window.stop();
  652. var selectedInstance = "";
  653.  
  654. if (quora[1] == false) {
  655. selectedInstance =
  656. quetreInstances[Math.floor(Math.random() * quetreInstances.length)];
  657. } else {
  658. selectedInstance = `${farsideInstance}/quetre`;
  659. }
  660.  
  661. let newURL = `${window.location.protocol}//${selectedInstance}${window.location.pathname}${window.location.search}${window.location.hash}`;
  662.  
  663. window.location.replace(newURL);
  664. }
  665. }
  666.  
  667. function redirectFandom() {
  668. if (fandom[0] == true) {
  669. let randomInstance =
  670. breezewikiInstances[
  671. Math.floor(Math.random() * breezewikiInstances.length)
  672. ];
  673. let fandomName = window.location.hostname.replace(/\..*/, "");
  674. let newURL = "";
  675. window.stop();
  676.  
  677. if (fandomName !== "www") {
  678. newURL = `${window.location.protocol}//${randomInstance}/${fandomName}${window.location.pathname}${window.location.search}${window.location.hash}`;
  679. } else {
  680. newURL = `${window.location.protocol}//${randomInstance}`;
  681. }
  682.  
  683. window.location.replace(newURL);
  684. }
  685. }
  686.  
  687. function redirectGoogle() {
  688. if (
  689. google[0] == true &&
  690. window.location.hostname.startsWith("www") &&
  691. window.location.pathname.startsWith("/search")
  692. ) {
  693. window.stop();
  694. var selectedInstance = "";
  695.  
  696. if (google[1] == false) {
  697. selectedInstance = eval(googleFrontend + "Instances")[
  698. Math.floor(Math.random() * eval(googleFrontend + "Instances.length"))
  699. ];
  700. } else {
  701. selectedInstance = `${farsideInstance}/${googleFrontend}`;
  702. }
  703.  
  704. if (window.location.pathname.match("/")) {
  705. let newURL = `${window.location.protocol}//${selectedInstance}${window.location.pathname}${window.location.search}${window.location.hash}`;
  706. window.location.replace(newURL);
  707. } else {
  708. let newURL = `${window.location.protocol}//${selectedInstance}${
  709. window.location.pathname
  710. }${window.location.search.match(/\?q.+?(?=\&)/)}`;
  711. window.location.replace(newURL);
  712. }
  713. }
  714. }
  715.  
  716. function redirectGoodreads() {
  717. if (goodreads[0] == true) {
  718. window.stop();
  719.  
  720. var selectedInstance =
  721. biblioreadsInstances[
  722. Math.floor(Math.random() * biblioreadsInstances.length)
  723. ];
  724.  
  725. if (window.location.pathname.startsWith("/search")) {
  726. let newURL =
  727. `${window.location.protocol}//${selectedInstance}${window.location.pathname}` +
  728. window.location.search.replace(/.*.q\=/, "/") +
  729. `${window.location.hash}`;
  730. window.location.replace(newURL);
  731. } else {
  732. let newURL = `${window.location.protocol}//${selectedInstance}${window.location.pathname}${window.location.search}${window.location.hash}`;
  733. window.location.replace(newURL);
  734. }
  735. }
  736. }
  737.  
  738. function redirectStackoverflow() {
  739. if (
  740. stackoverflow[0] == true &&
  741. window.location.pathname.startsWith("/questions")
  742. ) {
  743. window.stop();
  744. if (stackoverflow[1] == false) {
  745. selectedInstance =
  746. anonymousoverflowInstances[
  747. Math.floor(Math.random() * anonymousoverflowInstances.length)
  748. ];
  749. } else {
  750. selectedInstance = `${farsideInstance}/anonymousoverflow`;
  751. }
  752.  
  753. let newURL = `${window.location.protocol}//${selectedInstance}${window.location.pathname}${window.location.search}${window.location.hash}`;
  754. window.location.replace(newURL);
  755. }
  756. }
  757.  
  758. function redirectBandcamp() {
  759. if (bandcamp[0] == true) {
  760. // thanks to libredirect
  761.  
  762. var selectedInstance =
  763. tentInstances[Math.floor(Math.random() * tentInstances.length)];
  764.  
  765. if (
  766. window.location.hostname == "bandcamp.com" &&
  767. window.location.pathname == "/search"
  768. ) {
  769. const query = window.location.searchParams.get("q");
  770. let newURL = `${
  771. window.location.protocol
  772. }//${selectedInstance}/search.php?query=${encodeURIComponent(query)}`;
  773. window.location.replace(newURL);
  774. }
  775.  
  776. if (window.location.hostname.endsWith("bandcamp.com")) {
  777. const regex = /^(.*)\.bandcamp\.com/.exec(window.location.hostname);
  778. const artist = regex[1];
  779. if (window.location.pathname == "/") {
  780. let newURL = `${window.location.protocol}//${selectedInstance}/artist.php?name=${artist}`;
  781. window.location.replace(newURL);
  782. } else {
  783. const regex = /^\/(.*)\/(.*)/.exec(window.location.pathname);
  784. if (regex) {
  785. const type = regex[1];
  786. const name = regex[2];
  787. let newURL = `${window.location.protocol}//${selectedInstance}/release.php?artist=${artist}&type=${type}&name=${name}`;
  788. window.location.replace(newURL);
  789. }
  790. }
  791. }
  792.  
  793. if (window.location.hostname == "f4.bcbits.com") {
  794. const regex = /\/img\/(.*)/.exec(window.location.pathname);
  795. const image = regex[1];
  796. let newURL = `${window.location.protocol}//${selectedInstance}/image.php?file=${image}`;
  797. window.location.replace(newURL);
  798. }
  799.  
  800. if (window.location.hostname == "t4.bcbits.com") {
  801. const regex = /\/stream\/(.*)\/(.*)\/(.*)/.exec(window.location.pathname);
  802. if (regex) {
  803. const directory = regex[1];
  804. const format = regex[2];
  805. const file = regex[3];
  806. const token = window.location.searchParams.get("token");
  807. let newURL = `${
  808. window.location.protocol
  809. }//${selectedInstance}/audio.php/?directory=${directory}&format=${format}&file=${file}&token=${encodeURIComponent(
  810. token
  811. )}`;
  812. window.location.replace(newURL);
  813. }
  814. }
  815. }
  816. }
  817.  
  818. function redirectGenius() {
  819. if (genius[0] == true) {
  820. switch (geniusFrontend) {
  821. case "dumb":
  822. window.stop();
  823. var selectedInstance =
  824. dumbInstances[Math.floor(Math.random() * dumbInstances.length)];
  825.  
  826. let newURL = `${window.location.protocol}//${selectedInstance}${window.location.pathname}${window.location.search}${window.location.hash}`;
  827. window.location.replace(newURL);
  828. break;
  829. case "intellectual":
  830. var selectedInstance =
  831. intellectualInstances[
  832. Math.floor(Math.random() * intellectualInstances.length)
  833. ];
  834.  
  835. if (window.location.pathname.endsWith("-lyrics")) {
  836. window.stop();
  837. selectedInstance = selectedInstance + "/lyrics?path=";
  838. let newURL = `${window.location.protocol}//${selectedInstance}${window.location.pathname}${window.location.search}${window.location.hash}`;
  839. window.location.replace(newURL);
  840. } else if (window.location.pathname.startsWith("/albums")) {
  841. window.stop();
  842. let newURL =
  843. `${window.location.protocol}//${selectedInstance}` +
  844. `${window.location.pathname}${window.location.search}`.replace(
  845. "/albums",
  846. "/album?path=albums"
  847. ) +
  848. `${window.location.hash}`;
  849. window.location.replace(newURL);
  850. } else if (window.location.pathname.startsWith("/artists")) {
  851. window.stop();
  852. let newURL =
  853. `${window.location.protocol}//${selectedInstance}` +
  854. `${window.location.pathname}${window.location.search}`.replace(
  855. "/artists",
  856. "/artist?path=artists"
  857. ) +
  858. `${window.location.hash}`;
  859. window.location.replace(newURL);
  860. }
  861. break;
  862. }
  863. }
  864. }
  865.  
  866. function redirectPinterest() {
  867. if (pinterest[0] == true) {
  868. window.stop();
  869.  
  870. var selectedInstance =
  871. binternetInstances[Math.floor(Math.random() * binternetInstances.length)];
  872.  
  873. if (window.location.hostname == "i.pinimg.com") {
  874. let newURL = `${window.location.protocol}//${selectedInstance}/image_proxy.php?url=${window.location.href}`;
  875. window.location.replace(newURL);
  876. } else if (window.location.pathname.startsWith("/search")) {
  877. let newURL =
  878. `${window.location.protocol}//${selectedInstance}` +
  879. window.location.pathname
  880. .replace("search", "search.php")
  881. .replace("/pins/", "") +
  882. `${window.location.search}${window.location.hash}`;
  883. window.location.replace(newURL);
  884. } else if (window.location.pathname.startsWith("/pin")) {
  885. return;
  886. } else {
  887. let newURL = `${window.location.protocol}//${selectedInstance}/`;
  888. window.location.replace(newURL);
  889. }
  890. }
  891. }
  892.  
  893. function redirectSoundcloud() {
  894. if (soundcloud[0] == true) {
  895. window.stop();
  896. var selectedInstance =
  897. tuboInstances[Math.floor(Math.random() * tuboInstances.length)];
  898.  
  899. if (window.location.pathname != "/") {
  900. let newURL = `${window.location.protocol}//${selectedInstance}/stream?url=${window.location.href}`;
  901. window.location.replace(newURL);
  902. } else {
  903. let newURL = `${window.location.protocol}//${selectedInstance}/kiosk?serviceId=1`;
  904. window.location.replace(newURL);
  905. }
  906. }
  907. }
  908.  
  909. let urlHostname = window.location.hostname;
  910.  
  911. switch (urlHostname) {
  912. case "www.instagram.com":
  913. redirectInstagram();
  914. break;
  915.  
  916. case "twitter.com":
  917. case "mobile.twitter.com":
  918. redirectTwitter();
  919. break;
  920.  
  921. case "www.reddit.com":
  922. case "old.reddit.com":
  923. redirectReddit();
  924. break;
  925.  
  926. case "www.youtube.com":
  927. case "m.youtube.com":
  928. case "www.youtube-nocookie.com":
  929. redirectYoutube();
  930. break;
  931.  
  932. case "music.youtube.com":
  933. if (youtubeMusicFrontend == "beatbump") {
  934. redirectYoutubeMusic();
  935. } else {
  936. redirectYoutube();
  937. }
  938. break;
  939.  
  940. case "news.ycombinator.com":
  941. redirectHackerNews();
  942. break;
  943.  
  944. case "translate.google.com":
  945. redirectGTranslate();
  946. break;
  947.  
  948. case "www.reuters.com":
  949. redirectReuters();
  950. break;
  951.  
  952. case "www.imdb.com":
  953. case "m.imdb.com":
  954. redirectImdb();
  955. break;
  956.  
  957. case "www.quora.com":
  958. redirectQuora();
  959. break;
  960.  
  961. case "www.google.com":
  962. redirectGoogle();
  963. break;
  964.  
  965. case "www.goodreads.com":
  966. redirectGoodreads();
  967. break;
  968.  
  969. case "genius.com":
  970. redirectGenius();
  971. break;
  972.  
  973. case "stackoverflow.com":
  974. redirectStackoverflow();
  975. break;
  976.  
  977. case "f4.bcbits.com":
  978. case "t4.bcbits.com":
  979. redirectBandcamp();
  980. break;
  981.  
  982. case "i.pinimg.com":
  983. redirectPinterest();
  984. break;
  985.  
  986. case "soundcloud.com":
  987. redirectSoundcloud();
  988. break;
  989.  
  990. default:
  991. if (urlHostname.includes("medium.com")) {
  992. redirectMedium();
  993. } else if (urlHostname.includes("imgur.com")) {
  994. redirectImgur();
  995. } else if (urlHostname.includes("wikipedia.org")) {
  996. redirectWikipedia();
  997. } else if (urlHostname.includes("fandom.com")) {
  998. redirectFandom();
  999. } else if (urlHostname.includes("bandcamp.com")) {
  1000. redirectBandcamp();
  1001. } else if (urlHostname.includes("pinterest.com")) {
  1002. redirectPinterest();
  1003. }
  1004.  
  1005. break;
  1006. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement