Files
discord-decomp/_bundle/Module1076.js
T
2026-11-01 12:12:55 +02:00

155 lines
5.6 KiB
JavaScript

// Metro module 1076 (f1077).
import { getFunctionName, fill, getOriginalFunction, defineIntegration } from "./Module817";
import { wrap, WINDOW } from "./ignoreNextOnError";
let _excluded, _wrapRAF, _wrapXHR;
const _wrapTimeFunction = function _wrapTimeFunction(c12704_0) {
return function(...args) {
const r7 = args[0];
args[0] = wrap(r7, {
mechanism: {
handled: false,
type: `auto.browser.browserapierrors.${getFunctionName(c12704_0)}`
}
});
return c12704_0.apply(this, args);
};
};
_wrapRAF = function _wrapRAF(c12705_0) {
return function(a0) {
return c12705_0.apply(this, [wrap(a0, {
mechanism: {
data: {
handler: getFunctionName(c12705_0)
},
handled: false,
type: "auto.browser.browserapierrors.requestAnimationFrame"
}
})]);
};
};
_wrapXHR = function _wrapXHR(c12706_0) {
return function(...args) {
const _this = this;
["onload", "onerror", "onprogress", "onreadystatechange"].forEach((item) => {
if (item in _this && typeof _this[item] === "function") {
fill(_this, item, function(a0) {
const r3 = {
mechanism: {
data: {
handler: getFunctionName(a0)
},
handled: false,
type: `auto.browser.browserapierrors.xhr.${item}`
}
};
const originalFunction = getOriginalFunction(a0);
if (originalFunction) {
r3.mechanism.data.handler = getFunctionName(originalFunction);
}
return wrap(a0, r3);
});
}
});
return c12706_0.apply(this, args);
};
};
Object.defineProperty(exports, Symbol.toStringTag, {
value: "Module"
});
_excluded = ["EventTarget", "Window", "Node", "ApplicationCache", "AudioTrackList", "BroadcastChannel", "ChannelMergerNode", "CryptoOperation", "EventSource", "FileReader", "HTMLUnknownElement", "IDBDatabase", "IDBRequest", "IDBTransaction", "KeyOperation", "MediaController", "MessagePort", "ModalWindow", "Notification", "SVGElementInstance", "Screen", "SharedWorker", "TextTrack", "TextTrackCue", "TextTrackList", "WebSocket", "WebSocketWorker", "Worker", "XMLHttpRequest", "XMLHttpRequestEventTarget", "XMLHttpRequestUpload"];
export const browserApiErrorsIntegration = defineIntegration(function(r3 = {}) {
let c12707_0 = {
XMLHttpRequest: true,
eventTarget: true,
requestAnimationFrame: true,
setInterval: true,
setTimeout: true,
unregisterOriginalCallbacks: false,
...r3
};
return {
name: "BrowserApiErrors",
setupOnce: () => {
if (c12707_0.setTimeout) {
fill(WINDOW, "setTimeout", _wrapTimeFunction);
}
if (c12707_0.setInterval) {
fill(WINDOW, "setInterval", _wrapTimeFunction);
}
if (c12707_0.requestAnimationFrame) {
fill(WINDOW, "requestAnimationFrame", _wrapRAF);
}
if (c12707_0.XMLHttpRequest && "XMLHttpRequest" in WINDOW) {
fill(XMLHttpRequest.prototype, "send", _wrapXHR);
}
let eventTarget = c12707_0.eventTarget;
if (eventTarget) {
if (!Array.isArray(eventTarget)) {
eventTarget = _excluded;
}
eventTarget.forEach((item) => {
const target = item;
let c28752_1 = c12707_0;
const prototype = WINDOW[item]?.prototype;
const r17 = prototype == null;
let r18 = void 0;
if (!r17) {
const hasOwnProperty = prototype.hasOwnProperty;
r18 = hasOwnProperty == null ? void 0 : hasOwnProperty.call(prototype, "addEventListener");
}
if (r18) {
fill(prototype, "addEventListener", function(c31870_0) {
return function(a0, a1, a2) {
try {
if ((function isEventListenerObject(a0) {
return typeof a0.handleEvent === "function";
})(a1)) {
a1.handleEvent = wrap(a1.handleEvent, {
mechanism: {
data: {
handler: getFunctionName(a1),
target
},
handled: false,
type: "auto.browser.browserapierrors.handleEvent"
}
});
}
} catch ($e) {}
if (c28752_1.unregisterOriginalCallbacks) {
(function unregisterOriginalCallback(a0, a1, a2) {
if ((a0 ? typeof a0 === "object" : a0) && "removeEventListener" in a0 && typeof a0.removeEventListener === "function") {
a0.removeEventListener(a1, a2);
}
})(this, a0, a1);
}
return c31870_0.apply(this, [a0, wrap(a1, {
mechanism: {
data: {
handler: getFunctionName(a1),
target
},
handled: false,
type: "auto.browser.browserapierrors.addEventListener"
}
}), a2]);
};
});
fill(prototype, "removeEventListener", function(c31871_0) {
return function(a0, a1, a2) {
try {
const __sentry_wrapped__ = a1.__sentry_wrapped__;
if (__sentry_wrapped__) {
c31871_0.call(this, a0, __sentry_wrapped__, a2);
}
} catch ($e) {}
return c31871_0.call(this, a0, a1, a2);
};
});
}
});
}
}
};
});