2022-09-29 23:46:07 +02:00
|
|
|
import {webFrame} from "electron";
|
|
|
|
|
2022-10-14 05:42:05 +02:00
|
|
|
/* global window:false */
|
|
|
|
|
2022-09-29 23:46:07 +02:00
|
|
|
export default function () {
|
|
|
|
const patcher = function () {
|
|
|
|
const chunkName = "webpackChunkdiscord_app";
|
|
|
|
const predefine = function (target, prop, effect) {
|
|
|
|
const value = target[prop];
|
|
|
|
Object.defineProperty(target, prop, {
|
|
|
|
get() {return value;},
|
2022-10-14 05:42:05 +02:00
|
|
|
set(newValue) {
|
2022-09-29 23:46:07 +02:00
|
|
|
Object.defineProperty(target, prop, {
|
2022-10-14 05:42:05 +02:00
|
|
|
value: newValue,
|
2022-09-29 23:46:07 +02:00
|
|
|
configurable: true,
|
|
|
|
enumerable: true,
|
|
|
|
writable: true
|
|
|
|
});
|
|
|
|
|
|
|
|
try {
|
2022-10-14 05:42:05 +02:00
|
|
|
effect(newValue);
|
|
|
|
}
|
|
|
|
catch (error) {
|
|
|
|
// eslint-disable-next-line no-console
|
2022-09-29 23:46:07 +02:00
|
|
|
console.error(error);
|
|
|
|
}
|
|
|
|
|
2022-10-14 05:42:05 +02:00
|
|
|
// eslint-disable-next-line no-setter-return
|
|
|
|
return newValue;
|
2022-09-29 23:46:07 +02:00
|
|
|
},
|
|
|
|
configurable: true
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
if (!Reflect.has(window, chunkName)) {
|
|
|
|
predefine(window, chunkName, instance => {
|
|
|
|
predefine(instance, "push", () => {
|
|
|
|
instance.push([[Symbol()], {}, require => {
|
|
|
|
require.d = (target, exports) => {
|
|
|
|
for (const key in exports) {
|
|
|
|
if (!Reflect.has(exports, key) || target[key]) continue;
|
|
|
|
|
|
|
|
Object.defineProperty(target, key, {
|
|
|
|
get: exports[key],
|
|
|
|
enumerable: true,
|
|
|
|
configurable: true
|
|
|
|
});
|
|
|
|
}
|
2022-10-14 05:42:05 +02:00
|
|
|
};
|
2022-09-29 23:46:07 +02:00
|
|
|
}]);
|
|
|
|
|
|
|
|
instance.pop();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
webFrame.top.executeJavaScript("(" + patcher + ")()");
|
|
|
|
}
|