Substack: bypass tracking-redirect on outbound links
Rewrites outbound links that go through /redirect/ to their real destination URLs.
Code to copy
// Rewrite Substack tracking-redirect URLs back to their real destination
(function () {
function decodeOnce(u) {
try {
var url = new URL(u, location.href);
// common patterns: /redirect/2?...&url=ENC or /redirect?u=ENC
if (!/substack\.com/i.test(url.hostname) && !/^substack/i.test(url.hostname)) { return u; }
if (!/\/redirect/i.test(url.pathname)) { return u; }
var target = url.searchParams.get('url') || url.searchParams.get('u') || url.searchParams.get('to');
if (!target) { return u; }
try { target = decodeURIComponent(target); } catch (e) {}
return target;
} catch (e) { return u; }
}
function patch() {
document.querySelectorAll('a[href*="/redirect"]').forEach(function (a) {
if (a.dataset.jzSubLink) { return; }
var h = a.getAttribute('href') || '';
var clean = decodeOnce(h);
if (clean && clean !== h) { a.setAttribute('href', clean); }
a.dataset.jzSubLink = '1';
});
}
patch();
var obs = new MutationObserver(function () {
clearTimeout(window.__jzSubLinks);
window.__jzSubLinks = setTimeout(patch, 400);
});
obs.observe(document.body, { childList: true, subtree: true });
})();
How to use this example
- Copy the code with the button above.
- Install JustZix (2 minutes) and open the extension on the target page.
- Add a new rule matching that page.
- Paste the code into the rule's JavaScript panel and save — it runs on every page visit.
Rate this example
No ratings yet — be the first.