-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinject.js
34 lines (22 loc) · 916 Bytes
/
inject.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
if (!window.hasHookedXMLHttpRequest) {
window.hasHookedXMLHttpRequest = true;
const originalOpen = XMLHttpRequest.prototype.open;
const originalSend = XMLHttpRequest.prototype.send;
XMLHttpRequest.prototype.open = function (method, url, async, user, password) {
this._url = url;
return originalOpen.apply(this, arguments);
};
XMLHttpRequest.prototype.send = function (body) {
this.addEventListener("load", function () {
if (this._url.includes(`https://api2.maang.in/problems/user/`)) {
const data = {
url: this._url,
status: this.status,
response: this.responseText,
};
window.dispatchEvent(new CustomEvent("xhrDataFetched", { detail: data }));
}
});
return originalSend.apply(this, arguments);
};
}