Fix ad blocking for logged in users (video-swap-new / vaft)
This commit is contained in:
+28
-20
@@ -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')) {
|
||||
|
||||
Reference in New Issue
Block a user