Merge branch 'immediate-finds' into immediate-finds-modules-proxy
This commit is contained in:
commit
2f55c7b126
|
@ -78,8 +78,7 @@ export default definePlugin({
|
||||||
// Because of that, its WebpackInstance doesnt export wreq.m or wreq.c
|
// Because of that, its WebpackInstance doesnt export wreq.m or wreq.c
|
||||||
|
|
||||||
// To circuvent this and disable Sentry we are gonna hook when wreq.g of its WebpackInstance is set.
|
// To circuvent this and disable Sentry we are gonna hook when wreq.g of its WebpackInstance is set.
|
||||||
// When that happens we are gonna obtain a reference to its internal module cache (wreq.c) and proxy its prototype,
|
// When that happens we are gonna forcefully throw an error and abort everything.
|
||||||
// so, when the first require to initialize the Sentry is attempted, we are gonna forcefully throw an error and abort everything.
|
|
||||||
Object.defineProperty(Function.prototype, "g", {
|
Object.defineProperty(Function.prototype, "g", {
|
||||||
configurable: true,
|
configurable: true,
|
||||||
|
|
||||||
|
@ -94,36 +93,30 @@ export default definePlugin({
|
||||||
// Ensure this is most likely the Sentry WebpackInstance.
|
// Ensure this is most likely the Sentry WebpackInstance.
|
||||||
// Function.g is a very generic property and is not uncommon for another WebpackInstance (or even a React component: <g></g>) to include it
|
// Function.g is a very generic property and is not uncommon for another WebpackInstance (or even a React component: <g></g>) to include it
|
||||||
const { stack } = new Error();
|
const { stack } = new Error();
|
||||||
if (!(stack?.includes("discord.com") || stack?.includes("discordapp.com")) || this.c != null || !String(this).includes("exports:{}")) {
|
if (!(stack?.includes("discord.com") || stack?.includes("discordapp.com")) || !String(this).includes("exports:{}") || this.c != null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const cacheExtractSym = Symbol("vencord.cacheExtract");
|
const assetPath = stack?.match(/\/assets\/.+?\.js/)?.[0];
|
||||||
Object.defineProperty(Object.prototype, cacheExtractSym, {
|
if (!assetPath) {
|
||||||
configurable: true,
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
get(this: WebpackRequire["c"]) {
|
const srcRequest = new XMLHttpRequest();
|
||||||
// One more condition to check if this is the Sentry WebpackInstance
|
srcRequest.open("GET", assetPath, false);
|
||||||
if (Array.isArray(this)) {
|
srcRequest.send();
|
||||||
return { exports: {} };
|
|
||||||
}
|
|
||||||
|
|
||||||
new Logger("NoTrack", "#8caaee").info("Disabling Sentry by proxying its WebpackInstance cache");
|
// Final condition to see if this is the Sentry WebpackInstance
|
||||||
Object.setPrototypeOf(this, new Proxy(this, {
|
if (!srcRequest.responseText.includes("window.DiscordSentry=")) {
|
||||||
get() {
|
return;
|
||||||
throw new Error("Sentry successfully disabled");
|
}
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
Reflect.deleteProperty(Function.prototype, "g");
|
new Logger("NoTrack", "#8caaee").info("Disabling Sentry by erroring its WebpackInstance");
|
||||||
Reflect.deleteProperty(Object.prototype, cacheExtractSym);
|
|
||||||
Reflect.deleteProperty(window, "DiscordSentry");
|
|
||||||
return { exports: {} };
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// WebpackRequire our fake module id
|
Reflect.deleteProperty(Function.prototype, "g");
|
||||||
this(cacheExtractSym);
|
Reflect.deleteProperty(window, "DiscordSentry");
|
||||||
|
|
||||||
|
throw new Error("Sentry successfully disabled");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue