Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function() {
- const blockedDomains = [
- "privatestats.whatsapp.net",
- "dit.whatsapp.net",
- "graph.facebook.com",
- "graph.whatsapp.net",
- "graph.whatsapp.com"
- ];
- function isBlocked(url) {
- try {
- const hostname = new URL(url).hostname;
- return blockedDomains.some(dom => hostname === dom || hostname.endsWith("." + dom));
- } catch (e) {
- return false;
- }
- }
- // Intercepta fetch
- const origFetch = window.fetch;
- window.fetch = async function(input, init) {
- const url = typeof input === "string" ? input : input.url;
- if (isBlocked(url)) {
- console.warn("[Bloqueado pelo script] fetch para:", url);
- localStorage.setItem("ultBloqueio", JSON.stringify({url, time: Date.now()}));
- return new Response(null, { status: 418, statusText: "Blocked by script" });
- }
- return origFetch.call(this, input, init);
- };
- // Intercepta XMLHttpRequest
- const OrigXHR = window.XMLHttpRequest;
- function XHRProxy() {
- const xhr = new OrigXHR();
- const origOpen = xhr.open;
- xhr.open = function(method, url, ...rest) {
- this._url = url;
- return origOpen.call(this, method, url, ...rest);
- };
- xhr.send = function(...args) {
- if (isBlocked(this._url)) {
- console.warn("[Bloqueado pelo script] XHR para:", this._url);
- localStorage.setItem("ultBloqueioXHR", JSON.stringify({url: this._url, time: Date.now()}));
- this.abort();
- return;
- }
- return OrigXHR.prototype.send.apply(this, args);
- };
- return xhr;
- }
- window.XMLHttpRequest = XHRProxy;
- console.log("🛡️ Script de bloqueio de domínios de rastreamento do WhatsApp/Facebook ativado.");
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement