Tracking Redirect Nuker

Decode encoded URLs in links and replace them with the decoded URL

  1. // ==UserScript==
  2. // @name Tracking Redirect Nuker
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2.2
  5. // @description Decode encoded URLs in links and replace them with the decoded URL
  6. // @author yodaluca23
  7. // @license GNU GPLv3
  8. // @match *://*/*
  9. // @exclude *://*.indeed.com/*
  10. // @exclude *://indeed.com/*
  11. // @grant none
  12. // ==/UserScript==
  13. (function() {
  14. 'use strict';
  15.  
  16. function decodeAndReplaceLinks() {
  17. const links = document.querySelectorAll('a');
  18. links.forEach(link => {
  19. const href = link.getAttribute('href');
  20. const encodedIndexHttps = href.indexOf('https%3A%2F%2F');
  21. const encodedIndexHttp = href.indexOf('http%3A%2F%2F');
  22. if (encodedIndexHttps !== -1 || encodedIndexHttp !== -1) {
  23. const encodedPart = href.substring(Math.max(encodedIndexHttps, encodedIndexHttp));
  24. const decodedPart = decodeURIComponent(encodedPart);
  25. link.setAttribute('href', decodedPart);
  26. }
  27. });
  28. }
  29.  
  30. // Run once when the page loads
  31. decodeAndReplaceLinks();
  32.  
  33. // Run every time a change is detected on the page
  34. const observer = new MutationObserver(decodeAndReplaceLinks);
  35. observer.observe(document.body, { subtree: true, childList: true });
  36. })();