-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinjected.js
52 lines (52 loc) · 1.89 KB
/
injected.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
(function() {
// Intercept XMLHttpRequest
const originalXHR = window.XMLHttpRequest;
function interceptXHR() {
const xhr = new originalXHR();
const open = xhr.open;
const send = xhr.send;
xhr.open = function() {
this._url = arguments[1];
return open.apply(this, arguments);
};
xhr.send = function() {
if (this._url.includes('/_api/graphql')) {
this.addEventListener('load', function() {
handleResponse(this.responseText);
});
}
return send.apply(this, arguments);
};
return xhr;
}
window.XMLHttpRequest = interceptXHR;
// Intercept fetch
const originalFetch = window.fetch;
window.fetch = function() {
const url = arguments[0];
if (typeof url === 'string' && url.includes('/_api/graphql')) {
return originalFetch.apply(this, arguments).then(response => {
response.clone().text().then(handleResponse);
return response;
});
}
return originalFetch.apply(this, arguments);
};
function handleResponse(responseText) {
try {
const response = JSON.parse(responseText);
if (response.data) {
if (response.data.plinkoBet) {
const betData = response.data.plinkoBet;
window.postMessage({ type: 'PLINKO_BET_DATA', data: betData }, '*');
} else if (response.data.kenoBet) {
const betData = response.data.kenoBet;
window.postMessage({ type: 'KENO_BET_DATA', data: betData }, '*');
}
}
} catch (error) {
console.error('Error parsing GraphQL response:', error);
}
}
console.log('Stake Bet Analyzer: GraphQL interception initialized');
})();