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