Privacy Redirector

Redirect social media platforms to their privacy respecting frontends

目前为 2022-06-08 提交的版本。查看 最新版本

  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.5
  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. let newURL = window.location.protocol + "//" + farsideRimgo + window.location.pathname + window.location.search + window.location.hash;
  169. window.location.replace(newURL);
  170. }
  171.  
  172. function redirectMedium() {
  173. if (redirect_medium == false || window.location.pathname == "/") {
  174. return;
  175. }
  176.  
  177. window.stop();
  178.  
  179. let newURL = window.location.protocol + "//" + farsideInstance + "/scribe" + window.location.pathname + window.location.search + window.location.hash;
  180. window.location.replace(newURL);
  181. }
  182.  
  183. function redirectYoutubeMusic() {
  184. if (redirect_youtube == false) {
  185. return;
  186. }
  187.  
  188. window.stop();
  189.  
  190. if (window.location.pathname.indexOf("/playlist") != -1) {
  191. let newURL = window.location.protocol + "//" + "beatbump.ml" + window.location.pathname + window.location.search.replace("?list=", "/VL") + window.location.hash;
  192. window.location.replace(newURL);
  193. } else if (window.location.pathname.indexOf("/channel") != -1) {
  194. let newURL = window.location.protocol + "//" + "beatbump.ml" + window.location.pathname.replace("/channel", "/artist") + window.location.search + window.location.hash;
  195. window.location.replace(newURL);
  196. } else if (window.location.pathname.indexOf("/explore") != -1) {
  197. let newURL = window.location.protocol + "//" + "beatbump.ml" + window.location.pathname.replace("/explore", "/trending") + window.location.search + window.location.hash;
  198. window.location.replace(newURL);
  199. } else if (window.location.pathname.indexOf("/moods_and_genres") != -1) {
  200. let newURL = window.location.protocol + "//" + "beatbump.ml" + window.location.pathname.replace("/moods_and_genres", "/explore") + window.location.search + window.location.hash;
  201. window.location.replace(newURL);
  202. } else {
  203. location.hostname = "beatbump.ml";
  204. }
  205.  
  206. }
  207.  
  208. function redirectHackerNews() {
  209. if (redirect_hackernews == false) {
  210. return;
  211. }
  212.  
  213. window.stop();
  214. let newURL = window.location.protocol + "//" + "hn.algolia.com";
  215. window.location.replace(newURL);
  216. }
  217.  
  218. function redirectGTranslate() {
  219. if (redirect_gtranslate == false) {
  220. return;
  221. }
  222.  
  223. window.stop();
  224.  
  225.  
  226. if (window.location.search != "") {
  227. 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;
  228. window.location.replace(newURL);
  229. } else {
  230. let newURL = window.location.protocol + "//" + farsideInstance + "/lingva";
  231. window.location.replace(newURL);
  232. }
  233. }
  234.  
  235. function redirectReuters() {
  236. if (redirect_reuters == false) {
  237. return;
  238. }
  239.  
  240. window.stop();
  241. location.hostname = "neuters.de";
  242. }
  243.  
  244. function redirectWikipedia() {
  245. if (redirect_wikipedia == false) {
  246. return;
  247. }
  248.  
  249. let wikilessInstances = [
  250. 'wikiless.org',
  251. 'wikiless.alefvanoon.xyz',
  252. 'wikiless.sethforprivacy.com',
  253. 'wiki.604kph.xyz',
  254. 'wiki.froth.zone'
  255. ];
  256.  
  257. let randomInstance = wikilessInstances[Math.floor(Math.random()*wikilessInstances.length)];
  258. let langCodeIndex = window.location.hostname.search(/^[a-z][a-z]\./)
  259.  
  260. window.stop();
  261.  
  262. if (langCodeIndex != -1) {
  263. let newURL = window.location.protocol + "//" + randomInstance + window.location.pathname + "?lang=" + window.location.hostname[langCodeIndex] + window.location.hostname[langCodeIndex + 1] + window.location.hash;
  264. window.location.replace(newURL);
  265. } else {
  266. let newURL = window.location.protocol + "//" + randomInstance + window.location.pathname + "?lang=en" + window.location.hash;
  267. window.location.replace(newURL);
  268. }
  269. }
  270.  
  271. var urlHostname = window.location.hostname;
  272.  
  273. switch (urlHostname) {
  274.  
  275. case "www.instagram.com":
  276. redirectInstagram();
  277. break;
  278.  
  279. case "twitter.com":
  280. case "mobile.twitter.com":
  281. redirectTwitter();
  282. break;
  283.  
  284. case "www.reddit.com":
  285. case "old.reddit.com":
  286. redirectReddit();
  287. break;
  288.  
  289. case "www.youtube.com":
  290. case "m.youtube.com":
  291. redirectYoutube();
  292. break;
  293.  
  294. case "www.tiktok.com":
  295. redirectTiktok();
  296. break;
  297.  
  298. case "music.youtube.com":
  299. redirectYoutubeMusic();
  300. break;
  301.  
  302. case "news.ycombinator.com":
  303. redirectHackerNews();
  304. break;
  305.  
  306. case "translate.google.com":
  307. redirectGTranslate();
  308. break;
  309.  
  310. case "www.reuters.com":
  311. redirectReuters();
  312. break;
  313. }
  314.  
  315. if (urlHostname.includes("medium.com")) {
  316. redirectMedium();
  317. } else if (urlHostname.includes("imgur.com")) {
  318. redirectImgur();
  319. } else if (urlHostname.includes("wikipedia.org")) {
  320. redirectWikipedia();
  321. }