Privacy Frontend Redirect

This script redirects to privacy friendly front-ends of popular services, such as YouTube, Twitter, Reddit, Imgur, Instagram, TikTok, etc. Additionally, it replaces iframes and outgoing links to non frontend services with their privacy-friendly counterparts. The purpose of this script is to protect the user's privacy by avoiding the collection of personal data by these services.

当前为 2023-03-03 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Privacy Frontend Redirect
  3. // @match *://*/*
  4. // @exclude *://account*/*
  5. // @exclude *://messages.*/*
  6. // @grant none
  7. // @version 4.2.7
  8. // @author NoUser
  9. // @description This script redirects to privacy friendly front-ends of popular services, such as YouTube, Twitter, Reddit, Imgur, Instagram, TikTok, etc. Additionally, it replaces iframes and outgoing links to non frontend services with their privacy-friendly counterparts. The purpose of this script is to protect the user's privacy by avoiding the collection of personal data by these services.
  10. // @run-at document-start
  11. // @namespace https://greasyfork.org/en/scripts/458875-privacy-frontend-redirect
  12. // @homepage https://greasyfork.org/en/scripts/458875-privacy-frontend-redirect
  13. // @license MIT
  14. // ==/UserScript==
  15.  
  16. const hostname = window.location.hostname;
  17. const hosts = {
  18. "www.youtube.com": ["invidious.privacydev.net", "vid.puffyan.us", "inv.vern.cc", "invidious.kavin.rocks", "invidious.tiekoetter.com", "inv.riverside.rocks", "iv.ggtyler.dev", "invidious.nerdvpn.de"],
  19. "www.youtube-nocookie.com": ["invidious.privacydev.net", "vid.puffyan.us", "inv.vern.cc", "invidious.kavin.rocks", "invidious.tiekoetter.com", "inv.riverside.rocks", "iv.ggtyler.dev", "invidious.nerdvpn.de"],
  20. "m.youtube.com": ["invidious.privacydev.net", "vid.puffyan.us", "inv.vern.cc", "invidious.kavin.rocks", "invidious.tiekoetter.com", "inv.riverside.rocks", "iv.ggtyler.dev", "invidious.nerdvpn.de"],
  21. "twitter.com": ["nitter.sneed.network", "canada.unofficialbird.com", "nitter.privacytools.io", "nitter.foss.wtf", "nitter.privacy.com.de", "nitter.1d4.us", "nitter.poast.org", "twitter.censors.us"],
  22. "mobile.twitter.com": ["nitter.sneed.network", "canada.unofficialbird.com", "nitter.privacytools.io", "nitter.foss.wtf", "nitter.privacy.com.de", "nitter.1d4.us", "nitter.poast.org", "twitter.censors.us"],
  23. "www.reddit.com": ["libreddit.eu.org", "libreddit.spike.codes", "lr.odyssey346.dev", "rd.funami.tech", "libreddit.dcs0.hu", "lr.vern.cc", "www.troddit.com"],
  24. "imgur.com": ["rimgo.pussthecat.org", "rimgo.totaldarkness.net", "rimgo.vern.cc", "imgur.artemislena.eu", "rimgo.privacydev.net", "rimgo.bus-hit.me"],
  25. "i.imgur.com": ["rimgo.pussthecat.org", "rimgo.totaldarkness.net", "rimgo.vern.cc", "imgur.artemislena.eu", "rimgo.privacydev.net", "rimgo.bus-hit.me"],
  26. "i.stack.imgur.com": ["rimgo.pussthecat.org", "rimgo.totaldarkness.net", "rimgo.vern.cc", "imgur.artemislena.eu", "rimgo.privacydev.net", "rimgo.bus-hit.me"],
  27. "www.instagram.com": ["bibliogram.froth.zone", "ig.tokhmi.xyz"],
  28. "www.tiktok.com": ["proxitok.pussthecat.org", "tok.habedieeh.re", "tok.artemislena.eu", "proxitok.privacydev.net"],
  29. "www.imdb.com": ["ld.vern.cc", "libremdb.esmailelbob.xyz", "lmdb.tokhmi.xyz", "libremdb.iket.me", "libremdb.pussthecat.org"],
  30. "translate.google.com": ["lingva.ml", "translate.plausibility.cloud", "lingva.lunar.icu", "translate.projectsegfau.lt", "translate.jae.fi"],
  31. "medium.com": ["scribe.rip", "scribe.nixnet.services", "scribe.citizen4.eu", "scribe.bus-hit.me", "scribe.froth.zone", "scribe.rawbit.ninja"],
  32. };
  33.  
  34. const replaceUrl = (url) => {
  35. const { host } = new URL(url);
  36. if (host in hosts) {
  37. let replacement = hosts[host];
  38. if (Array.isArray(replacement)) {
  39. replacement = replacement[Math.floor(Math.random() * replacement.length)];
  40. }
  41. return url.replace(host, replacement);
  42. }
  43. return url;
  44. };
  45.  
  46. try {
  47. const replacement = hosts[hostname];
  48. if (replacement) {
  49. window.location.href = replaceUrl(window.location.href);
  50. }
  51. } catch (error) {
  52. console.error(error.message);
  53. }
  54.  
  55. window.addEventListener("load", function () {
  56. try {
  57. // Replace iframes
  58. const iframes = document.querySelectorAll(`iframe[src*="${window.location.host}"]`);
  59. iframes.forEach(iframe => {
  60. const newIframe = document.createElement('iframe');
  61. const attributes = ['src', 'width', 'height', 'frameborder', 'allowfullscreen', 'allow', 'title'];
  62. attributes.forEach(attribute => {
  63. if (iframe.hasAttribute(attribute)) {
  64. newIframe.setAttribute(attribute, iframe.getAttribute(attribute));
  65. }
  66. });
  67. iframe.parentNode.replaceChild(newIframe, iframe);
  68. });
  69.  
  70. // Replace hrefs
  71. const links = document.querySelectorAll("a");
  72. links.forEach(link => {
  73. const href = link.href;
  74. const newUrl = replaceUrl(href);
  75. if (newUrl !== href) {
  76. link.href = newUrl;
  77. }
  78. });
  79. } catch (error) {
  80. console.error(error.message);
  81. }
  82. });