Privacy Redirector

Redirect social media platforms to their privacy respecting frontends

As of 2022-06-07. See the latest version.

  1. // ==UserScript==
  2. // @name Privacy Redirector
  3. // @name:tr Gizlilik Yönlendiricisi
  4. // @namespace https://github.com/dybdeskarphet/privacy-redirector
  5. // @license GPLv3
  6. // @version 1.2.4
  7. // @description Redirect social media platforms to their privacy respecting frontends
  8. // @description:tr Sosyal medya platformlarını, gizliliğe saygı duyan önyüzlerine yönlendirir
  9. // @supportURL https://github.com/dybdeskarphet/privacy-redirector
  10. // @run-at document-start
  11. // @match *://instagram.com/*
  12. // @match *://*.instagram.com/*
  13. // @match *://twitter.com/*
  14. // @match *://*.twitter.com/*
  15. // @match *://reddit.com/*
  16. // @match *://*.reddit.com/*
  17. // @match *://youtube.com/*
  18. // @match *://*.youtube.com/*
  19. // @match *://*.tiktok.com/*
  20. // @match *://imgur.com/*
  21. // @match *://*.imgur.com/*
  22. // @match *://medium.com/*
  23. // @match *://*.medium.com/*
  24. // @match *://translate.google.com/*
  25. // @match *://news.ycombinator.com/*
  26. // @match *://*.reuters.com/*
  27. // @match *://*.wikipedia.org/*
  28. // ==/UserScript==
  29.  
  30. /*
  31. ___ _ _ ___ _____ _____
  32. / _ \| \ | | / _ \| ___| ___|
  33. | | | | \| |_____| | | | |_ | |_
  34. | |_| | |\ |_____| |_| | _| | _|
  35. \___/|_| \_| \___/|_| |_|
  36.  
  37. CHANGE THE RELEVANT VALUE TO "false" TO
  38. DISABLE THE REDIRECTION FOR THAT
  39. PARTICULAR SITE */
  40. var redirect_youtube = true;
  41. var redirect_instagram = true;
  42. var redirect_twitter = true;
  43. var redirect_reddit = true;
  44. var redirect_tiktok = true;
  45. var redirect_imgur = true;
  46. var redirect_medium = true;
  47. var redirect_hackernews = true;
  48. var redirect_gtranslate = true;
  49. var redirect_reuters = true;
  50. var redirect_wikipedia = true;
  51.  
  52. // // // // // // // // // // // // //
  53.  
  54. var farsideInstance = "farside.link"
  55.  
  56. function redirectInstagram() {
  57. if (redirect_instagram == false) {
  58. return;
  59. }
  60.  
  61. window.stop();
  62.  
  63. let bibliogramInstances = [
  64. 'bibliogram.art',
  65. 'bibliogram.pussthecat.org',
  66. 'bibliogram.1d4.us',
  67. 'bibliogram.froth.zone'
  68. ];
  69.  
  70. let randomInstance = bibliogramInstances[Math.floor(Math.random()*bibliogramInstances.length)];
  71.  
  72. if (window.location.pathname.indexOf("/accounts/login/") != -1) {
  73. if (window.location.href.indexOf("/reel/") != -1) {
  74. let newURL = window.location.protocol + "//" + randomInstance + window.location.pathname.replace("/accounts/login/", "/") + window.location.search.replace("?next=/reel", "p") + window.location.hash;
  75. window.location.replace(newURL);
  76. } else if (window.location.href.indexOf("/p/") == -1) {
  77. let newURL = window.location.protocol + "//" + randomInstance + window.location.pathname.replace("/accounts/login/", "/") + window.location.search.replace("?next=", "u") + window.location.hash;
  78. window.location.replace(newURL);
  79. } else {
  80. let newURL = window.location.protocol + "//" + randomInstance + window.location.pathname.replace("/accounts/login/", "") + window.location.search.replace("?next=", "") + window.location.hash;
  81. window.location.replace(newURL);
  82. }
  83. } else {
  84. if (window.location.pathname == "/") {
  85. location.hostname = randomInstance
  86. } else if (window.location.href.indexOf("/reel/") != -1) {
  87. let newURL = window.location.protocol + "//" + randomInstance + window.location.pathname.replace("/reel", "/p") + window.location.hash;
  88. window.location.replace(newURL);
  89. } else if (window.location.href.indexOf("/p/") == -1) {
  90. let newURL = window.location.protocol + "//" + randomInstance + "/u" + window.location.pathname + window.location.search + window.location.hash;
  91. window.location.replace(newURL);
  92. } else {
  93. location.hostname = randomInstance
  94. }
  95. }
  96. }
  97.  
  98. function redirectTwitter() {
  99. if (redirect_twitter == false) {
  100. return;
  101. }
  102.  
  103. window.stop();
  104.  
  105. let newURL = window.location.protocol + "//" + farsideInstance + "/nitter" + window.location.pathname + window.location.search + window.location.hash;
  106. window.location.replace(newURL);
  107. }
  108.  
  109. function redirectReddit() {
  110. if (redirect_reddit == false) {
  111. return;
  112. }
  113.  
  114. window.stop();
  115.  
  116. let farsideLibreddit = farsideInstance + "/libreddit";
  117. let farsideTeddit = farsideInstance + "/teddit";
  118.  
  119. if (window.location.hostname == "old.reddit.com") {
  120. let newURL = window.location.protocol + "//" + farsideTeddit + window.location.pathname + window.location.search + window.location.hash;
  121. window.location.replace(newURL);
  122. } else {
  123. let newURL = window.location.protocol + "//" + farsideLibreddit + window.location.pathname + window.location.search + window.location.hash;
  124. window.location.replace(newURL);
  125. }
  126. }
  127.  
  128. function redirectYoutube() {
  129. if (redirect_youtube == false) {
  130. return;
  131. }
  132.  
  133. window.stop();
  134.  
  135. let newURL = window.location.protocol + "//" + farsideInstance + "/invidious" + window.location.pathname + window.location.search + window.location.hash;
  136. window.location.replace(newURL);
  137. }
  138.  
  139. function redirectTiktok() {
  140. if (redirect_tiktok == false) {
  141. return;
  142. }
  143.  
  144. window.stop();
  145.  
  146. let langcodeIndex = window.location.pathname.search(/[a-z][a-z]\-[A-Z][A-Z]/g);
  147.  
  148. if (window.location.pathname.indexOf("/discover") != -1) {
  149. let newURL = window.location.protocol + "//" + "proxitok.herokuapp.com" + window.location.pathname.replace("discover", "tag") + window.location.hash;
  150. window.location.replace(newURL);
  151. } else if (langcodeIndex != -1) {
  152. let newURL = window.location.protocol + "//" + "proxitok.pussthecat.org";
  153. window.location.replace(newURL);
  154. } else {
  155. location.hostname = "proxitok.pussthecat.org";
  156. }
  157.  
  158. }
  159.  
  160. function redirectImgur() {
  161. if (redirect_imgur == false) {
  162. return;
  163. }
  164.  
  165. let farsideRimgo = farsideInstance + "/rimgo";
  166.  
  167. window.stop();
  168. location.hostname = farsideRimgo;
  169. }
  170.  
  171. function redirectMedium() {
  172. if (redirect_medium == false || window.location.pathname == "/") {
  173. return;
  174. }
  175.  
  176. window.stop();
  177.  
  178. let newURL = window.location.protocol + "//" + farsideInstance + "/scribe" + window.location.pathname + window.location.search + window.location.hash;
  179. window.location.replace(newURL);
  180. }
  181.  
  182. function redirectYoutubeMusic() {
  183. if (redirect_youtube == false) {
  184. return;
  185. }
  186.  
  187. window.stop();
  188.  
  189. if (window.location.pathname.indexOf("/playlist") != -1) {
  190. let newURL = window.location.protocol + "//" + "beatbump.ml" + window.location.pathname + window.location.search.replace("?list=", "/VL") + window.location.hash;
  191. window.location.replace(newURL);
  192. } else if (window.location.pathname.indexOf("/channel") != -1) {
  193. let newURL = window.location.protocol + "//" + "beatbump.ml" + window.location.pathname.replace("/channel", "/artist") + window.location.search + window.location.hash;
  194. window.location.replace(newURL);
  195. } else if (window.location.pathname.indexOf("/explore") != -1) {
  196. let newURL = window.location.protocol + "//" + "beatbump.ml" + window.location.pathname.replace("/explore", "/trending") + window.location.search + window.location.hash;
  197. window.location.replace(newURL);
  198. } else if (window.location.pathname.indexOf("/moods_and_genres") != -1) {
  199. let newURL = window.location.protocol + "//" + "beatbump.ml" + window.location.pathname.replace("/moods_and_genres", "/explore") + window.location.search + window.location.hash;
  200. window.location.replace(newURL);
  201. } else {
  202. location.hostname = "beatbump.ml";
  203. }
  204.  
  205. }
  206.  
  207. function redirectHackerNews() {
  208. if (redirect_hackernews == false) {
  209. return;
  210. }
  211.  
  212. window.stop();
  213. let newURL = window.location.protocol + "//" + "hn.algolia.com";
  214. window.location.replace(newURL);
  215. }
  216.  
  217. function redirectGTranslate() {
  218. if (redirect_gtranslate == false) {
  219. return;
  220. }
  221.  
  222. window.stop();
  223.  
  224.  
  225. if (window.location.search != "") {
  226. let newURL = window.location.protocol + "//" + farsideInstance + "/lingva" + window.location.pathname + window.location.search.replace(/\?hl=tr/, "").replace(/.sl=/, "").replace("&tl=", "/").replace("&text=", "/").replace("&op=translate", "") + window.location.hash;
  227. window.location.replace(newURL);
  228. } else {
  229. let newURL = window.location.protocol + "//" + farsideInstance + "/lingva";
  230. window.location.replace(newURL);
  231. }
  232. }
  233.  
  234. function redirectReuters() {
  235. if (redirect_reuters == false) {
  236. return;
  237. }
  238.  
  239. window.stop();
  240. location.hostname = "neuters.de";
  241. }
  242.  
  243. function redirectWikipedia() {
  244. if (redirect_wikipedia == false) {
  245. return;
  246. }
  247.  
  248. let wikilessInstances = [
  249. 'wikiless.org',
  250. 'wikiless.alefvanoon.xyz',
  251. 'wikiless.sethforprivacy.com',
  252. 'wiki.604kph.xyz',
  253. 'wiki.froth.zone'
  254. ];
  255.  
  256. let randomInstance = wikilessInstances[Math.floor(Math.random()*wikilessInstances.length)];
  257. let langCodeIndex = window.location.hostname.search(/^[a-z][a-z]\./)
  258.  
  259. window.stop();
  260.  
  261. if (langCodeIndex != -1) {
  262. let newURL = window.location.protocol + "//" + randomInstance + window.location.pathname + "?lang=" + window.location.hostname[langCodeIndex] + window.location.hostname[langCodeIndex + 1] + window.location.hash;
  263. window.location.replace(newURL);
  264. } else {
  265. let newURL = window.location.protocol + "//" + randomInstance + window.location.pathname + "?lang=en" + window.location.hash;
  266. window.location.replace(newURL);
  267. }
  268. }
  269.  
  270. var urlHostname = window.location.hostname;
  271.  
  272. switch (urlHostname) {
  273.  
  274. case "www.instagram.com":
  275. redirectInstagram();
  276. break;
  277.  
  278. case "twitter.com":
  279. case "mobile.twitter.com":
  280. redirectTwitter();
  281. break;
  282.  
  283. case "www.reddit.com":
  284. case "old.reddit.com":
  285. redirectReddit();
  286. break;
  287.  
  288. case "www.youtube.com":
  289. case "m.youtube.com":
  290. redirectYoutube();
  291. break;
  292.  
  293. case "www.tiktok.com":
  294. redirectTiktok();
  295. break;
  296.  
  297. case "music.youtube.com":
  298. redirectYoutubeMusic();
  299. break;
  300.  
  301. case "news.ycombinator.com":
  302. redirectHackerNews();
  303. break;
  304.  
  305. case "translate.google.com":
  306. redirectGTranslate();
  307. break;
  308.  
  309. case "www.reuters.com":
  310. redirectReuters();
  311. break;
  312. }
  313.  
  314. if (urlHostname.includes("medium.com")) {
  315. redirectMedium();
  316. } else if (urlHostname.includes("imgur.com")) {
  317. redirectImgur();
  318. } else if (urlHostname.includes("wikipedia.org")) {
  319. redirectWikipedia();
  320. }