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

Fix FrankerFaceZ loading issue #249

This commit is contained in:
pixeltris 2024-06-16 06:53:51 +01:00
parent c66faba74f
commit 2eefb984c1
4 changed files with 84 additions and 124 deletions

View File

@ -71,11 +71,6 @@ twitch-videoad.js text/javascript
const oldWorker = window.Worker; const oldWorker = window.Worker;
window.Worker = class Worker extends oldWorker { window.Worker = class Worker extends oldWorker {
constructor(twitchBlobUrl) { constructor(twitchBlobUrl) {
var jsURL = getWasmWorkerUrl(twitchBlobUrl);
if (typeof jsURL !== 'string') {
super(twitchBlobUrl);
return;
}
var newBlobStr = ` var newBlobStr = `
${getStreamUrlForResolution.toString()} ${getStreamUrlForResolution.toString()}
${getStreamForResolution.toString()} ${getStreamForResolution.toString()}
@ -88,26 +83,30 @@ twitch-videoad.js text/javascript
${adRecordgqlPacket.toString()} ${adRecordgqlPacket.toString()}
${tryNotifyTwitch.toString()} ${tryNotifyTwitch.toString()}
${parseAttributes.toString()} ${parseAttributes.toString()}
declareOptions(self); ${getWasmWorkerUrl.toString()}
self.addEventListener('message', function(e) { var workerUrl = getWasmWorkerUrl('${twitchBlobUrl}');
if (e.data.key == 'UpdateIsSquadStream') { if (workerUrl && workerUrl.includes('assets.twitch.tv/assets/amazon-ivs-wasmworker')) {
IsSquadStream = e.data.value; declareOptions(self);
} else if (e.data.key == 'UpdateClientVersion') { self.addEventListener('message', function(e) {
ClientVersion = e.data.value; if (e.data.key == 'UpdateIsSquadStream') {
} else if (e.data.key == 'UpdateClientSession') { IsSquadStream = e.data.value;
ClientSession = e.data.value; } else if (e.data.key == 'UpdateClientVersion') {
} else if (e.data.key == 'UpdateClientId') { ClientVersion = e.data.value;
ClientID = e.data.value; } else if (e.data.key == 'UpdateClientSession') {
} else if (e.data.key == 'UpdateDeviceId') { ClientSession = e.data.value;
GQLDeviceID = e.data.value; } else if (e.data.key == 'UpdateClientId') {
} else if (e.data.key == 'UpdateClientIntegrityHeader') { ClientID = e.data.value;
ClientIntegrityHeader = e.data.value; } else if (e.data.key == 'UpdateDeviceId') {
} else if (e.data.key == 'UpdateAuthorizationHeader') { GQLDeviceID = e.data.value;
AuthorizationHeader = e.data.value; } else if (e.data.key == 'UpdateClientIntegrityHeader') {
} ClientIntegrityHeader = e.data.value;
}); } else if (e.data.key == 'UpdateAuthorizationHeader') {
hookWorkerFetch(); AuthorizationHeader = e.data.value;
importScripts('${jsURL}'); }
});
hookWorkerFetch();
importScripts(workerUrl);
}
`; `;
super(URL.createObjectURL(new Blob([newBlobStr]))); super(URL.createObjectURL(new Blob([newBlobStr])));
twitchWorkers.push(this); twitchWorkers.push(this);

View File

@ -1,7 +1,7 @@
// ==UserScript== // ==UserScript==
// @name TwitchAdSolutions (vaft) // @name TwitchAdSolutions (vaft)
// @namespace https://github.com/pixeltris/TwitchAdSolutions // @namespace https://github.com/pixeltris/TwitchAdSolutions
// @version 8.0.0 // @version 9.0.0
// @description Multiple solutions for blocking Twitch ads (vaft) // @description Multiple solutions for blocking Twitch ads (vaft)
// @updateURL https://github.com/pixeltris/TwitchAdSolutions/raw/master/vaft/vaft.user.js // @updateURL https://github.com/pixeltris/TwitchAdSolutions/raw/master/vaft/vaft.user.js
// @downloadURL https://github.com/pixeltris/TwitchAdSolutions/raw/master/vaft/vaft.user.js // @downloadURL https://github.com/pixeltris/TwitchAdSolutions/raw/master/vaft/vaft.user.js
@ -83,11 +83,6 @@
const oldWorker = window.Worker; const oldWorker = window.Worker;
window.Worker = class Worker extends oldWorker { window.Worker = class Worker extends oldWorker {
constructor(twitchBlobUrl) { constructor(twitchBlobUrl) {
var jsURL = getWasmWorkerUrl(twitchBlobUrl);
if (typeof jsURL !== 'string') {
super(twitchBlobUrl);
return;
}
var newBlobStr = ` var newBlobStr = `
${getStreamUrlForResolution.toString()} ${getStreamUrlForResolution.toString()}
${getStreamForResolution.toString()} ${getStreamForResolution.toString()}
@ -100,26 +95,30 @@
${adRecordgqlPacket.toString()} ${adRecordgqlPacket.toString()}
${tryNotifyTwitch.toString()} ${tryNotifyTwitch.toString()}
${parseAttributes.toString()} ${parseAttributes.toString()}
declareOptions(self); ${getWasmWorkerUrl.toString()}
self.addEventListener('message', function(e) { var workerUrl = getWasmWorkerUrl('${twitchBlobUrl}');
if (e.data.key == 'UpdateIsSquadStream') { if (workerUrl && workerUrl.includes('assets.twitch.tv/assets/amazon-ivs-wasmworker')) {
IsSquadStream = e.data.value; declareOptions(self);
} else if (e.data.key == 'UpdateClientVersion') { self.addEventListener('message', function(e) {
ClientVersion = e.data.value; if (e.data.key == 'UpdateIsSquadStream') {
} else if (e.data.key == 'UpdateClientSession') { IsSquadStream = e.data.value;
ClientSession = e.data.value; } else if (e.data.key == 'UpdateClientVersion') {
} else if (e.data.key == 'UpdateClientId') { ClientVersion = e.data.value;
ClientID = e.data.value; } else if (e.data.key == 'UpdateClientSession') {
} else if (e.data.key == 'UpdateDeviceId') { ClientSession = e.data.value;
GQLDeviceID = e.data.value; } else if (e.data.key == 'UpdateClientId') {
} else if (e.data.key == 'UpdateClientIntegrityHeader') { ClientID = e.data.value;
ClientIntegrityHeader = e.data.value; } else if (e.data.key == 'UpdateDeviceId') {
} else if (e.data.key == 'UpdateAuthorizationHeader') { GQLDeviceID = e.data.value;
AuthorizationHeader = e.data.value; } else if (e.data.key == 'UpdateClientIntegrityHeader') {
} ClientIntegrityHeader = e.data.value;
}); } else if (e.data.key == 'UpdateAuthorizationHeader') {
hookWorkerFetch(); AuthorizationHeader = e.data.value;
importScripts('${jsURL}'); }
});
hookWorkerFetch();
importScripts(workerUrl);
}
`; `;
super(URL.createObjectURL(new Blob([newBlobStr]))); super(URL.createObjectURL(new Blob([newBlobStr])));
twitchWorkers.push(this); twitchWorkers.push(this);

View File

@ -3,7 +3,6 @@ twitch-videoad.js text/javascript
if ( /(^|\.)twitch\.tv$/.test(document.location.hostname) === false ) { return; } if ( /(^|\.)twitch\.tv$/.test(document.location.hostname) === false ) { return; }
function declareOptions(scope) { function declareOptions(scope) {
// Options / globals // Options / globals
scope.OPT_ROLLING_DEVICE_ID = false;
scope.OPT_MODE_STRIP_AD_SEGMENTS = true; scope.OPT_MODE_STRIP_AD_SEGMENTS = true;
scope.OPT_MODE_NOTIFY_ADS_WATCHED = true; scope.OPT_MODE_NOTIFY_ADS_WATCHED = true;
scope.OPT_MODE_NOTIFY_ADS_WATCHED_MIN_REQUESTS = false; scope.OPT_MODE_NOTIFY_ADS_WATCHED_MIN_REQUESTS = false;
@ -21,15 +20,6 @@ twitch-videoad.js text/javascript
scope.CurrentChannelNameFromM3U8 = null; scope.CurrentChannelNameFromM3U8 = null;
// Need this in both scopes. Window scope needs to update this to worker scope. // Need this in both scopes. Window scope needs to update this to worker scope.
scope.gql_device_id = null; scope.gql_device_id = null;
scope.gql_device_id_rolling = '';
// Rolling device id crap... TODO: improve this
var charTable = []; for (var i = 97; i <= 122; i++) { charTable.push(String.fromCharCode(i)); } for (var i = 65; i <= 90; i++) { charTable.push(String.fromCharCode(i)); } for (var i = 48; i <= 57; i++) { charTable.push(String.fromCharCode(i)); }
var bs = 'eVI6jx47kJvCFfFowK86eVI6jx47kJvC';
var di = (new Date()).getUTCFullYear() + (new Date()).getUTCMonth() + ((new Date()).getUTCDate() / 7) | 0;
for (var i = 0; i < bs.length; i++) {
scope.gql_device_id_rolling += charTable[(bs.charCodeAt(i) ^ di) % charTable.length];
}
scope.gql_device_id_rolling = '1';//temporary
scope.ClientIntegrityHeader = null; scope.ClientIntegrityHeader = null;
scope.AuthorizationHeader = null; scope.AuthorizationHeader = null;
} }
@ -38,11 +28,6 @@ twitch-videoad.js text/javascript
const oldWorker = window.Worker; const oldWorker = window.Worker;
window.Worker = class Worker extends oldWorker { window.Worker = class Worker extends oldWorker {
constructor(twitchBlobUrl) { constructor(twitchBlobUrl) {
var jsURL = getWasmWorkerUrl(twitchBlobUrl);
if (typeof jsURL !== 'string') {
super(twitchBlobUrl);
return;
}
var newBlobStr = ` var newBlobStr = `
${processM3U8.toString()} ${processM3U8.toString()}
${hookWorkerFetch.toString()} ${hookWorkerFetch.toString()}
@ -53,18 +38,22 @@ twitch-videoad.js text/javascript
${tryNotifyAdsWatchedM3U8.toString()} ${tryNotifyAdsWatchedM3U8.toString()}
${parseAttributes.toString()} ${parseAttributes.toString()}
${onFoundAd.toString()} ${onFoundAd.toString()}
declareOptions(self); ${getWasmWorkerUrl.toString()}
self.addEventListener('message', function(e) { var workerUrl = getWasmWorkerUrl('${twitchBlobUrl}');
if (e.data.key == 'UboUpdateDeviceId') { if (workerUrl && workerUrl.includes('assets.twitch.tv/assets/amazon-ivs-wasmworker')) {
gql_device_id = e.data.value; declareOptions(self);
} else if (e.data.key == 'UpdateClientIntegrityHeader') { self.addEventListener('message', function(e) {
ClientIntegrityHeader = e.data.value; if (e.data.key == 'UboUpdateDeviceId') {
} else if (e.data.key == 'UpdateAuthorizationHeader') { gql_device_id = e.data.value;
AuthorizationHeader = e.data.value; } else if (e.data.key == 'UpdateClientIntegrityHeader') {
} ClientIntegrityHeader = e.data.value;
}); } else if (e.data.key == 'UpdateAuthorizationHeader') {
hookWorkerFetch(); AuthorizationHeader = e.data.value;
importScripts('${jsURL}'); }
});
hookWorkerFetch();
importScripts(workerUrl);
}
` `
super(URL.createObjectURL(new Blob([newBlobStr]))); super(URL.createObjectURL(new Blob([newBlobStr])));
twitchWorkers.push(this); twitchWorkers.push(this);
@ -373,7 +362,7 @@ twitch-videoad.js text/javascript
headers: { headers: {
'Client-Id': CLIENT_ID, 'Client-Id': CLIENT_ID,
'Client-Integrity': ClientIntegrityHeader, 'Client-Integrity': ClientIntegrityHeader,
'X-Device-Id': OPT_ROLLING_DEVICE_ID ? gql_device_id_rolling : gql_device_id, 'X-Device-Id': gql_device_id,
'Authorization': AuthorizationHeader 'Authorization': AuthorizationHeader
} }
}); });
@ -481,14 +470,6 @@ twitch-videoad.js text/javascript
} }
init.body = JSON.stringify(newBody); init.body = JSON.stringify(newBody);
} }
if (OPT_ROLLING_DEVICE_ID) {
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;
}
}
if (typeof init.headers['Client-Integrity'] === 'string') { if (typeof init.headers['Client-Integrity'] === 'string') {
ClientIntegrityHeader = init.headers['Client-Integrity']; ClientIntegrityHeader = init.headers['Client-Integrity'];
if (ClientIntegrityHeader) { if (ClientIntegrityHeader) {

View File

@ -1,7 +1,7 @@
// ==UserScript== // ==UserScript==
// @name TwitchAdSolutions (video-swap-new) // @name TwitchAdSolutions (video-swap-new)
// @namespace https://github.com/pixeltris/TwitchAdSolutions // @namespace https://github.com/pixeltris/TwitchAdSolutions
// @version 1.26 // @version 1.27
// @updateURL https://github.com/pixeltris/TwitchAdSolutions/raw/master/video-swap-new/video-swap-new.user.js // @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 // @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) // @description Multiple solutions for blocking Twitch ads (video-swap-new)
@ -15,7 +15,6 @@
'use strict'; 'use strict';
function declareOptions(scope) { function declareOptions(scope) {
// Options / globals // Options / globals
scope.OPT_ROLLING_DEVICE_ID = false;
scope.OPT_MODE_STRIP_AD_SEGMENTS = true; scope.OPT_MODE_STRIP_AD_SEGMENTS = true;
scope.OPT_MODE_NOTIFY_ADS_WATCHED = true; scope.OPT_MODE_NOTIFY_ADS_WATCHED = true;
scope.OPT_MODE_NOTIFY_ADS_WATCHED_MIN_REQUESTS = false; scope.OPT_MODE_NOTIFY_ADS_WATCHED_MIN_REQUESTS = false;
@ -33,15 +32,6 @@
scope.CurrentChannelNameFromM3U8 = null; scope.CurrentChannelNameFromM3U8 = null;
// Need this in both scopes. Window scope needs to update this to worker scope. // Need this in both scopes. Window scope needs to update this to worker scope.
scope.gql_device_id = null; scope.gql_device_id = null;
scope.gql_device_id_rolling = '';
// Rolling device id crap... TODO: improve this
var charTable = []; for (var i = 97; i <= 122; i++) { charTable.push(String.fromCharCode(i)); } for (var i = 65; i <= 90; i++) { charTable.push(String.fromCharCode(i)); } for (var i = 48; i <= 57; i++) { charTable.push(String.fromCharCode(i)); }
var bs = 'eVI6jx47kJvCFfFowK86eVI6jx47kJvC';
var di = (new Date()).getUTCFullYear() + (new Date()).getUTCMonth() + ((new Date()).getUTCDate() / 7) | 0;
for (var i = 0; i < bs.length; i++) {
scope.gql_device_id_rolling += charTable[(bs.charCodeAt(i) ^ di) % charTable.length];
}
scope.gql_device_id_rolling = '1';//temporary
scope.ClientIntegrityHeader = null; scope.ClientIntegrityHeader = null;
scope.AuthorizationHeader = null; scope.AuthorizationHeader = null;
} }
@ -50,11 +40,6 @@
const oldWorker = window.Worker; const oldWorker = window.Worker;
window.Worker = class Worker extends oldWorker { window.Worker = class Worker extends oldWorker {
constructor(twitchBlobUrl) { constructor(twitchBlobUrl) {
var jsURL = getWasmWorkerUrl(twitchBlobUrl);
if (typeof jsURL !== 'string') {
super(twitchBlobUrl);
return;
}
var newBlobStr = ` var newBlobStr = `
${processM3U8.toString()} ${processM3U8.toString()}
${hookWorkerFetch.toString()} ${hookWorkerFetch.toString()}
@ -65,18 +50,22 @@
${tryNotifyAdsWatchedM3U8.toString()} ${tryNotifyAdsWatchedM3U8.toString()}
${parseAttributes.toString()} ${parseAttributes.toString()}
${onFoundAd.toString()} ${onFoundAd.toString()}
declareOptions(self); ${getWasmWorkerUrl.toString()}
self.addEventListener('message', function(e) { var workerUrl = getWasmWorkerUrl('${twitchBlobUrl}');
if (e.data.key == 'UboUpdateDeviceId') { if (workerUrl && workerUrl.includes('assets.twitch.tv/assets/amazon-ivs-wasmworker')) {
gql_device_id = e.data.value; declareOptions(self);
} else if (e.data.key == 'UpdateClientIntegrityHeader') { self.addEventListener('message', function(e) {
ClientIntegrityHeader = e.data.value; if (e.data.key == 'UboUpdateDeviceId') {
} else if (e.data.key == 'UpdateAuthorizationHeader') { gql_device_id = e.data.value;
AuthorizationHeader = e.data.value; } else if (e.data.key == 'UpdateClientIntegrityHeader') {
} ClientIntegrityHeader = e.data.value;
}); } else if (e.data.key == 'UpdateAuthorizationHeader') {
hookWorkerFetch(); AuthorizationHeader = e.data.value;
importScripts('${jsURL}'); }
});
hookWorkerFetch();
importScripts(workerUrl);
}
` `
super(URL.createObjectURL(new Blob([newBlobStr]))); super(URL.createObjectURL(new Blob([newBlobStr])));
twitchWorkers.push(this); twitchWorkers.push(this);
@ -385,7 +374,7 @@
headers: { headers: {
'Client-Id': CLIENT_ID, 'Client-Id': CLIENT_ID,
'Client-Integrity': ClientIntegrityHeader, 'Client-Integrity': ClientIntegrityHeader,
'X-Device-Id': OPT_ROLLING_DEVICE_ID ? gql_device_id_rolling : gql_device_id, 'X-Device-Id': gql_device_id,
'Authorization': AuthorizationHeader 'Authorization': AuthorizationHeader
} }
}); });
@ -493,14 +482,6 @@
} }
init.body = JSON.stringify(newBody); init.body = JSON.stringify(newBody);
} }
if (OPT_ROLLING_DEVICE_ID) {
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;
}
}
if (typeof init.headers['Client-Integrity'] === 'string') { if (typeof init.headers['Client-Integrity'] === 'string') {
ClientIntegrityHeader = init.headers['Client-Integrity']; ClientIntegrityHeader = init.headers['Client-Integrity'];
if (ClientIntegrityHeader) { if (ClientIntegrityHeader) {