Privacy Redirector

Redirect social media platforms to their privacy respecting frontends

当前为 2022-11-27 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Privacy Redirector
  3. // @name:tr Gizlilik Yönlendiricisi
  4. // @name:de Datenschutz Umleiter
  5. // @namespace https://github.com/dybdeskarphet/privacy-redirector
  6. // @license GPLv3
  7. // @version 1.3.1
  8. // @description Redirect social media platforms to their privacy respecting frontends
  9. // @description:tr Sosyal medya platformlarını, gizliliğe saygı duyan önyüzlerine yönlendirir
  10. // @description:de Leitet von Social-Media-Plattformen auf deren jeweilige datenschutzfreundlicheren Frontends
  11. // @supportURL https://github.com/dybdeskarphet/privacy-redirector
  12. // @run-at document-start
  13. // @match *://*.fandom.com/*
  14. // @match *://*.imdb.com/*
  15. // @match *://*.imgur.com/*
  16. // @match *://*.instagram.com/*
  17. // @match *://*.medium.com/*
  18. // @match *://*.quora.com/*
  19. // @match *://*.reddit.com/*
  20. // @match *://*.reuters.com/*
  21. // @match *://*.tiktok.com/*
  22. // @match *://*.twitter.com/*
  23. // @match *://*.wikipedia.org/*
  24. // @match *://*.youtube.com/*
  25. // @match *://imgur.com/*
  26. // @match *://instagram.com/*
  27. // @match *://medium.com/*
  28. // @match *://news.ycombinator.com/*
  29. // @match *://reddit.com/*
  30. // @match *://translate.google.com/*
  31. // @match *://twitter.com/*
  32. // @match *://youtube.com/*
  33. // ==/UserScript==
  34.  
  35. /*
  36. ___ _ _ ___ _____ _____
  37. / _ \| \ | | / _ \| ___| ___|
  38. | | | | \| |_____| | | | |_ | |_
  39. | |_| | |\ |_____| |_| | _| | _|
  40. \___/|_| \_| \___/|_| |_|
  41.  
  42. CHANGE THE RELEVANT VALUE TO "false" TO
  43. DISABLE THE REDIRECTION FOR THAT
  44. PARTICULAR SITE */
  45. var redirect_fandom = true;
  46. var redirect_gtranslate = true;
  47. var redirect_hackernews = true;
  48. var redirect_imdb = true;
  49. var redirect_imgur = true;
  50. var redirect_instagram = false;
  51. var redirect_medium = true;
  52. var redirect_quora = false;
  53. var redirect_reddit = true;
  54. var redirect_reuters = true;
  55. var redirect_tiktok = true;
  56. var redirect_twitter = true;
  57. var redirect_wikipedia = true;
  58. var redirect_youtube = true;
  59.  
  60. // // // // // // // // // // // // //
  61.  
  62. var farsideInstance = "farside.link";
  63. var debug_mode = false;
  64.  
  65. if (debug_mode == true) {
  66. alert("Hostname: " + window.location.hostname + "\nPath: " + window.location.pathname + "\nQuery: " + window.location.search + "\nHash: " + window.location.hash)
  67. }
  68.  
  69. function redirectInstagram() {
  70. if (redirect_instagram == false) {
  71. return;
  72. }
  73.  
  74. window.stop();
  75.  
  76. alert("Bibliogram Instances are broken, you may want to disable the redirection for Instagram")
  77.  
  78. let bibliogramInstances = [
  79. 'bibliogram.art',
  80. 'bibliogram.pussthecat.org',
  81. 'bibliogram.1d4.us',
  82. 'bibliogram.froth.zone'
  83. ];
  84.  
  85. let randomInstance = bibliogramInstances[Math.floor(Math.random()*bibliogramInstances.length)];
  86.  
  87. if (window.location.pathname.startsWith("/accounts/login/")) {
  88. if (window.location.search.indexOf("/reel/") != -1) { // reels
  89. let newURL = window.location.protocol +
  90. "//" + randomInstance +
  91. window.location.pathname.replace("/accounts/login/", "/") +
  92. window.location.search.replace("?next=/reel", "p") +
  93. window.location.hash;
  94.  
  95. window.location.replace(newURL);
  96. } else if (window.location.search.indexOf("/p/") == -1) { // user pages - it will crash if it's not the second last block
  97. let newURL = window.location.protocol +
  98. "//" + randomInstance +
  99. window.location.pathname.replace("/accounts/login/", "/") +
  100. window.location.search.replace("?next=", "u") +
  101. window.location.hash;
  102.  
  103. window.location.replace(newURL);
  104. } else { // probably a post
  105. let newURL = window.location.protocol +
  106. "//" +randomInstance +
  107. window.location.pathname.replace("/accounts/login/", "") +
  108. window.location.search.replace("?next=", "") +
  109. window.location.hash;
  110.  
  111. window.location.replace(newURL);
  112. }
  113. } else {
  114. if (window.location.pathname == "/") { // home page
  115. location.hostname = randomInstance
  116. } else if (window.location.pathname.startsWith("/reel/")) { // reel
  117. let newURL = window.location.protocol +
  118. "//" + randomInstance +
  119. window.location.pathname.replace("/reel", "/p") +
  120. window.location.hash;
  121.  
  122. window.location.replace(newURL);
  123.  
  124. } else if (! window.location.pathname.startsWith("/p/")) { // user page - it will crash if it's not the second last block
  125. let newURL = window.location.protocol +
  126. "//" + randomInstance +
  127. "/u" + window.location.pathname +
  128. window.location.search +
  129. indow.location.hash;
  130.  
  131. window.location.replace(newURL);
  132. } else { // probably a post
  133. location.hostname = randomInstance
  134. }
  135. }
  136. }
  137.  
  138. function redirectTwitter() {
  139. if (redirect_twitter == false) {
  140. return;
  141. }
  142.  
  143. window.stop();
  144.  
  145. let newURL = window.location.protocol +
  146. "//" + farsideInstance + "/nitter" +
  147. window.location.pathname +
  148. window.location.search +
  149. window.location.hash;
  150.  
  151. window.location.replace(newURL);
  152. }
  153.  
  154. function redirectReddit() {
  155. if (redirect_reddit == false) {
  156. return;
  157. }
  158.  
  159. window.stop();
  160.  
  161. let farsideLibreddit = farsideInstance + "/libreddit";
  162. let farsideTeddit = farsideInstance + "/teddit";
  163.  
  164. if (window.location.hostname == "old.reddit.com") {
  165. let newURL = window.location.protocol +
  166. "//" + farsideTeddit +
  167. window.location.pathname +
  168. window.location.search +
  169. window.location.hash;
  170.  
  171. window.location.replace(newURL);
  172. } else {
  173. let newURL = window.location.protocol +
  174. "//" + farsideLibreddit +
  175. window.location.pathname +
  176. window.location.search +
  177. window.location.hash;
  178.  
  179. window.location.replace(newURL);
  180. }
  181. }
  182.  
  183. function redirectYoutube() {
  184. if (redirect_youtube == false) {
  185. return;
  186. }
  187.  
  188. window.stop();
  189.  
  190. let newURL = window.location.protocol +
  191. "//" + farsideInstance + "/invidious" +
  192. window.location.pathname +
  193. window.location.search +
  194. window.location.hash;
  195.  
  196. window.location.replace(newURL);
  197. }
  198.  
  199. function redirectTiktok() {
  200. if (redirect_tiktok == false) {
  201. return;
  202. }
  203.  
  204. let proxitokInstances = [
  205. 'proxitok.pabloferreiro.es',
  206. 'proxitok.pussthecat.org',
  207. 'tok.habedieeh.re',
  208. 'proxitok.esmailelbob.xyz'
  209. ];
  210.  
  211. let randomInstance = proxitokInstances[Math.floor(Math.random()*proxitokInstances.length)];
  212.  
  213. window.stop();
  214.  
  215. if (window.location.pathname.startsWith("/discover")) {
  216. let newURL = window.location.protocol +
  217. "//" + randomInstance +
  218. window.location.pathname.replace("discover", "tag") +
  219. window.location.hash;
  220.  
  221. window.location.replace(newURL);
  222. } else if (window.location.pathname.search(/[a-z][a-z]\-[A-Z][A-Z]/g) != -1) {
  223. let newURL = window.location.protocol +
  224. "//" + randomInstance +
  225. window.location.pathname +
  226. window.location.search +
  227. window.location.hash;
  228.  
  229. window.location.replace(newURL);
  230. } else {
  231. let newURL = window.location.protocol +
  232. "//" + randomInstance +
  233. window.location.pathname +
  234. window.location.search +
  235. window.location.hash;
  236.  
  237. window.location.replace(newURL);
  238. }
  239.  
  240. }
  241.  
  242. function redirectImgur() {
  243. if (redirect_imgur == false) {
  244. return;
  245. }
  246.  
  247. window.stop();
  248.  
  249. let newURL = window.location.protocol +
  250. "//" + farsideInstance + "/rimgo" +
  251. window.location.pathname +
  252. window.location.search +
  253. window.location.hash;
  254.  
  255. window.location.replace(newURL);
  256. }
  257.  
  258. function redirectMedium() {
  259. if (redirect_medium == false || window.location.pathname == "/") {
  260. return;
  261. }
  262.  
  263. window.stop();
  264.  
  265. let newURL = window.location.protocol +
  266. "//" + farsideInstance + "/scribe" +
  267. window.location.pathname +
  268. window.location.search +
  269. window.location.hash;
  270.  
  271. window.location.replace(newURL);
  272. }
  273.  
  274. function redirectYoutubeMusic() {
  275. if (redirect_youtube == false) {
  276. return;
  277. }
  278.  
  279. window.stop();
  280.  
  281. if (window.location.pathname.startsWith("/playlist")) {
  282. let newURL = window.location.protocol +
  283. "//" + "beatbump.ml" +
  284. window.location.pathname +
  285. window.location.search.replace("?list=", "/VL") +
  286. window.location.hash;
  287.  
  288. window.location.replace(newURL);
  289. } else if (window.location.pathname.startsWith("/channel")) {
  290. let newURL = window.location.protocol +
  291. "//" + "beatbump.ml" +
  292. window.location.pathname.replace("/channel", "/artist") +
  293. window.location.search +
  294. window.location.hash;
  295.  
  296. window.location.replace(newURL);
  297. } else if (window.location.pathname.startsWith("/explore")) {
  298. let newURL = window.location.protocol +
  299. "//" + "beatbump.ml" +
  300. window.location.pathname.replace("/explore", "/trending") +
  301. window.location.search +
  302. window.location.hash;
  303.  
  304. window.location.replace(newURL);
  305. } else if (window.location.pathname.startsWith("/moods_and_genres")) {
  306. let newURL = window.location.protocol +
  307. "//" + "beatbump.ml" +
  308. window.location.pathname.replace("/moods_and_genres", "/explore") +
  309. window.location.search +
  310. window.location.hash;
  311.  
  312. window.location.replace(newURL);
  313. } else {
  314. location.hostname = "beatbump.ml";
  315. }
  316.  
  317. }
  318.  
  319. function redirectHackerNews() {
  320. if (redirect_hackernews == false) {
  321. return;
  322. }
  323.  
  324. window.stop();
  325. let newURL = window.location.protocol + "//" + "hn.algolia.com";
  326. window.location.replace(newURL);
  327. }
  328.  
  329. function redirectGTranslate() {
  330. if (redirect_gtranslate == false) {
  331. return;
  332. }
  333.  
  334. window.stop();
  335.  
  336.  
  337. if (window.location.search != "") {
  338. let newURL = window.location.protocol +
  339. "//" + farsideInstance + "/lingva" +
  340. window.location.pathname +
  341. window.location.search
  342. .replace(/\?hl=tr/, "")
  343. .replace(/.sl=/, "")
  344. .replace("&tl=", "/")
  345. .replace("&text=", "/")
  346. .replace("&op=translate", "") +
  347. window.location.hash;
  348.  
  349. window.location.replace(newURL);
  350. } else {
  351. let newURL = window.location.protocol +
  352. "//" + farsideInstance + "/lingva";
  353.  
  354. window.location.replace(newURL);
  355. }
  356. }
  357.  
  358. function redirectReuters() {
  359. if (redirect_reuters == false) {
  360. return;
  361. }
  362.  
  363. window.stop();
  364. location.hostname = "neuters.de";
  365. }
  366.  
  367. function redirectWikipedia() {
  368. if (redirect_wikipedia == false) {
  369. return;
  370. }
  371.  
  372. let langCodeIndex = window.location.hostname.search(/^[a-z][a-z]\./)
  373.  
  374. window.stop();
  375.  
  376. if (langCodeIndex != -1) {
  377. let newURL = window.location.protocol +
  378. "//" + farsideInstance + "/wikiless" +
  379. window.location.pathname +
  380. "?lang=" +
  381. window.location.hostname[langCodeIndex] + window.location.hostname[langCodeIndex + 1] +
  382. window.location.hash;
  383. window.location.replace(newURL);
  384. } else {
  385. let newURL = window.location.protocol +
  386. "//" + farsideInstance + "/wikiless" +
  387. window.location.pathname +"?lang=en" +
  388. window.location.hash;
  389. window.location.replace(newURL);
  390. }
  391. }
  392.  
  393. function redirectImdb() {
  394. if (redirect_imdb == false) {
  395. return;
  396. }
  397.  
  398. if (window.location.pathname.startsWith("/title/")) {
  399. window.stop();
  400. let newURL =
  401. window.location.protocol +
  402. "//" + farsideInstance + "/libremdb" +
  403. window.location.pathname +
  404. window.location.search +
  405. window.location.hash;
  406. window.location.replace(newURL);
  407. }
  408. }
  409.  
  410. function redirectQuora() {
  411. if (redirect_quora == false) {
  412. return;
  413. }
  414.  
  415. window.stop();
  416.  
  417. let newURL =
  418. window.location.protocol +
  419. "//" + farsideInstance + "/querte" +
  420. window.location.pathname +
  421. window.location.search +
  422. window.location.hash;
  423.  
  424. window.location.replace(newURL);
  425. }
  426.  
  427. function redirectFandom() {
  428. if (redirect_fandom == false) {
  429. return;
  430. }
  431.  
  432. let breezewikiInstances = [
  433. 'breezewiki.com',
  434. 'breezewiki.pussthecat.org',
  435. 'breezewiki.esmailelbob.xyz',
  436. ];
  437.  
  438. let randomInstance = breezewikiInstances[Math.floor(Math.random()*breezewikiInstances.length)];
  439. let fandomName = window.location.hostname.replace(/\..*/, "")
  440. let newURL = ""
  441.  
  442. window.stop();
  443.  
  444. if(fandomName !== "www") {
  445. newURL =
  446. window.location.protocol +
  447. "//" + randomInstance + `/${fandomName}` +
  448. window.location.pathname +
  449. window.location.search +
  450. window.location.hash;
  451. } else {
  452. newURL = window.location.protocol + "//" + randomInstance
  453. }
  454.  
  455. window.location.replace(newURL);
  456. }
  457.  
  458. let urlHostname = window.location.hostname;
  459.  
  460. switch (urlHostname) {
  461.  
  462. case "www.instagram.com":
  463. redirectInstagram();
  464. break;
  465.  
  466. case "twitter.com":
  467. case "mobile.twitter.com":
  468. redirectTwitter();
  469. break;
  470.  
  471. case "www.reddit.com":
  472. case "old.reddit.com":
  473. redirectReddit();
  474. break;
  475.  
  476. case "www.youtube.com":
  477. case "m.youtube.com":
  478. redirectYoutube();
  479. break;
  480.  
  481. case "www.tiktok.com":
  482. redirectTiktok();
  483. break;
  484.  
  485. case "music.youtube.com":
  486. redirectYoutubeMusic();
  487. break;
  488.  
  489. case "news.ycombinator.com":
  490. redirectHackerNews();
  491. break;
  492.  
  493. case "translate.google.com":
  494. redirectGTranslate();
  495. break;
  496.  
  497. case "www.reuters.com":
  498. redirectReuters();
  499. break;
  500.  
  501. case "www.imdb.com":
  502. redirectImdb();
  503. break;
  504.  
  505. case "www.quora.com":
  506. redirectQuora();
  507. break;
  508. }
  509.  
  510. if (urlHostname.includes("medium.com")) {
  511. redirectMedium();
  512. } else if (urlHostname.includes("imgur.com")) {
  513. redirectImgur();
  514. } else if (urlHostname.includes("wikipedia.org")) {
  515. redirectWikipedia();
  516. } else if (urlHostname.includes("fandom.com")) {
  517. redirectFandom();
  518. }