From f6798e53dee873960f3be7e80668b1eddeb65fd5 Mon Sep 17 00:00:00 2001 From: yellowsink Date: Sun, 12 Jan 2025 12:57:36 +0000 Subject: [PATCH] deploy: dbb0c6bd28c68c16ea16feee911cff63c5828fbc --- antitrack/plugin.js | 36 +++++++++++++++++++++++++++++++----- antitrack/plugin.json | 2 +- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/antitrack/plugin.js b/antitrack/plugin.js index 5157eca..a7c6deb 100644 --- a/antitrack/plugin.js +++ b/antitrack/plugin.js @@ -3,12 +3,38 @@ "use strict"; //#region plugins/antitrack/index.js -const { scoped } = shelter.plugin; +const { plugin: { scoped }, util: { log } } = shelter; try { - window.__SENTRY__.hub.getClient().getOptions().enabled = false; - Object.keys(console).forEach((x) => console[x] = console[x].__sentry_original__ ?? console[x]); -} catch {} -scoped.http.intercept("POST", /^\/science|^\/error-reporting-proxy/, () => {}); + if (DiscordSentry) DiscordSentry.close(); +else Object.defineProperty(window, "DiscordSentry", { + set(v) { + delete window.DiscordSentry; + window.DiscordSentry = v; + setTimeout(v.close); + }, + enumerable: false, + configurable: true + }); +} catch (e) { + log(`[Antitrack] Error while disabling Sentry ${e}`); +} +try { + Object.keys(console).forEach((func) => { + const original = console[func]?.__sentry_original__; + if (!original) return; + console[func] = original; + }); +} catch (e) { + log(`[Antitrack] Error while unpatching console functions ${e}`); +} +scoped.http.intercept("POST", /^\/science/, () => {}); +const metricsRe = /^https?:\/\/([a-z0-9\-]+\.)?discord\.com\/api\/v\d+\/metrics/; +const getSentryProp = (obj) => obj[Object.keys(obj).find((k) => k.startsWith("__sentry_xhr"))]; +scoped.patcher.instead("send", XMLHttpRequest.prototype, function(args, orig) { + const url = getSentryProp(this)?.url; + if (typeof url === "string" && metricsRe.test(url)) return; + return orig.apply(this, args); +}); //#endregion })(); \ No newline at end of file diff --git a/antitrack/plugin.json b/antitrack/plugin.json index 2b94b58..c3e7c96 100644 --- a/antitrack/plugin.json +++ b/antitrack/plugin.json @@ -1 +1 @@ -{"name":"Antitrack","description":"The essential.","author":"Yellowsink","hash":"eb4c72e5ce13d670237f727b3bd2b0b9"} \ No newline at end of file +{"name":"Antitrack","description":"The essential.","author":"Yellowsink","hash":"1c0b7ced93be17a775b05e83f703db47"} \ No newline at end of file