Substack: block follow indicator emission
Intercepts fetch, XHR and sendBeacon calls so Substack cannot report that you viewed or followed the author.
Code to copy
// Suppress the "follow" indicator/beacon network calls
(function () {
var BLOCK = [/\/api\/v1\/follow/i, /\/api\/v1\/notes\/.*\/seen/i, /\/api\/v1\/email\/seen/i];
function blocked(url) { return BLOCK.some(function (rx) { return rx.test(url); }); }
if (window.fetch) {
var orig = window.fetch;
window.fetch = function (input, init) {
var u = typeof input === 'string' ? input : (input && input.url) || '';
if (blocked(u)) { return Promise.resolve(new Response('', { status: 204 })); }
return orig.call(this, input, init);
};
}
var OrigXHR = window.XMLHttpRequest;
if (OrigXHR) {
var Patched = function () {
var x = new OrigXHR();
var open = x.open;
x.open = function (m, u) {
if (typeof u === 'string' && blocked(u)) { this.__jzBlocked = true; }
return open.apply(this, arguments);
};
var send = x.send;
x.send = function () {
if (this.__jzBlocked) { return; }
return send.apply(this, arguments);
};
return x;
};
Patched.prototype = OrigXHR.prototype;
window.XMLHttpRequest = Patched;
}
if (navigator.sendBeacon) {
var sb = navigator.sendBeacon.bind(navigator);
navigator.sendBeacon = function (url, data) {
if (blocked(String(url || ''))) { return true; }
return sb(url, data);
};
}
})();
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.