mirror of
https://github.com/pixeltris/TwitchAdSolutions.git
synced 2024-11-22 10:22:51 +01:00
Fix ad blocking for logged in users (video-swap-new / vaft)
This commit is contained in:
parent
b986914732
commit
ccfcc71a12
@ -59,8 +59,8 @@ twitch-videoad.js text/javascript
|
||||
scope.ClientSession = 'null';
|
||||
//scope.PlayerType1 = 'site'; //Source - NOTE: This is unused as it's implicitly used by the website iself
|
||||
scope.PlayerType2 = 'autoplay'; //360p
|
||||
scope.PlayerType3 = 'proxy'; //Source
|
||||
scope.PlayerType4 = 'embed'; //Source
|
||||
scope.PlayerType3 = 'embed'; //Source
|
||||
//scope.PlayerType4 = 'embed'; //Source
|
||||
scope.CurrentChannelName = null;
|
||||
scope.UsherParams = null;
|
||||
scope.WasShowingAd = false;
|
||||
@ -73,7 +73,8 @@ twitch-videoad.js text/javascript
|
||||
scope.DefaultProxyType = null;
|
||||
scope.DefaultForcedQuality = null;
|
||||
scope.DefaultProxyQuality = null;
|
||||
scope.ClientIntegrity = null;
|
||||
scope.ClientIntegrityHeader = null;
|
||||
scope.AuthorizationHeader = null;
|
||||
}
|
||||
declareOptions(window);
|
||||
var TwitchAdblockSettings = {
|
||||
@ -123,8 +124,10 @@ twitch-videoad.js text/javascript
|
||||
ClientID = e.data.value;
|
||||
} else if (e.data.key == 'UpdateDeviceId') {
|
||||
GQLDeviceID = e.data.value;
|
||||
} else if (e.data.key == 'UpdateClientIntegrity') {
|
||||
ClientIntegrity = e.data.value;
|
||||
} else if (e.data.key == 'UpdateClientIntegrityHeader') {
|
||||
ClientIntegrityHeader = e.data.value;
|
||||
} else if (e.data.key == 'UpdateAuthorizationHeader') {
|
||||
AuthorizationHeader = e.data.value;
|
||||
}
|
||||
});
|
||||
hookWorkerFetch();
|
||||
@ -140,7 +143,7 @@ twitch-videoad.js text/javascript
|
||||
if (adBlockDiv == null) {
|
||||
adBlockDiv = getAdBlockDiv();
|
||||
}
|
||||
adBlockDiv.P.textContent = 'Blocking ads...';
|
||||
adBlockDiv.P.textContent = 'Blocking ads';
|
||||
adBlockDiv.style.display = 'block';
|
||||
} else if (e.data.key == 'HideAdBlockBanner') {
|
||||
if (adBlockDiv == null) {
|
||||
@ -281,9 +284,9 @@ twitch-videoad.js text/javascript
|
||||
if (weaverText.includes(AdSignifier)) {
|
||||
weaverText = await processM3U8(url, responseText, realFetch, PlayerType3);
|
||||
}
|
||||
if (weaverText.includes(AdSignifier)) {
|
||||
weaverText = await processM3U8(url, responseText, realFetch, PlayerType4);
|
||||
}
|
||||
//if (weaverText.includes(AdSignifier)) {
|
||||
// weaverText = await processM3U8(url, responseText, realFetch, PlayerType4);
|
||||
//}
|
||||
resolve(new Response(weaverText));
|
||||
};
|
||||
var send = function() {
|
||||
@ -659,9 +662,9 @@ twitch-videoad.js text/javascript
|
||||
return gqlRequest(body, realFetch);
|
||||
}
|
||||
function gqlRequest(body, realFetch) {
|
||||
if (ClientIntegrity == null) {
|
||||
console.error('ClientIntegrity is null');
|
||||
throw 'ClientIntegrity is null';
|
||||
if (ClientIntegrityHeader == null) {
|
||||
console.error('ClientIntegrityHeader is null');
|
||||
throw 'ClientIntegrityHeader is null';
|
||||
}
|
||||
var fetchFunc = realFetch ? realFetch : fetch;
|
||||
if (!GQLDeviceID) {
|
||||
@ -676,11 +679,12 @@ twitch-videoad.js text/javascript
|
||||
body: JSON.stringify(body),
|
||||
headers: {
|
||||
'Client-ID': ClientID,
|
||||
'Client-Integrity': ClientIntegrity,
|
||||
'Client-Integrity': ClientIntegrityHeader,
|
||||
'Device-ID': GQLDeviceID,
|
||||
'X-Device-Id': GQLDeviceID,
|
||||
'Client-Version': ClientVersion,
|
||||
'Client-Session-Id': ClientSession
|
||||
'Client-Session-Id': ClientSession,
|
||||
'Authorization': AuthorizationHeader
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -855,14 +859,18 @@ twitch-videoad.js text/javascript
|
||||
value: ClientID
|
||||
});
|
||||
}
|
||||
}
|
||||
//Client integrity
|
||||
if (url.includes('gql') && init && typeof init.headers['Client-Integrity'] === 'string') {
|
||||
ClientIntegrity = init.headers['Client-Integrity'];
|
||||
//Client integrity header
|
||||
ClientIntegrityHeader = init.headers['Client-Integrity'];
|
||||
twitchMainWorker.postMessage({
|
||||
key: 'UpdateClientIntegrity',
|
||||
key: 'UpdateClientIntegrityHeader',
|
||||
value: init.headers['Client-Integrity']
|
||||
});
|
||||
//Authorization header
|
||||
AuthorizationHeader = init.headers['Authorization'];
|
||||
twitchMainWorker.postMessage({
|
||||
key: 'UpdateAuthorizationHeader',
|
||||
value: init.headers['Authorization']
|
||||
});
|
||||
}
|
||||
//To prevent pause/resume loop for mid-rolls.
|
||||
if (url.includes('gql') && init && typeof init.body === 'string' && init.body.includes('PlaybackAccessToken') && init.body.includes('picture-by-picture')) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
// ==UserScript==
|
||||
// @name TwitchAdSolutions (vaft)
|
||||
// @namespace https://github.com/pixeltris/TwitchAdSolutions
|
||||
// @version 5.8.1
|
||||
// @version 5.8.2
|
||||
// @description Multiple solutions for blocking Twitch ads (vaft)
|
||||
// @updateURL https://github.com/pixeltris/TwitchAdSolutions/raw/master/vaft/vaft.user.js
|
||||
// @downloadURL https://github.com/pixeltris/TwitchAdSolutions/raw/master/vaft/vaft.user.js
|
||||
@ -70,8 +70,8 @@
|
||||
scope.ClientSession = 'null';
|
||||
//scope.PlayerType1 = 'site'; //Source - NOTE: This is unused as it's implicitly used by the website iself
|
||||
scope.PlayerType2 = 'autoplay'; //360p
|
||||
scope.PlayerType3 = 'proxy'; //Source
|
||||
scope.PlayerType4 = 'embed'; //Source
|
||||
scope.PlayerType3 = 'embed'; //Source
|
||||
//scope.PlayerType4 = 'embed'; //Source
|
||||
scope.CurrentChannelName = null;
|
||||
scope.UsherParams = null;
|
||||
scope.WasShowingAd = false;
|
||||
@ -84,7 +84,8 @@
|
||||
scope.DefaultProxyType = null;
|
||||
scope.DefaultForcedQuality = null;
|
||||
scope.DefaultProxyQuality = null;
|
||||
scope.ClientIntegrity = null;
|
||||
scope.ClientIntegrityHeader = null;
|
||||
scope.AuthorizationHeader = null;
|
||||
}
|
||||
declareOptions(window);
|
||||
var TwitchAdblockSettings = {
|
||||
@ -134,8 +135,10 @@
|
||||
ClientID = e.data.value;
|
||||
} else if (e.data.key == 'UpdateDeviceId') {
|
||||
GQLDeviceID = e.data.value;
|
||||
} else if (e.data.key == 'UpdateClientIntegrity') {
|
||||
ClientIntegrity = e.data.value;
|
||||
} else if (e.data.key == 'UpdateClientIntegrityHeader') {
|
||||
ClientIntegrityHeader = e.data.value;
|
||||
} else if (e.data.key == 'UpdateAuthorizationHeader') {
|
||||
AuthorizationHeader = e.data.value;
|
||||
}
|
||||
});
|
||||
hookWorkerFetch();
|
||||
@ -151,7 +154,7 @@
|
||||
if (adBlockDiv == null) {
|
||||
adBlockDiv = getAdBlockDiv();
|
||||
}
|
||||
adBlockDiv.P.textContent = 'Blocking ads...';
|
||||
adBlockDiv.P.textContent = 'Blocking ads';
|
||||
adBlockDiv.style.display = 'block';
|
||||
} else if (e.data.key == 'HideAdBlockBanner') {
|
||||
if (adBlockDiv == null) {
|
||||
@ -292,9 +295,9 @@
|
||||
if (weaverText.includes(AdSignifier)) {
|
||||
weaverText = await processM3U8(url, responseText, realFetch, PlayerType3);
|
||||
}
|
||||
if (weaverText.includes(AdSignifier)) {
|
||||
weaverText = await processM3U8(url, responseText, realFetch, PlayerType4);
|
||||
}
|
||||
//if (weaverText.includes(AdSignifier)) {
|
||||
// weaverText = await processM3U8(url, responseText, realFetch, PlayerType4);
|
||||
//}
|
||||
resolve(new Response(weaverText));
|
||||
};
|
||||
var send = function() {
|
||||
@ -670,9 +673,9 @@
|
||||
return gqlRequest(body, realFetch);
|
||||
}
|
||||
function gqlRequest(body, realFetch) {
|
||||
if (ClientIntegrity == null) {
|
||||
console.error('ClientIntegrity is null');
|
||||
throw 'ClientIntegrity is null';
|
||||
if (ClientIntegrityHeader == null) {
|
||||
console.error('ClientIntegrityHeader is null');
|
||||
throw 'ClientIntegrityHeader is null';
|
||||
}
|
||||
var fetchFunc = realFetch ? realFetch : fetch;
|
||||
if (!GQLDeviceID) {
|
||||
@ -687,11 +690,12 @@
|
||||
body: JSON.stringify(body),
|
||||
headers: {
|
||||
'Client-ID': ClientID,
|
||||
'Client-Integrity': ClientIntegrity,
|
||||
'Client-Integrity': ClientIntegrityHeader,
|
||||
'Device-ID': GQLDeviceID,
|
||||
'X-Device-Id': GQLDeviceID,
|
||||
'Client-Version': ClientVersion,
|
||||
'Client-Session-Id': ClientSession
|
||||
'Client-Session-Id': ClientSession,
|
||||
'Authorization': AuthorizationHeader
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -866,14 +870,18 @@
|
||||
value: ClientID
|
||||
});
|
||||
}
|
||||
}
|
||||
//Client integrity
|
||||
if (url.includes('gql') && init && typeof init.headers['Client-Integrity'] === 'string') {
|
||||
ClientIntegrity = init.headers['Client-Integrity'];
|
||||
//Client integrity header
|
||||
ClientIntegrityHeader = init.headers['Client-Integrity'];
|
||||
twitchMainWorker.postMessage({
|
||||
key: 'UpdateClientIntegrity',
|
||||
key: 'UpdateClientIntegrityHeader',
|
||||
value: init.headers['Client-Integrity']
|
||||
});
|
||||
//Authorization header
|
||||
AuthorizationHeader = init.headers['Authorization'];
|
||||
twitchMainWorker.postMessage({
|
||||
key: 'UpdateAuthorizationHeader',
|
||||
value: init.headers['Authorization']
|
||||
});
|
||||
}
|
||||
//To prevent pause/resume loop for mid-rolls.
|
||||
if (url.includes('gql') && init && typeof init.body === 'string' && init.body.includes('PlaybackAccessToken') && init.body.includes('picture-by-picture')) {
|
||||
|
@ -30,7 +30,8 @@ twitch-videoad.js text/javascript
|
||||
scope.gql_device_id_rolling += charTable[(bs.charCodeAt(i) ^ di) % charTable.length];
|
||||
}
|
||||
scope.gql_device_id_rolling = '1';//temporary
|
||||
scope.ClientIntegrity = null;
|
||||
scope.ClientIntegrityHeader = null;
|
||||
scope.AuthorizationHeader = null;
|
||||
}
|
||||
declareOptions(window);
|
||||
var twitchMainWorker = null;
|
||||
@ -60,8 +61,10 @@ twitch-videoad.js text/javascript
|
||||
self.addEventListener('message', function(e) {
|
||||
if (e.data.key == 'UboUpdateDeviceId') {
|
||||
gql_device_id = e.data.value;
|
||||
} else if (e.data.key == 'UpdateClientIntegrity') {
|
||||
ClientIntegrity = e.data.value;
|
||||
} else if (e.data.key == 'UpdateClientIntegrityHeader') {
|
||||
ClientIntegrityHeader = e.data.value;
|
||||
} else if (e.data.key == 'UpdateAuthorizationHeader') {
|
||||
AuthorizationHeader = e.data.value;
|
||||
}
|
||||
});
|
||||
hookWorkerFetch();
|
||||
@ -74,7 +77,7 @@ twitch-videoad.js text/javascript
|
||||
if (e.data.key == 'UboShowAdBanner') {
|
||||
var adDiv = getAdDiv();
|
||||
if (adDiv != null) {
|
||||
adDiv.P.textContent = 'Blocking' + (e.data.isMidroll ? ' midroll' : '') + ' ads...';
|
||||
adDiv.P.textContent = 'Blocking' + (e.data.isMidroll ? ' midroll' : '') + ' ads';
|
||||
if (OPT_SHOW_AD_BANNER) {
|
||||
adDiv.style.display = 'block';
|
||||
}
|
||||
@ -310,9 +313,9 @@ twitch-videoad.js text/javascript
|
||||
return gqlRequest(body, realFetch);
|
||||
}
|
||||
function gqlRequest(body, realFetch) {
|
||||
if (ClientIntegrity == null) {
|
||||
console.error('ClientIntegrity is null');
|
||||
throw 'ClientIntegrity is null';
|
||||
if (ClientIntegrityHeader == null) {
|
||||
console.error('ClientIntegrityHeader is null');
|
||||
throw 'ClientIntegrityHeader is null';
|
||||
}
|
||||
var fetchFunc = realFetch ? realFetch : fetch;
|
||||
return fetchFunc('https://gql.twitch.tv/gql', {
|
||||
@ -320,8 +323,9 @@ twitch-videoad.js text/javascript
|
||||
body: JSON.stringify(body),
|
||||
headers: {
|
||||
'Client-Id': CLIENT_ID,
|
||||
'Client-Integrity': ClientIntegrity,
|
||||
'X-Device-Id': OPT_ROLLING_DEVICE_ID ? gql_device_id_rolling : gql_device_id
|
||||
'Client-Integrity': ClientIntegrityHeader,
|
||||
'X-Device-Id': OPT_ROLLING_DEVICE_ID ? gql_device_id_rolling : gql_device_id,
|
||||
'Authorization': AuthorizationHeader
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -435,12 +439,19 @@ twitch-videoad.js text/javascript
|
||||
}
|
||||
}
|
||||
if (typeof init.headers['Client-Integrity'] === 'string') {
|
||||
ClientIntegrity = init.headers['Client-Integrity'];
|
||||
ClientIntegrityHeader = init.headers['Client-Integrity'];
|
||||
twitchMainWorker.postMessage({
|
||||
key: 'UpdateClientIntegrity',
|
||||
key: 'UpdateClientIntegrityHeader',
|
||||
value: init.headers['Client-Integrity']
|
||||
});
|
||||
}
|
||||
if (typeof init.headers['Authorization'] === 'string') {
|
||||
AuthorizationHeader = init.headers['Authorization'];
|
||||
twitchMainWorker.postMessage({
|
||||
key: 'UpdateAuthorizationHeader',
|
||||
value: init.headers['Authorization']
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
// ==UserScript==
|
||||
// @name TwitchAdSolutions (video-swap-new)
|
||||
// @namespace https://github.com/pixeltris/TwitchAdSolutions
|
||||
// @version 1.18
|
||||
// @version 1.19
|
||||
// @updateURL https://github.com/pixeltris/TwitchAdSolutions/raw/master/video-swap-new/video-swap-new.user.js
|
||||
// @downloadURL https://github.com/pixeltris/TwitchAdSolutions/raw/master/video-swap-new/video-swap-new.user.js
|
||||
// @description Multiple solutions for blocking Twitch ads (video-swap-new)
|
||||
@ -41,7 +41,8 @@
|
||||
scope.gql_device_id_rolling += charTable[(bs.charCodeAt(i) ^ di) % charTable.length];
|
||||
}
|
||||
scope.gql_device_id_rolling = '1';//temporary
|
||||
scope.ClientIntegrity = null;
|
||||
scope.ClientIntegrityHeader = null;
|
||||
scope.AuthorizationHeader = null;
|
||||
}
|
||||
declareOptions(window);
|
||||
var twitchMainWorker = null;
|
||||
@ -71,8 +72,10 @@
|
||||
self.addEventListener('message', function(e) {
|
||||
if (e.data.key == 'UboUpdateDeviceId') {
|
||||
gql_device_id = e.data.value;
|
||||
} else if (e.data.key == 'UpdateClientIntegrity') {
|
||||
ClientIntegrity = e.data.value;
|
||||
} else if (e.data.key == 'UpdateClientIntegrityHeader') {
|
||||
ClientIntegrityHeader = e.data.value;
|
||||
} else if (e.data.key == 'UpdateAuthorizationHeader') {
|
||||
AuthorizationHeader = e.data.value;
|
||||
}
|
||||
});
|
||||
hookWorkerFetch();
|
||||
@ -85,7 +88,7 @@
|
||||
if (e.data.key == 'UboShowAdBanner') {
|
||||
var adDiv = getAdDiv();
|
||||
if (adDiv != null) {
|
||||
adDiv.P.textContent = 'Blocking' + (e.data.isMidroll ? ' midroll' : '') + ' ads...';
|
||||
adDiv.P.textContent = 'Blocking' + (e.data.isMidroll ? ' midroll' : '') + ' ads';
|
||||
if (OPT_SHOW_AD_BANNER) {
|
||||
adDiv.style.display = 'block';
|
||||
}
|
||||
@ -321,9 +324,9 @@
|
||||
return gqlRequest(body, realFetch);
|
||||
}
|
||||
function gqlRequest(body, realFetch) {
|
||||
if (ClientIntegrity == null) {
|
||||
console.error('ClientIntegrity is null');
|
||||
throw 'ClientIntegrity is null';
|
||||
if (ClientIntegrityHeader == null) {
|
||||
console.error('ClientIntegrityHeader is null');
|
||||
throw 'ClientIntegrityHeader is null';
|
||||
}
|
||||
var fetchFunc = realFetch ? realFetch : fetch;
|
||||
return fetchFunc('https://gql.twitch.tv/gql', {
|
||||
@ -331,8 +334,9 @@
|
||||
body: JSON.stringify(body),
|
||||
headers: {
|
||||
'Client-Id': CLIENT_ID,
|
||||
'Client-Integrity': ClientIntegrity,
|
||||
'X-Device-Id': OPT_ROLLING_DEVICE_ID ? gql_device_id_rolling : gql_device_id
|
||||
'Client-Integrity': ClientIntegrityHeader,
|
||||
'X-Device-Id': OPT_ROLLING_DEVICE_ID ? gql_device_id_rolling : gql_device_id,
|
||||
'Authorization': AuthorizationHeader
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -446,12 +450,19 @@
|
||||
}
|
||||
}
|
||||
if (typeof init.headers['Client-Integrity'] === 'string') {
|
||||
ClientIntegrity = init.headers['Client-Integrity'];
|
||||
ClientIntegrityHeader = init.headers['Client-Integrity'];
|
||||
twitchMainWorker.postMessage({
|
||||
key: 'UpdateClientIntegrity',
|
||||
key: 'UpdateClientIntegrityHeader',
|
||||
value: init.headers['Client-Integrity']
|
||||
});
|
||||
}
|
||||
if (typeof init.headers['Authorization'] === 'string') {
|
||||
AuthorizationHeader = init.headers['Authorization'];
|
||||
twitchMainWorker.postMessage({
|
||||
key: 'UpdateAuthorizationHeader',
|
||||
value: init.headers['Authorization']
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user