1
0
mirror of https://github.com/pixeltris/TwitchAdSolutions.git synced 2024-11-25 11:52:52 +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;
window.Worker = class Worker extends oldWorker {
constructor(twitchBlobUrl) {
var jsURL = getWasmWorkerUrl(twitchBlobUrl);
if (typeof jsURL !== 'string') {
super(twitchBlobUrl);
return;
}
var newBlobStr = `
${getStreamUrlForResolution.toString()}
${getStreamForResolution.toString()}
@ -88,6 +83,9 @@ twitch-videoad.js text/javascript
${adRecordgqlPacket.toString()}
${tryNotifyTwitch.toString()}
${parseAttributes.toString()}
${getWasmWorkerUrl.toString()}
var workerUrl = getWasmWorkerUrl('${twitchBlobUrl}');
if (workerUrl && workerUrl.includes('assets.twitch.tv/assets/amazon-ivs-wasmworker')) {
declareOptions(self);
self.addEventListener('message', function(e) {
if (e.data.key == 'UpdateIsSquadStream') {
@ -107,7 +105,8 @@ twitch-videoad.js text/javascript
}
});
hookWorkerFetch();
importScripts('${jsURL}');
importScripts(workerUrl);
}
`;
super(URL.createObjectURL(new Blob([newBlobStr])));
twitchWorkers.push(this);

View File

@ -1,7 +1,7 @@
// ==UserScript==
// @name TwitchAdSolutions (vaft)
// @namespace https://github.com/pixeltris/TwitchAdSolutions
// @version 8.0.0
// @version 9.0.0
// @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
@ -83,11 +83,6 @@
const oldWorker = window.Worker;
window.Worker = class Worker extends oldWorker {
constructor(twitchBlobUrl) {
var jsURL = getWasmWorkerUrl(twitchBlobUrl);
if (typeof jsURL !== 'string') {
super(twitchBlobUrl);
return;
}
var newBlobStr = `
${getStreamUrlForResolution.toString()}
${getStreamForResolution.toString()}
@ -100,6 +95,9 @@
${adRecordgqlPacket.toString()}
${tryNotifyTwitch.toString()}
${parseAttributes.toString()}
${getWasmWorkerUrl.toString()}
var workerUrl = getWasmWorkerUrl('${twitchBlobUrl}');
if (workerUrl && workerUrl.includes('assets.twitch.tv/assets/amazon-ivs-wasmworker')) {
declareOptions(self);
self.addEventListener('message', function(e) {
if (e.data.key == 'UpdateIsSquadStream') {
@ -119,7 +117,8 @@
}
});
hookWorkerFetch();
importScripts('${jsURL}');
importScripts(workerUrl);
}
`;
super(URL.createObjectURL(new Blob([newBlobStr])));
twitchWorkers.push(this);

View File

@ -3,7 +3,6 @@ twitch-videoad.js text/javascript
if ( /(^|\.)twitch\.tv$/.test(document.location.hostname) === false ) { return; }
function declareOptions(scope) {
// Options / globals
scope.OPT_ROLLING_DEVICE_ID = false;
scope.OPT_MODE_STRIP_AD_SEGMENTS = true;
scope.OPT_MODE_NOTIFY_ADS_WATCHED = true;
scope.OPT_MODE_NOTIFY_ADS_WATCHED_MIN_REQUESTS = false;
@ -21,15 +20,6 @@ twitch-videoad.js text/javascript
scope.CurrentChannelNameFromM3U8 = null;
// Need this in both scopes. Window scope needs to update this to worker scope.
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.AuthorizationHeader = null;
}
@ -38,11 +28,6 @@ twitch-videoad.js text/javascript
const oldWorker = window.Worker;
window.Worker = class Worker extends oldWorker {
constructor(twitchBlobUrl) {
var jsURL = getWasmWorkerUrl(twitchBlobUrl);
if (typeof jsURL !== 'string') {
super(twitchBlobUrl);
return;
}
var newBlobStr = `
${processM3U8.toString()}
${hookWorkerFetch.toString()}
@ -53,6 +38,9 @@ twitch-videoad.js text/javascript
${tryNotifyAdsWatchedM3U8.toString()}
${parseAttributes.toString()}
${onFoundAd.toString()}
${getWasmWorkerUrl.toString()}
var workerUrl = getWasmWorkerUrl('${twitchBlobUrl}');
if (workerUrl && workerUrl.includes('assets.twitch.tv/assets/amazon-ivs-wasmworker')) {
declareOptions(self);
self.addEventListener('message', function(e) {
if (e.data.key == 'UboUpdateDeviceId') {
@ -64,7 +52,8 @@ twitch-videoad.js text/javascript
}
});
hookWorkerFetch();
importScripts('${jsURL}');
importScripts(workerUrl);
}
`
super(URL.createObjectURL(new Blob([newBlobStr])));
twitchWorkers.push(this);
@ -373,7 +362,7 @@ twitch-videoad.js text/javascript
headers: {
'Client-Id': CLIENT_ID,
'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
}
});
@ -481,14 +470,6 @@ twitch-videoad.js text/javascript
}
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') {
ClientIntegrityHeader = init.headers['Client-Integrity'];
if (ClientIntegrityHeader) {

View File

@ -1,7 +1,7 @@
// ==UserScript==
// @name TwitchAdSolutions (video-swap-new)
// @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
// @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)
@ -15,7 +15,6 @@
'use strict';
function declareOptions(scope) {
// Options / globals
scope.OPT_ROLLING_DEVICE_ID = false;
scope.OPT_MODE_STRIP_AD_SEGMENTS = true;
scope.OPT_MODE_NOTIFY_ADS_WATCHED = true;
scope.OPT_MODE_NOTIFY_ADS_WATCHED_MIN_REQUESTS = false;
@ -33,15 +32,6 @@
scope.CurrentChannelNameFromM3U8 = null;
// Need this in both scopes. Window scope needs to update this to worker scope.
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.AuthorizationHeader = null;
}
@ -50,11 +40,6 @@
const oldWorker = window.Worker;
window.Worker = class Worker extends oldWorker {
constructor(twitchBlobUrl) {
var jsURL = getWasmWorkerUrl(twitchBlobUrl);
if (typeof jsURL !== 'string') {
super(twitchBlobUrl);
return;
}
var newBlobStr = `
${processM3U8.toString()}
${hookWorkerFetch.toString()}
@ -65,6 +50,9 @@
${tryNotifyAdsWatchedM3U8.toString()}
${parseAttributes.toString()}
${onFoundAd.toString()}
${getWasmWorkerUrl.toString()}
var workerUrl = getWasmWorkerUrl('${twitchBlobUrl}');
if (workerUrl && workerUrl.includes('assets.twitch.tv/assets/amazon-ivs-wasmworker')) {
declareOptions(self);
self.addEventListener('message', function(e) {
if (e.data.key == 'UboUpdateDeviceId') {
@ -76,7 +64,8 @@
}
});
hookWorkerFetch();
importScripts('${jsURL}');
importScripts(workerUrl);
}
`
super(URL.createObjectURL(new Blob([newBlobStr])));
twitchWorkers.push(this);
@ -385,7 +374,7 @@
headers: {
'Client-Id': CLIENT_ID,
'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
}
});
@ -493,14 +482,6 @@
}
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') {
ClientIntegrityHeader = init.headers['Client-Integrity'];
if (ClientIntegrityHeader) {