Universal Redirect Anonymity

Replaces all link hrefs with anonredir.replit.app to preserve redirect privacy for the paranoid.

  1. // ==UserScript==
  2. // @name Universal Redirect Anonymity
  3. // @name:es Anonimato de Redirección Universal
  4. // @name:fr Anonymat par Redirection Universelle
  5. // @name:zh-CN 通用重定向匿名
  6. // @name:zh-TW 通用重定向匿名化
  7. // @namespace https://spin.rip/
  8. // @match *://*/*
  9. // @exclude *://anonredir.replit.app/*
  10. // @grant none
  11. // @version 3.0
  12. // @author Spinfal
  13. // @description Replaces all link hrefs with anonredir.replit.app to preserve redirect privacy for the paranoid.
  14. // @description:es Reemplaza todos los enlaces externos con redirecciones anonimizadas o agrega noreferrer para mayor privacidad.
  15. // @description:fr Remplace tous les liens externes par des redirections anonymisées ou ajoute noreferrer pour plus de confidentialité.
  16. // @description:zh-CN 将所有外部链接替换为匿名重定向或添加 noreferrer 以提高隐私性。
  17. // @description:zh-TW 將所有外部連結替換為匿名重定向或添加 noreferrer 以提高隱私性。
  18. // @license AGPL-3.0 License
  19. // @run-at document-idle
  20. // ==/UserScript==
  21.  
  22.  
  23. /*
  24. * 'true' will use "anonredir.replit.app" which is a basic html, css, and js page that has no server backend. the code is fully open to view by viewing the page source
  25. * 'false' will NOT use "anonredir.replit.app", but instead will add "noreferrer noopener" to all a tags that this script can find
  26. *
  27. * what's the difference?
  28. * * 'true' ensures more privacy by redirecting from a new page completely unrelated to your previous page, and uses location.replace to prevent the page from being saved in history. it will also try to strip all common url tracking params.
  29. * * 'false' simply adds "noreferrer noopener", which hides the page you were referred from but doesn't use location.replace and does not remove common url tracking params.
  30. */
  31. const useExternal = true;
  32. const noreferrerRegex = /noreferrer/;
  33. const skipReplacement = ["javascript:", "mailto:", "tel:"]; // any text here will cause the code to NOT edit a HREF attribute
  34.  
  35. (function () {
  36. function processLinks(links) {
  37. links.forEach(link => {
  38. const rel = link.rel;
  39. const href = link.href;
  40.  
  41. if (!noreferrerRegex.test(rel)) {
  42. if (useExternal && !skipReplacement.some((text) => href.includes(text)) && href) {
  43. link.href = `https://anonredir.replit.app/redir-hop?url=${encodeURIComponent(href)}`;
  44. } else {
  45. link.rel = rel ? `${rel} noreferrer noopener` : 'noreferrer noopener';
  46. }
  47. }
  48. });
  49. }
  50.  
  51. window.addEventListener('load', () => {
  52. // Process initial links
  53. const initialLinks = Array.from(
  54. document.querySelectorAll('a:not([rel*="noreferrer"])')
  55. );
  56. processLinks(initialLinks);
  57.  
  58. // Set up MutationObserver for dynamic content
  59. const observer = new MutationObserver(mutations => {
  60. mutations.forEach(mutation => {
  61. Array.from(mutation.addedNodes).forEach(node => {
  62. if (node.tagName === 'A' && !noreferrerRegex.test(node.rel)) {
  63. processLinks([node]);
  64. }
  65. });
  66. });
  67. });
  68.  
  69. observer.observe(document.body, {
  70. childList: true,
  71. subtree: true
  72. });
  73. }, { once: true });
  74. })();