mirror of
https://github.com/gorhill/uBlock.git
synced 2024-10-06 09:37:12 +02:00
Update twitch-videoad scriptlet
Related issue:
- https://github.com/uBlockOrigin/uAssets/issues/5184#issuecomment-938379331
Solution contributed by <https://github.com/pixeltris>:
- 6be4c53130
This commit is contained in:
parent
c4b7ee80ea
commit
0d3a1932e9
@ -1559,19 +1559,31 @@
|
|||||||
})();
|
})();
|
||||||
|
|
||||||
|
|
||||||
// https://github.com/uBlockOrigin/uAssets/issues/5184
|
|
||||||
/// twitch-videoad.js
|
/// twitch-videoad.js
|
||||||
|
// https://github.com/uBlockOrigin/uAssets/issues/5184
|
||||||
|
// https://github.com/pixeltris/TwitchAdSolutions/commit/6be4c5313035
|
||||||
(function() {
|
(function() {
|
||||||
if ( /(^|\.)twitch\.tv$/.test(document.location.hostname) === false ) { return; }
|
if ( /(^|\.)twitch\.tv$/.test(document.location.hostname) === false ) { return; }
|
||||||
var realFetch = window.fetch;
|
window.fetch = new Proxy(window.fetch, {
|
||||||
window.fetch = function(input) {
|
apply: function(target, thisArg, args) {
|
||||||
if ( arguments.length >= 2 && typeof input === 'string' && input.includes('/access_token') ) {
|
const [ url, init ] = args;
|
||||||
var url = new URL(arguments[0]);
|
if (
|
||||||
url.searchParams.delete('platform');
|
typeof url === 'string' &&
|
||||||
arguments[0] = url.href;
|
url.includes('gql') &&
|
||||||
|
init instanceof Object &&
|
||||||
|
init.headers instanceof Object
|
||||||
|
) {
|
||||||
|
const { headers } = init;
|
||||||
|
if ( typeof headers['X-Device-Id'] === 'string' ) {
|
||||||
|
headers['X-Device-Id'] = 'twitch-web-wall-mason';
|
||||||
|
}
|
||||||
|
if ( typeof headers['Device-ID'] === 'string' ) {
|
||||||
|
headers['Device-ID'] = 'twitch-web-wall-mason';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Reflect.apply(target, thisArg, args);
|
||||||
}
|
}
|
||||||
return realFetch.apply(this, arguments);
|
});
|
||||||
};
|
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user