mirror of https://github.com/gorhill/uBlock.git
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
|
||||
// https://github.com/uBlockOrigin/uAssets/issues/5184
|
||||
// https://github.com/pixeltris/TwitchAdSolutions/commit/6be4c5313035
|
||||
(function() {
|
||||
if ( /(^|\.)twitch\.tv$/.test(document.location.hostname) === false ) { return; }
|
||||
var realFetch = window.fetch;
|
||||
window.fetch = function(input) {
|
||||
if ( arguments.length >= 2 && typeof input === 'string' && input.includes('/access_token') ) {
|
||||
var url = new URL(arguments[0]);
|
||||
url.searchParams.delete('platform');
|
||||
arguments[0] = url.href;
|
||||
window.fetch = new Proxy(window.fetch, {
|
||||
apply: function(target, thisArg, args) {
|
||||
const [ url, init ] = args;
|
||||
if (
|
||||
typeof url === 'string' &&
|
||||
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';
|
||||
}
|
||||
return realFetch.apply(this, arguments);
|
||||
};
|
||||
if ( typeof headers['Device-ID'] === 'string' ) {
|
||||
headers['Device-ID'] = 'twitch-web-wall-mason';
|
||||
}
|
||||
}
|
||||
return Reflect.apply(target, thisArg, args);
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue