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

Fix broken site functionality #50 #45

This commit is contained in:
pixeltris 2021-10-14 14:36:13 +01:00
parent 6be4c53130
commit 3d2883ea9e
8 changed files with 84 additions and 87 deletions

View File

@ -2,6 +2,8 @@
This repo aims to provide multiple solutions for blocking Twitch ads. This repo aims to provide multiple solutions for blocking Twitch ads.
**Don't combine Twitch specific ad blockers.**
## Recommendations ## Recommendations
Proxies are the most reliable way of avoiding ads ([buffering / downtime info](full-list.md#proxy-issues)). Proxies are the most reliable way of avoiding ads ([buffering / downtime info](full-list.md#proxy-issues)).
@ -22,10 +24,9 @@ Alternatively:
**There are better / easier to use methods in the above** `Recommendations`. **There are better / easier to use methods in the above** `Recommendations`.
*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)) - 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. - No ads.
- *Enabled by default on uBlock Origin 1.38.4*.
- 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

@ -1,7 +1,7 @@
// ==UserScript== // ==UserScript==
// @name TwitchAdSolutions // @name TwitchAdSolutions
// @namespace https://github.com/pixeltris/TwitchAdSolutions // @namespace https://github.com/pixeltris/TwitchAdSolutions
// @version 1.11 // @version 1.12
// @description Multiple solutions for blocking Twitch ads // @description Multiple solutions for blocking Twitch ads
// @author pixeltris // @author pixeltris
// @match *://*.twitch.tv/* // @match *://*.twitch.tv/*
@ -492,14 +492,7 @@
var realFetch = window.fetch; var realFetch = window.fetch;
window.fetch = function(url, init, ...args) { window.fetch = function(url, init, ...args) {
if (typeof url === 'string') { if (typeof url === 'string') {
if (url.includes('/access_token') || url.includes('gql')) { if (url.includes('gql')) {
if (OPT_ACCESS_TOKEN_PLAYER_TYPE) {
if (url.includes('gql') && init && typeof init.body === 'string' && init.body.includes('PlaybackAccessToken')) {
const newBody = JSON.parse(init.body);
newBody.variables.playerType = OPT_ACCESS_TOKEN_PLAYER_TYPE;
init.body = JSON.stringify(newBody);
}
}
var deviceId = init.headers['X-Device-Id']; var deviceId = init.headers['X-Device-Id'];
if (typeof deviceId !== 'string') { if (typeof deviceId !== 'string') {
deviceId = init.headers['Device-ID']; deviceId = init.headers['Device-ID'];
@ -513,12 +506,19 @@
value: gql_device_id value: gql_device_id
}); });
} }
if (OPT_ROLLING_DEVICE_ID) { if (typeof init.body === 'string' && init.body.includes('PlaybackAccessToken')) {
if (typeof init.headers['X-Device-Id'] === 'string') { if (OPT_ACCESS_TOKEN_PLAYER_TYPE) {
init.headers['X-Device-Id'] = gql_device_id_rolling; const newBody = JSON.parse(init.body);
newBody.variables.playerType = OPT_ACCESS_TOKEN_PLAYER_TYPE;
init.body = JSON.stringify(newBody);
} }
if (typeof init.headers['Device-ID'] === 'string') { if (OPT_ROLLING_DEVICE_ID) {
init.headers['Device-ID'] = gql_device_id_rolling; if (typeof init.headers['X-Device-Id'] === 'string') {
init.headers['X-Device-Id'] = gql_device_id_rolling;
}
if (typeof init.headers['Device-ID'] === 'string') {
init.headers['Device-ID'] = gql_device_id_rolling;
}
} }
} }
} }

View File

@ -4,14 +4,12 @@ twitch-videoad.js application/javascript
function hookFetch() { function hookFetch() {
var realFetch = window.fetch; var realFetch = window.fetch;
window.fetch = function(url, init, ...args) { window.fetch = function(url, init, ...args) {
if (typeof url === 'string') { if (typeof url === 'string' && url.includes('gql') && typeof init.body == 'string' && init.body.includes('PlaybackAccessToken')) {
if (url.includes('gql')) { if (typeof init.headers['X-Device-Id'] === 'string') {
if (typeof init.headers['X-Device-Id'] === 'string') { init.headers['X-Device-Id'] = 'twitch-web-wall-mason';
init.headers['X-Device-Id'] = 'twitch-web-wall-mason'; }
} if (typeof init.headers['Device-ID'] === 'string') {
if (typeof init.headers['Device-ID'] === 'string') { init.headers['Device-ID'] = 'twitch-web-wall-mason';
init.headers['Device-ID'] = 'twitch-web-wall-mason';
}
} }
} }
return realFetch.apply(this, arguments); return realFetch.apply(this, arguments);

View File

@ -1,7 +1,7 @@
// ==UserScript== // ==UserScript==
// @name TwitchAdSolutions (bypass) // @name TwitchAdSolutions (bypass)
// @namespace https://github.com/pixeltris/TwitchAdSolutions // @namespace https://github.com/pixeltris/TwitchAdSolutions
// @version 1.0 // @version 1.1
// @updateURL https://github.com/pixeltris/TwitchAdSolutions/raw/master/bypass/bypass.user.js // @updateURL https://github.com/pixeltris/TwitchAdSolutions/raw/master/bypass/bypass.user.js
// @downloadURL 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) // @description Multiple solutions for blocking Twitch ads (bypass)
@ -15,14 +15,12 @@
function hookFetch() { function hookFetch() {
var realFetch = window.fetch; var realFetch = window.fetch;
window.fetch = function(url, init, ...args) { window.fetch = function(url, init, ...args) {
if (typeof url === 'string') { if (typeof url === 'string' && url.includes('gql') && typeof init.body == 'string' && init.body.includes('PlaybackAccessToken')) {
if (url.includes('gql')) { if (typeof init.headers['X-Device-Id'] === 'string') {
if (typeof init.headers['X-Device-Id'] === 'string') { init.headers['X-Device-Id'] = 'twitch-web-wall-mason';
init.headers['X-Device-Id'] = 'twitch-web-wall-mason'; }
} if (typeof init.headers['Device-ID'] === 'string') {
if (typeof init.headers['Device-ID'] === 'string') { init.headers['Device-ID'] = 'twitch-web-wall-mason';
init.headers['Device-ID'] = 'twitch-web-wall-mason';
}
} }
} }
return realFetch.apply(this, arguments); return realFetch.apply(this, arguments);

View File

@ -483,14 +483,7 @@ twitch-videoad.js application/javascript
var realFetch = window.fetch; var realFetch = window.fetch;
window.fetch = function(url, init, ...args) { window.fetch = function(url, init, ...args) {
if (typeof url === 'string') { if (typeof url === 'string') {
if (url.includes('/access_token') || url.includes('gql')) { if (url.includes('gql')) {
if (OPT_ACCESS_TOKEN_PLAYER_TYPE) {
if (url.includes('gql') && init && typeof init.body === 'string' && init.body.includes('PlaybackAccessToken')) {
const newBody = JSON.parse(init.body);
newBody.variables.playerType = OPT_ACCESS_TOKEN_PLAYER_TYPE;
init.body = JSON.stringify(newBody);
}
}
var deviceId = init.headers['X-Device-Id']; var deviceId = init.headers['X-Device-Id'];
if (typeof deviceId !== 'string') { if (typeof deviceId !== 'string') {
deviceId = init.headers['Device-ID']; deviceId = init.headers['Device-ID'];
@ -504,12 +497,19 @@ twitch-videoad.js application/javascript
value: gql_device_id value: gql_device_id
}); });
} }
if (OPT_ROLLING_DEVICE_ID) { if (typeof init.body === 'string' && init.body.includes('PlaybackAccessToken')) {
if (typeof init.headers['X-Device-Id'] === 'string') { if (OPT_ACCESS_TOKEN_PLAYER_TYPE) {
init.headers['X-Device-Id'] = gql_device_id_rolling; const newBody = JSON.parse(init.body);
newBody.variables.playerType = OPT_ACCESS_TOKEN_PLAYER_TYPE;
init.body = JSON.stringify(newBody);
} }
if (typeof init.headers['Device-ID'] === 'string') { if (OPT_ROLLING_DEVICE_ID) {
init.headers['Device-ID'] = gql_device_id_rolling; if (typeof init.headers['X-Device-Id'] === 'string') {
init.headers['X-Device-Id'] = gql_device_id_rolling;
}
if (typeof init.headers['Device-ID'] === 'string') {
init.headers['Device-ID'] = gql_device_id_rolling;
}
} }
} }
} }

View File

@ -1,7 +1,7 @@
// ==UserScript== // ==UserScript==
// @name TwitchAdSolutions (notify-reload) // @name TwitchAdSolutions (notify-reload)
// @namespace https://github.com/pixeltris/TwitchAdSolutions // @namespace https://github.com/pixeltris/TwitchAdSolutions
// @version 1.11 // @version 1.12
// @updateURL https://github.com/pixeltris/TwitchAdSolutions/raw/master/notify-reload/notify-reload.user.js // @updateURL https://github.com/pixeltris/TwitchAdSolutions/raw/master/notify-reload/notify-reload.user.js
// @downloadURL https://github.com/pixeltris/TwitchAdSolutions/raw/master/notify-reload/notify-reload.user.js // @downloadURL https://github.com/pixeltris/TwitchAdSolutions/raw/master/notify-reload/notify-reload.user.js
// @description Multiple solutions for blocking Twitch ads (notify-reload) // @description Multiple solutions for blocking Twitch ads (notify-reload)
@ -494,14 +494,7 @@
var realFetch = window.fetch; var realFetch = window.fetch;
window.fetch = function(url, init, ...args) { window.fetch = function(url, init, ...args) {
if (typeof url === 'string') { if (typeof url === 'string') {
if (url.includes('/access_token') || url.includes('gql')) { if (url.includes('gql')) {
if (OPT_ACCESS_TOKEN_PLAYER_TYPE) {
if (url.includes('gql') && init && typeof init.body === 'string' && init.body.includes('PlaybackAccessToken')) {
const newBody = JSON.parse(init.body);
newBody.variables.playerType = OPT_ACCESS_TOKEN_PLAYER_TYPE;
init.body = JSON.stringify(newBody);
}
}
var deviceId = init.headers['X-Device-Id']; var deviceId = init.headers['X-Device-Id'];
if (typeof deviceId !== 'string') { if (typeof deviceId !== 'string') {
deviceId = init.headers['Device-ID']; deviceId = init.headers['Device-ID'];
@ -515,12 +508,19 @@
value: gql_device_id value: gql_device_id
}); });
} }
if (OPT_ROLLING_DEVICE_ID) { if (typeof init.body === 'string' && init.body.includes('PlaybackAccessToken')) {
if (typeof init.headers['X-Device-Id'] === 'string') { if (OPT_ACCESS_TOKEN_PLAYER_TYPE) {
init.headers['X-Device-Id'] = gql_device_id_rolling; const newBody = JSON.parse(init.body);
newBody.variables.playerType = OPT_ACCESS_TOKEN_PLAYER_TYPE;
init.body = JSON.stringify(newBody);
} }
if (typeof init.headers['Device-ID'] === 'string') { if (OPT_ROLLING_DEVICE_ID) {
init.headers['Device-ID'] = gql_device_id_rolling; if (typeof init.headers['X-Device-Id'] === 'string') {
init.headers['X-Device-Id'] = gql_device_id_rolling;
}
if (typeof init.headers['Device-ID'] === 'string') {
init.headers['Device-ID'] = gql_device_id_rolling;
}
} }
} }
} }

View File

@ -483,14 +483,7 @@ twitch-videoad.js application/javascript
var realFetch = window.fetch; var realFetch = window.fetch;
window.fetch = function(url, init, ...args) { window.fetch = function(url, init, ...args) {
if (typeof url === 'string') { if (typeof url === 'string') {
if (url.includes('/access_token') || url.includes('gql')) { if (url.includes('gql')) {
if (OPT_ACCESS_TOKEN_PLAYER_TYPE) {
if (url.includes('gql') && init && typeof init.body === 'string' && init.body.includes('PlaybackAccessToken')) {
const newBody = JSON.parse(init.body);
newBody.variables.playerType = OPT_ACCESS_TOKEN_PLAYER_TYPE;
init.body = JSON.stringify(newBody);
}
}
var deviceId = init.headers['X-Device-Id']; var deviceId = init.headers['X-Device-Id'];
if (typeof deviceId !== 'string') { if (typeof deviceId !== 'string') {
deviceId = init.headers['Device-ID']; deviceId = init.headers['Device-ID'];
@ -504,12 +497,19 @@ twitch-videoad.js application/javascript
value: gql_device_id value: gql_device_id
}); });
} }
if (OPT_ROLLING_DEVICE_ID) { if (typeof init.body === 'string' && init.body.includes('PlaybackAccessToken')) {
if (typeof init.headers['X-Device-Id'] === 'string') { if (OPT_ACCESS_TOKEN_PLAYER_TYPE) {
init.headers['X-Device-Id'] = gql_device_id_rolling; const newBody = JSON.parse(init.body);
newBody.variables.playerType = OPT_ACCESS_TOKEN_PLAYER_TYPE;
init.body = JSON.stringify(newBody);
} }
if (typeof init.headers['Device-ID'] === 'string') { if (OPT_ROLLING_DEVICE_ID) {
init.headers['Device-ID'] = gql_device_id_rolling; if (typeof init.headers['X-Device-Id'] === 'string') {
init.headers['X-Device-Id'] = gql_device_id_rolling;
}
if (typeof init.headers['Device-ID'] === 'string') {
init.headers['Device-ID'] = gql_device_id_rolling;
}
} }
} }
} }

View File

@ -1,7 +1,7 @@
// ==UserScript== // ==UserScript==
// @name TwitchAdSolutions (notify-strip) // @name TwitchAdSolutions (notify-strip)
// @namespace https://github.com/pixeltris/TwitchAdSolutions // @namespace https://github.com/pixeltris/TwitchAdSolutions
// @version 1.11 // @version 1.12
// @updateURL https://github.com/pixeltris/TwitchAdSolutions/raw/master/notify-strip/notify-strip.user.js // @updateURL https://github.com/pixeltris/TwitchAdSolutions/raw/master/notify-strip/notify-strip.user.js
// @downloadURL https://github.com/pixeltris/TwitchAdSolutions/raw/master/notify-strip/notify-strip.user.js // @downloadURL https://github.com/pixeltris/TwitchAdSolutions/raw/master/notify-strip/notify-strip.user.js
// @description Multiple solutions for blocking Twitch ads (notify-strip) // @description Multiple solutions for blocking Twitch ads (notify-strip)
@ -494,14 +494,7 @@
var realFetch = window.fetch; var realFetch = window.fetch;
window.fetch = function(url, init, ...args) { window.fetch = function(url, init, ...args) {
if (typeof url === 'string') { if (typeof url === 'string') {
if (url.includes('/access_token') || url.includes('gql')) { if (url.includes('gql')) {
if (OPT_ACCESS_TOKEN_PLAYER_TYPE) {
if (url.includes('gql') && init && typeof init.body === 'string' && init.body.includes('PlaybackAccessToken')) {
const newBody = JSON.parse(init.body);
newBody.variables.playerType = OPT_ACCESS_TOKEN_PLAYER_TYPE;
init.body = JSON.stringify(newBody);
}
}
var deviceId = init.headers['X-Device-Id']; var deviceId = init.headers['X-Device-Id'];
if (typeof deviceId !== 'string') { if (typeof deviceId !== 'string') {
deviceId = init.headers['Device-ID']; deviceId = init.headers['Device-ID'];
@ -515,12 +508,19 @@
value: gql_device_id value: gql_device_id
}); });
} }
if (OPT_ROLLING_DEVICE_ID) { if (typeof init.body === 'string' && init.body.includes('PlaybackAccessToken')) {
if (typeof init.headers['X-Device-Id'] === 'string') { if (OPT_ACCESS_TOKEN_PLAYER_TYPE) {
init.headers['X-Device-Id'] = gql_device_id_rolling; const newBody = JSON.parse(init.body);
newBody.variables.playerType = OPT_ACCESS_TOKEN_PLAYER_TYPE;
init.body = JSON.stringify(newBody);
} }
if (typeof init.headers['Device-ID'] === 'string') { if (OPT_ROLLING_DEVICE_ID) {
init.headers['Device-ID'] = gql_device_id_rolling; if (typeof init.headers['X-Device-Id'] === 'string') {
init.headers['X-Device-Id'] = gql_device_id_rolling;
}
if (typeof init.headers['Device-ID'] === 'string') {
init.headers['Device-ID'] = gql_device_id_rolling;
}
} }
} }
} }