-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgql_injection.js
More file actions
45 lines (44 loc) · 2.78 KB
/
Copy pathgql_injection.js
File metadata and controls
45 lines (44 loc) · 2.78 KB
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
// gql_injection.js
'use strict';
(() => {
const оригинальнаяФункция = window.fetch;
// const originalFunction = window.fetch;
window.fetch = function (адрес, параметры) {
// window.fetch = function (address, parameters) {
const обещание = оригинальнаяФункция(адрес, параметры);
// const promise = originalFunction(address, parameters);
if (адрес === 'https://gql.twitch.tv/integrity' && параметры && параметры.method && параметры.method.toUpperCase() === 'POST' && параметры.headers && параметры.headers.Authorization) {
// if (address === 'https://gql.twitch.tv/integrity' && parameters && parameters.method && parameters.method.toUpperCase() === 'POST' && parameters.headers && parameters.headers.Authorization) {
обещание.then(ответ => {
// promise.then(response => {
if (ответ.ok && ответ.status === 200) {
// if (response.ok && response.status === 200) {
return ответ.clone().json().then(({
// return response.clone().json().then(({
token: сТокен,
// token: sToken,
expiration: чПротухнетПосле
// expiration: nExpiresAt
}) => {
if (typeof сТокен == 'string' && сТокен && Number.isSafeInteger(чПротухнетПосле)) {
// if (typeof sToken == 'string' && sToken && Number.isSafeInteger(nExpiresAt)) {
const текущееВремя = Date.now();
// const currentTime = Date.now();
чПротухнетПосле = Math.min(Math.max(чПротухнетПосле - 3 * 60 * 1e3, текущееВремя + 1 * 60 * 60 * 1e3), текущееВремя + 24 * 60 * 60 * 1e3);
// nExpiresAt = Math.min(Math.max(nExpiresAt - 3 * 60 * 1e3, currentTime + 1 * 60 * 60 * 1e3), currentTime + 24 * 60 * 60 * 1e3);
document.cookie = `tw5~gqltoken=${encodeURIComponent(JSON.stringify({
сТокен,
// sToken,
чПротухнетПосле
// nExpiresAt
}))}; path=/tw5~storage/; samesite=none; secure; max-age=86400`;
}
});
}
}).catch(причина => {});
// }).catch(reason => {});
}
return обещание;
// return promise;
};
})();