1
0
mirror of https://github.com/pixeltris/TwitchAdSolutions.git synced 2024-11-22 10:22:51 +01:00

Add "bypass" script

This commit is contained in:
pixeltris 2021-10-06 17:04:29 +01:00
parent 8bf35bf03f
commit 6be4c53130
3 changed files with 55 additions and 0 deletions

View File

@ -24,6 +24,8 @@ Alternatively:
*Don't combine these scripts with other Twitch specific ad blockers.* *Don't combine these scripts with other Twitch specific ad blockers.*
- bypass ([ublock](https://github.com/pixeltris/TwitchAdSolutions/raw/master/bypass/bypass-ublock-origin.js) / [userscript](https://github.com/pixeltris/TwitchAdSolutions/raw/master/bypass/bypass.user.js))
- No ads.
- notify-strip ([ublock](https://github.com/pixeltris/TwitchAdSolutions/raw/master/notify-strip/notify-strip-ublock-origin.js) / [userscript](https://github.com/pixeltris/TwitchAdSolutions/raw/master/notify-strip/notify-strip.user.js)) - notify-strip ([ublock](https://github.com/pixeltris/TwitchAdSolutions/raw/master/notify-strip/notify-strip-ublock-origin.js) / [userscript](https://github.com/pixeltris/TwitchAdSolutions/raw/master/notify-strip/notify-strip.user.js))
- Ad segments are replaced by low resolution stream segments. - Ad segments are replaced by low resolution stream segments.
- Notifies Twitch that ads were "watched" (reduces preroll ad frequency). - Notifies Twitch that ads were "watched" (reduces preroll ad frequency).

View File

@ -0,0 +1,21 @@
twitch-videoad.js application/javascript
(function() {
if ( /(^|\.)twitch\.tv$/.test(document.location.hostname) === false ) { return; }
function hookFetch() {
var realFetch = window.fetch;
window.fetch = function(url, init, ...args) {
if (typeof url === 'string') {
if (url.includes('gql')) {
if (typeof init.headers['X-Device-Id'] === 'string') {
init.headers['X-Device-Id'] = 'twitch-web-wall-mason';
}
if (typeof init.headers['Device-ID'] === 'string') {
init.headers['Device-ID'] = 'twitch-web-wall-mason';
}
}
}
return realFetch.apply(this, arguments);
}
}
hookFetch();
})();

32
bypass/bypass.user.js Normal file
View File

@ -0,0 +1,32 @@
// ==UserScript==
// @name TwitchAdSolutions (bypass)
// @namespace https://github.com/pixeltris/TwitchAdSolutions
// @version 1.0
// @updateURL https://github.com/pixeltris/TwitchAdSolutions/raw/master/bypass/bypass.user.js
// @downloadURL https://github.com/pixeltris/TwitchAdSolutions/raw/master/bypass/bypass.user.js
// @description Multiple solutions for blocking Twitch ads (bypass)
// @author pixeltris
// @match *://*.twitch.tv/*
// @run-at document-start
// @grant none
// ==/UserScript==
(function() {
'use strict';
function hookFetch() {
var realFetch = window.fetch;
window.fetch = function(url, init, ...args) {
if (typeof url === 'string') {
if (url.includes('gql')) {
if (typeof init.headers['X-Device-Id'] === 'string') {
init.headers['X-Device-Id'] = 'twitch-web-wall-mason';
}
if (typeof init.headers['Device-ID'] === 'string') {
init.headers['Device-ID'] = 'twitch-web-wall-mason';
}
}
}
return realFetch.apply(this, arguments);
}
}
hookFetch();
})();