Substack : bloquer l'indicateur « follow »
Intercepte fetch, XHR et sendBeacon afin que Substack ne signale ni vues ni suivis.
Code à copier
// 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);
};
}
})();
Comment utiliser cet exemple
- Copiez le code avec le bouton ci-dessus.
- Installez JustZix (2 minutes) et ouvrez l'extension sur la page cible.
- Ajoutez une nouvelle règle correspondant à cette page.
- Collez le code dans le panneau JavaScript de la règle et enregistrez — il s'exécute à chaque visite de page.
Notez cet exemple
Aucune note — soyez le premier.