Config tweaks
This commit is contained in:
@@ -2,7 +2,7 @@ twitch-videoad.js text/javascript
|
|||||||
(function() {
|
(function() {
|
||||||
if ( /(^|\.)twitch\.tv$/.test(document.location.hostname) === false ) { return; }
|
if ( /(^|\.)twitch\.tv$/.test(document.location.hostname) === false ) { return; }
|
||||||
'use strict';
|
'use strict';
|
||||||
const ourTwitchAdSolutionsVersion = 19;// Used to prevent conflicts with outdated versions of the scripts
|
const ourTwitchAdSolutionsVersion = 20;// Used to prevent conflicts with outdated versions of the scripts
|
||||||
if (typeof window.twitchAdSolutionsVersion !== 'undefined' && window.twitchAdSolutionsVersion >= ourTwitchAdSolutionsVersion) {
|
if (typeof window.twitchAdSolutionsVersion !== 'undefined' && window.twitchAdSolutionsVersion >= ourTwitchAdSolutionsVersion) {
|
||||||
console.log("skipping vaft as there's another script active. ourVersion:" + ourTwitchAdSolutionsVersion + " activeVersion:" + window.twitchAdSolutionsVersion);
|
console.log("skipping vaft as there's another script active. ourVersion:" + ourTwitchAdSolutionsVersion + " activeVersion:" + window.twitchAdSolutionsVersion);
|
||||||
window.twitchAdSolutionsVersion = ourTwitchAdSolutionsVersion;
|
window.twitchAdSolutionsVersion = ourTwitchAdSolutionsVersion;
|
||||||
@@ -14,17 +14,17 @@ twitch-videoad.js text/javascript
|
|||||||
scope.ClientID = 'kimne78kx3ncx6brgo4mv6wki5h1ko';
|
scope.ClientID = 'kimne78kx3ncx6brgo4mv6wki5h1ko';
|
||||||
scope.BackupPlayerTypes = [
|
scope.BackupPlayerTypes = [
|
||||||
'embed',//Source
|
'embed',//Source
|
||||||
'site',//Source
|
'popout',//Source
|
||||||
'autoplay',//360p
|
'autoplay',//360p
|
||||||
'picture-by-picture-CACHED'//360p (-CACHED is an internal suffix and is removed)
|
//'picture-by-picture-CACHED'//360p (-CACHED is an internal suffix and is removed)
|
||||||
];
|
];
|
||||||
scope.FallbackPlayerType = 'embed';
|
scope.FallbackPlayerType = 'embed';
|
||||||
scope.ForceAccessTokenPlayerType = 'site';// Replaces 'embed' player type with 'site' (to reduce prerolls when on embeded websites)
|
scope.ForceAccessTokenPlayerType = 'popout';
|
||||||
scope.SkipPlayerReloadOnHevc = false;// If true this will skip player reload on streams which have 2k/4k quality (if you enable this and you use the 2k/4k quality setting you'll get error #4000 / #3000 / spinning wheel on chrome based browsers)
|
scope.SkipPlayerReloadOnHevc = false;// If true this will skip player reload on streams which have 2k/4k quality (if you enable this and you use the 2k/4k quality setting you'll get error #4000 / #3000 / spinning wheel on chrome based browsers)
|
||||||
scope.AlwaysReloadPlayerOnAd = false;// Always pause/play when entering/leaving ads
|
scope.AlwaysReloadPlayerOnAd = false;// Always pause/play when entering/leaving ads
|
||||||
scope.ReloadPlayerAfterAd = true;// After the ad finishes do a player reload instead of pause/play
|
scope.ReloadPlayerAfterAd = true;// After the ad finishes do a player reload instead of pause/play
|
||||||
scope.PlayerReloadMinimalRequestsTime = 1500;
|
scope.PlayerReloadMinimalRequestsTime = 1500;
|
||||||
scope.PlayerReloadMinimalRequestsPlayerIndex = 0;//embed
|
scope.PlayerReloadMinimalRequestsPlayerIndex = 2;//autoplay
|
||||||
scope.HasTriggeredPlayerReload = false;
|
scope.HasTriggeredPlayerReload = false;
|
||||||
scope.StreamInfos = [];
|
scope.StreamInfos = [];
|
||||||
scope.StreamInfosByUrl = [];
|
scope.StreamInfosByUrl = [];
|
||||||
@@ -698,7 +698,7 @@ twitch-videoad.js text/javascript
|
|||||||
const bufferDuration = player.getBufferDuration();
|
const bufferDuration = player.getBufferDuration();
|
||||||
//console.log('position:' + position + ' bufferDuration:' + bufferDuration + ' bufferPosition:' + bufferedPosition);
|
//console.log('position:' + position + ' bufferDuration:' + bufferDuration + ' bufferPosition:' + bufferedPosition);
|
||||||
// NOTE: This could be improved. It currently lets the player fully eat the full buffer before it triggers pause/play
|
// NOTE: This could be improved. It currently lets the player fully eat the full buffer before it triggers pause/play
|
||||||
if (position > 0 &&
|
if (position > 5 &&// changed from >0 to >5 due to issues with prerolls. TODO: Improve this, player could get stuck
|
||||||
(playerBufferState.position == position || bufferDuration < PlayerBufferingDangerZone) &&
|
(playerBufferState.position == position || bufferDuration < PlayerBufferingDangerZone) &&
|
||||||
playerBufferState.bufferedPosition == bufferedPosition &&
|
playerBufferState.bufferedPosition == bufferedPosition &&
|
||||||
playerBufferState.bufferDuration >= bufferDuration &&
|
playerBufferState.bufferDuration >= bufferDuration &&
|
||||||
@@ -923,18 +923,17 @@ twitch-videoad.js text/javascript
|
|||||||
postTwitchWorkerMessage('UpdateAuthorizationHeader', AuthorizationHeader = init.headers['Authorization']);
|
postTwitchWorkerMessage('UpdateAuthorizationHeader', AuthorizationHeader = init.headers['Authorization']);
|
||||||
}
|
}
|
||||||
if (ForceAccessTokenPlayerType && typeof init.body === 'string' && init.body.includes('PlaybackAccessToken')) {
|
if (ForceAccessTokenPlayerType && typeof init.body === 'string' && init.body.includes('PlaybackAccessToken')) {
|
||||||
const targetPlayerType = 'embed';
|
|
||||||
let replacedPlayerType = '';
|
let replacedPlayerType = '';
|
||||||
const newBody = JSON.parse(init.body);
|
const newBody = JSON.parse(init.body);
|
||||||
if (Array.isArray(newBody)) {
|
if (Array.isArray(newBody)) {
|
||||||
for (let i = 0; i < newBody.length; i++) {
|
for (let i = 0; i < newBody.length; i++) {
|
||||||
if (newBody[i]?.variables?.playerType && newBody[i]?.variables?.playerType === targetPlayerType) {
|
if (newBody[i]?.variables?.playerType && newBody[i]?.variables?.playerType !== ForceAccessTokenPlayerType) {
|
||||||
replacedPlayerType = newBody[i].variables.playerType;
|
replacedPlayerType = newBody[i].variables.playerType;
|
||||||
newBody[i].variables.playerType = ForceAccessTokenPlayerType;
|
newBody[i].variables.playerType = ForceAccessTokenPlayerType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (newBody?.variables?.playerType && newBody?.variables?.playerType === targetPlayerType) {
|
if (newBody?.variables?.playerType && newBody?.variables?.playerType !== ForceAccessTokenPlayerType) {
|
||||||
replacedPlayerType = newBody.variables.playerType;
|
replacedPlayerType = newBody.variables.playerType;
|
||||||
newBody.variables.playerType = ForceAccessTokenPlayerType;
|
newBody.variables.playerType = ForceAccessTokenPlayerType;
|
||||||
}
|
}
|
||||||
@@ -944,14 +943,10 @@ twitch-videoad.js text/javascript
|
|||||||
init.body = JSON.stringify(newBody);
|
init.body = JSON.stringify(newBody);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Get rid of mini player above chat
|
// Get rid of mini player above chat - TODO: Reject this locally instead of having server reject it
|
||||||
if (init && typeof init.body === 'string' && init.body.includes('PlaybackAccessToken') && init.body.includes('picture-by-picture')) {
|
if (init && typeof init.body === 'string' && init.body.includes('PlaybackAccessToken') && init.body.includes('picture-by-picture')) {
|
||||||
init.body = '';
|
init.body = '';
|
||||||
}
|
}
|
||||||
var isPBYPRequest = url.includes('picture-by-picture');
|
|
||||||
if (isPBYPRequest) {
|
|
||||||
url = '';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return realFetch.apply(this, arguments);
|
return realFetch.apply(this, arguments);
|
||||||
|
|||||||
+10
-15
@@ -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 32.0.0
|
// @version 33.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
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
(function() {
|
(function() {
|
||||||
'use strict';
|
'use strict';
|
||||||
const ourTwitchAdSolutionsVersion = 19;// Used to prevent conflicts with outdated versions of the scripts
|
const ourTwitchAdSolutionsVersion = 20;// Used to prevent conflicts with outdated versions of the scripts
|
||||||
if (typeof window.twitchAdSolutionsVersion !== 'undefined' && window.twitchAdSolutionsVersion >= ourTwitchAdSolutionsVersion) {
|
if (typeof window.twitchAdSolutionsVersion !== 'undefined' && window.twitchAdSolutionsVersion >= ourTwitchAdSolutionsVersion) {
|
||||||
console.log("skipping vaft as there's another script active. ourVersion:" + ourTwitchAdSolutionsVersion + " activeVersion:" + window.twitchAdSolutionsVersion);
|
console.log("skipping vaft as there's another script active. ourVersion:" + ourTwitchAdSolutionsVersion + " activeVersion:" + window.twitchAdSolutionsVersion);
|
||||||
window.twitchAdSolutionsVersion = ourTwitchAdSolutionsVersion;
|
window.twitchAdSolutionsVersion = ourTwitchAdSolutionsVersion;
|
||||||
@@ -25,17 +25,17 @@
|
|||||||
scope.ClientID = 'kimne78kx3ncx6brgo4mv6wki5h1ko';
|
scope.ClientID = 'kimne78kx3ncx6brgo4mv6wki5h1ko';
|
||||||
scope.BackupPlayerTypes = [
|
scope.BackupPlayerTypes = [
|
||||||
'embed',//Source
|
'embed',//Source
|
||||||
'site',//Source
|
'popout',//Source
|
||||||
'autoplay',//360p
|
'autoplay',//360p
|
||||||
'picture-by-picture-CACHED'//360p (-CACHED is an internal suffix and is removed)
|
//'picture-by-picture-CACHED'//360p (-CACHED is an internal suffix and is removed)
|
||||||
];
|
];
|
||||||
scope.FallbackPlayerType = 'embed';
|
scope.FallbackPlayerType = 'embed';
|
||||||
scope.ForceAccessTokenPlayerType = 'site';// Replaces 'embed' player type with 'site' (to reduce prerolls when on embeded websites)
|
scope.ForceAccessTokenPlayerType = 'popout';
|
||||||
scope.SkipPlayerReloadOnHevc = false;// If true this will skip player reload on streams which have 2k/4k quality (if you enable this and you use the 2k/4k quality setting you'll get error #4000 / #3000 / spinning wheel on chrome based browsers)
|
scope.SkipPlayerReloadOnHevc = false;// If true this will skip player reload on streams which have 2k/4k quality (if you enable this and you use the 2k/4k quality setting you'll get error #4000 / #3000 / spinning wheel on chrome based browsers)
|
||||||
scope.AlwaysReloadPlayerOnAd = false;// Always pause/play when entering/leaving ads
|
scope.AlwaysReloadPlayerOnAd = false;// Always pause/play when entering/leaving ads
|
||||||
scope.ReloadPlayerAfterAd = true;// After the ad finishes do a player reload instead of pause/play
|
scope.ReloadPlayerAfterAd = true;// After the ad finishes do a player reload instead of pause/play
|
||||||
scope.PlayerReloadMinimalRequestsTime = 1500;
|
scope.PlayerReloadMinimalRequestsTime = 1500;
|
||||||
scope.PlayerReloadMinimalRequestsPlayerIndex = 0;//embed
|
scope.PlayerReloadMinimalRequestsPlayerIndex = 2;//autoplay
|
||||||
scope.HasTriggeredPlayerReload = false;
|
scope.HasTriggeredPlayerReload = false;
|
||||||
scope.StreamInfos = [];
|
scope.StreamInfos = [];
|
||||||
scope.StreamInfosByUrl = [];
|
scope.StreamInfosByUrl = [];
|
||||||
@@ -709,7 +709,7 @@
|
|||||||
const bufferDuration = player.getBufferDuration();
|
const bufferDuration = player.getBufferDuration();
|
||||||
//console.log('position:' + position + ' bufferDuration:' + bufferDuration + ' bufferPosition:' + bufferedPosition);
|
//console.log('position:' + position + ' bufferDuration:' + bufferDuration + ' bufferPosition:' + bufferedPosition);
|
||||||
// NOTE: This could be improved. It currently lets the player fully eat the full buffer before it triggers pause/play
|
// NOTE: This could be improved. It currently lets the player fully eat the full buffer before it triggers pause/play
|
||||||
if (position > 0 &&
|
if (position > 5 &&// changed from >0 to >5 due to issues with prerolls. TODO: Improve this, player could get stuck
|
||||||
(playerBufferState.position == position || bufferDuration < PlayerBufferingDangerZone) &&
|
(playerBufferState.position == position || bufferDuration < PlayerBufferingDangerZone) &&
|
||||||
playerBufferState.bufferedPosition == bufferedPosition &&
|
playerBufferState.bufferedPosition == bufferedPosition &&
|
||||||
playerBufferState.bufferDuration >= bufferDuration &&
|
playerBufferState.bufferDuration >= bufferDuration &&
|
||||||
@@ -934,18 +934,17 @@
|
|||||||
postTwitchWorkerMessage('UpdateAuthorizationHeader', AuthorizationHeader = init.headers['Authorization']);
|
postTwitchWorkerMessage('UpdateAuthorizationHeader', AuthorizationHeader = init.headers['Authorization']);
|
||||||
}
|
}
|
||||||
if (ForceAccessTokenPlayerType && typeof init.body === 'string' && init.body.includes('PlaybackAccessToken')) {
|
if (ForceAccessTokenPlayerType && typeof init.body === 'string' && init.body.includes('PlaybackAccessToken')) {
|
||||||
const targetPlayerType = 'embed';
|
|
||||||
let replacedPlayerType = '';
|
let replacedPlayerType = '';
|
||||||
const newBody = JSON.parse(init.body);
|
const newBody = JSON.parse(init.body);
|
||||||
if (Array.isArray(newBody)) {
|
if (Array.isArray(newBody)) {
|
||||||
for (let i = 0; i < newBody.length; i++) {
|
for (let i = 0; i < newBody.length; i++) {
|
||||||
if (newBody[i]?.variables?.playerType && newBody[i]?.variables?.playerType === targetPlayerType) {
|
if (newBody[i]?.variables?.playerType && newBody[i]?.variables?.playerType !== ForceAccessTokenPlayerType) {
|
||||||
replacedPlayerType = newBody[i].variables.playerType;
|
replacedPlayerType = newBody[i].variables.playerType;
|
||||||
newBody[i].variables.playerType = ForceAccessTokenPlayerType;
|
newBody[i].variables.playerType = ForceAccessTokenPlayerType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (newBody?.variables?.playerType && newBody?.variables?.playerType === targetPlayerType) {
|
if (newBody?.variables?.playerType && newBody?.variables?.playerType !== ForceAccessTokenPlayerType) {
|
||||||
replacedPlayerType = newBody.variables.playerType;
|
replacedPlayerType = newBody.variables.playerType;
|
||||||
newBody.variables.playerType = ForceAccessTokenPlayerType;
|
newBody.variables.playerType = ForceAccessTokenPlayerType;
|
||||||
}
|
}
|
||||||
@@ -955,14 +954,10 @@
|
|||||||
init.body = JSON.stringify(newBody);
|
init.body = JSON.stringify(newBody);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Get rid of mini player above chat
|
// Get rid of mini player above chat - TODO: Reject this locally instead of having server reject it
|
||||||
if (init && typeof init.body === 'string' && init.body.includes('PlaybackAccessToken') && init.body.includes('picture-by-picture')) {
|
if (init && typeof init.body === 'string' && init.body.includes('PlaybackAccessToken') && init.body.includes('picture-by-picture')) {
|
||||||
init.body = '';
|
init.body = '';
|
||||||
}
|
}
|
||||||
var isPBYPRequest = url.includes('picture-by-picture');
|
|
||||||
if (isPBYPRequest) {
|
|
||||||
url = '';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return realFetch.apply(this, arguments);
|
return realFetch.apply(this, arguments);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
twitch-videoad.js text/javascript
|
twitch-videoad.js text/javascript
|
||||||
(function() {
|
(function() {
|
||||||
if ( /(^|\.)twitch\.tv$/.test(document.location.hostname) === false ) { return; }
|
if ( /(^|\.)twitch\.tv$/.test(document.location.hostname) === false ) { return; }
|
||||||
const ourTwitchAdSolutionsVersion = 19;// Used to prevent conflicts with outdated versions of the scripts
|
const ourTwitchAdSolutionsVersion = 20;// Used to prevent conflicts with outdated versions of the scripts
|
||||||
if (typeof window.twitchAdSolutionsVersion !== 'undefined' && window.twitchAdSolutionsVersion >= ourTwitchAdSolutionsVersion) {
|
if (typeof window.twitchAdSolutionsVersion !== 'undefined' && window.twitchAdSolutionsVersion >= ourTwitchAdSolutionsVersion) {
|
||||||
console.log("skipping video-swap-new as there's another script active. ourVersion:" + ourTwitchAdSolutionsVersion + " activeVersion:" + window.twitchAdSolutionsVersion);
|
console.log("skipping video-swap-new as there's another script active. ourVersion:" + ourTwitchAdSolutionsVersion + " activeVersion:" + window.twitchAdSolutionsVersion);
|
||||||
window.twitchAdSolutionsVersion = ourTwitchAdSolutionsVersion;
|
window.twitchAdSolutionsVersion = ourTwitchAdSolutionsVersion;
|
||||||
@@ -10,8 +10,8 @@ twitch-videoad.js text/javascript
|
|||||||
window.twitchAdSolutionsVersion = ourTwitchAdSolutionsVersion;
|
window.twitchAdSolutionsVersion = ourTwitchAdSolutionsVersion;
|
||||||
function declareOptions(scope) {
|
function declareOptions(scope) {
|
||||||
// Options / globals
|
// Options / globals
|
||||||
scope.OPT_BACKUP_PLAYER_TYPES = [ 'autoplay', 'picture-by-picture', 'autoplay-ALT', 'embed' ];
|
scope.OPT_BACKUP_PLAYER_TYPES = [ 'autoplay', 'picture-by-picture', /*'autoplay-ALT',*/ 'embed' ];
|
||||||
scope.OPT_FORCE_ACCESS_TOKEN_PLAYER_TYPE = 'site';
|
scope.OPT_FORCE_ACCESS_TOKEN_PLAYER_TYPE = 'popout';
|
||||||
scope.AD_SIGNIFIER = 'stitched-ad';
|
scope.AD_SIGNIFIER = 'stitched-ad';
|
||||||
scope.LIVE_SIGNIFIER = ',live';
|
scope.LIVE_SIGNIFIER = ',live';
|
||||||
scope.CLIENT_ID = 'kimne78kx3ncx6brgo4mv6wki5h1ko';
|
scope.CLIENT_ID = 'kimne78kx3ncx6brgo4mv6wki5h1ko';
|
||||||
@@ -686,18 +686,17 @@ twitch-videoad.js text/javascript
|
|||||||
postTwitchWorkerMessage('UpdateAuthorizationHeader', AuthorizationHeader = init.headers['Authorization']);
|
postTwitchWorkerMessage('UpdateAuthorizationHeader', AuthorizationHeader = init.headers['Authorization']);
|
||||||
}
|
}
|
||||||
if (OPT_FORCE_ACCESS_TOKEN_PLAYER_TYPE && typeof init.body === 'string' && init.body.includes('PlaybackAccessToken')) {
|
if (OPT_FORCE_ACCESS_TOKEN_PLAYER_TYPE && typeof init.body === 'string' && init.body.includes('PlaybackAccessToken')) {
|
||||||
const targetPlayerType = 'embed';
|
|
||||||
let replacedPlayerType = '';
|
let replacedPlayerType = '';
|
||||||
const newBody = JSON.parse(init.body);
|
const newBody = JSON.parse(init.body);
|
||||||
if (Array.isArray(newBody)) {
|
if (Array.isArray(newBody)) {
|
||||||
for (let i = 0; i < newBody.length; i++) {
|
for (let i = 0; i < newBody.length; i++) {
|
||||||
if (newBody[i]?.variables?.playerType && newBody[i]?.variables?.playerType === targetPlayerType) {
|
if (newBody[i]?.variables?.playerType && newBody[i]?.variables?.playerType !== OPT_FORCE_ACCESS_TOKEN_PLAYER_TYPE) {
|
||||||
replacedPlayerType = newBody[i].variables.playerType;
|
replacedPlayerType = newBody[i].variables.playerType;
|
||||||
newBody[i].variables.playerType = OPT_FORCE_ACCESS_TOKEN_PLAYER_TYPE;
|
newBody[i].variables.playerType = OPT_FORCE_ACCESS_TOKEN_PLAYER_TYPE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (newBody?.variables?.playerType && newBody?.variables?.playerType === targetPlayerType) {
|
if (newBody?.variables?.playerType && newBody?.variables?.playerType !== OPT_FORCE_ACCESS_TOKEN_PLAYER_TYPE) {
|
||||||
replacedPlayerType = newBody.variables.playerType;
|
replacedPlayerType = newBody.variables.playerType;
|
||||||
newBody.variables.playerType = OPT_FORCE_ACCESS_TOKEN_PLAYER_TYPE;
|
newBody.variables.playerType = OPT_FORCE_ACCESS_TOKEN_PLAYER_TYPE;
|
||||||
}
|
}
|
||||||
@@ -707,14 +706,10 @@ twitch-videoad.js text/javascript
|
|||||||
init.body = JSON.stringify(newBody);
|
init.body = JSON.stringify(newBody);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Get rid of mini player above chat
|
// Get rid of mini player above chat - TODO: Reject this locally instead of having server reject it
|
||||||
if (init && typeof init.body === 'string' && init.body.includes('PlaybackAccessToken') && init.body.includes('picture-by-picture')) {
|
if (init && typeof init.body === 'string' && init.body.includes('PlaybackAccessToken') && init.body.includes('picture-by-picture')) {
|
||||||
init.body = '';
|
init.body = '';
|
||||||
}
|
}
|
||||||
var isPBYPRequest = url.includes('picture-by-picture');
|
|
||||||
if (isPBYPRequest) {
|
|
||||||
url = '';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return realFetch.apply(this, arguments);
|
return realFetch.apply(this, arguments);
|
||||||
|
|||||||
@@ -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.51
|
// @version 1.52
|
||||||
// @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)
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
(function() {
|
(function() {
|
||||||
'use strict';
|
'use strict';
|
||||||
const ourTwitchAdSolutionsVersion = 19;// Used to prevent conflicts with outdated versions of the scripts
|
const ourTwitchAdSolutionsVersion = 20;// Used to prevent conflicts with outdated versions of the scripts
|
||||||
if (typeof window.twitchAdSolutionsVersion !== 'undefined' && window.twitchAdSolutionsVersion >= ourTwitchAdSolutionsVersion) {
|
if (typeof window.twitchAdSolutionsVersion !== 'undefined' && window.twitchAdSolutionsVersion >= ourTwitchAdSolutionsVersion) {
|
||||||
console.log("skipping video-swap-new as there's another script active. ourVersion:" + ourTwitchAdSolutionsVersion + " activeVersion:" + window.twitchAdSolutionsVersion);
|
console.log("skipping video-swap-new as there's another script active. ourVersion:" + ourTwitchAdSolutionsVersion + " activeVersion:" + window.twitchAdSolutionsVersion);
|
||||||
window.twitchAdSolutionsVersion = ourTwitchAdSolutionsVersion;
|
window.twitchAdSolutionsVersion = ourTwitchAdSolutionsVersion;
|
||||||
@@ -22,8 +22,8 @@
|
|||||||
window.twitchAdSolutionsVersion = ourTwitchAdSolutionsVersion;
|
window.twitchAdSolutionsVersion = ourTwitchAdSolutionsVersion;
|
||||||
function declareOptions(scope) {
|
function declareOptions(scope) {
|
||||||
// Options / globals
|
// Options / globals
|
||||||
scope.OPT_BACKUP_PLAYER_TYPES = [ 'autoplay', 'picture-by-picture', 'autoplay-ALT', 'embed' ];
|
scope.OPT_BACKUP_PLAYER_TYPES = [ 'autoplay', 'picture-by-picture', /*'autoplay-ALT',*/ 'embed' ];
|
||||||
scope.OPT_FORCE_ACCESS_TOKEN_PLAYER_TYPE = 'site';
|
scope.OPT_FORCE_ACCESS_TOKEN_PLAYER_TYPE = 'popout';
|
||||||
scope.AD_SIGNIFIER = 'stitched-ad';
|
scope.AD_SIGNIFIER = 'stitched-ad';
|
||||||
scope.LIVE_SIGNIFIER = ',live';
|
scope.LIVE_SIGNIFIER = ',live';
|
||||||
scope.CLIENT_ID = 'kimne78kx3ncx6brgo4mv6wki5h1ko';
|
scope.CLIENT_ID = 'kimne78kx3ncx6brgo4mv6wki5h1ko';
|
||||||
@@ -698,18 +698,17 @@
|
|||||||
postTwitchWorkerMessage('UpdateAuthorizationHeader', AuthorizationHeader = init.headers['Authorization']);
|
postTwitchWorkerMessage('UpdateAuthorizationHeader', AuthorizationHeader = init.headers['Authorization']);
|
||||||
}
|
}
|
||||||
if (OPT_FORCE_ACCESS_TOKEN_PLAYER_TYPE && typeof init.body === 'string' && init.body.includes('PlaybackAccessToken')) {
|
if (OPT_FORCE_ACCESS_TOKEN_PLAYER_TYPE && typeof init.body === 'string' && init.body.includes('PlaybackAccessToken')) {
|
||||||
const targetPlayerType = 'embed';
|
|
||||||
let replacedPlayerType = '';
|
let replacedPlayerType = '';
|
||||||
const newBody = JSON.parse(init.body);
|
const newBody = JSON.parse(init.body);
|
||||||
if (Array.isArray(newBody)) {
|
if (Array.isArray(newBody)) {
|
||||||
for (let i = 0; i < newBody.length; i++) {
|
for (let i = 0; i < newBody.length; i++) {
|
||||||
if (newBody[i]?.variables?.playerType && newBody[i]?.variables?.playerType === targetPlayerType) {
|
if (newBody[i]?.variables?.playerType && newBody[i]?.variables?.playerType !== OPT_FORCE_ACCESS_TOKEN_PLAYER_TYPE) {
|
||||||
replacedPlayerType = newBody[i].variables.playerType;
|
replacedPlayerType = newBody[i].variables.playerType;
|
||||||
newBody[i].variables.playerType = OPT_FORCE_ACCESS_TOKEN_PLAYER_TYPE;
|
newBody[i].variables.playerType = OPT_FORCE_ACCESS_TOKEN_PLAYER_TYPE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (newBody?.variables?.playerType && newBody?.variables?.playerType === targetPlayerType) {
|
if (newBody?.variables?.playerType && newBody?.variables?.playerType !== OPT_FORCE_ACCESS_TOKEN_PLAYER_TYPE) {
|
||||||
replacedPlayerType = newBody.variables.playerType;
|
replacedPlayerType = newBody.variables.playerType;
|
||||||
newBody.variables.playerType = OPT_FORCE_ACCESS_TOKEN_PLAYER_TYPE;
|
newBody.variables.playerType = OPT_FORCE_ACCESS_TOKEN_PLAYER_TYPE;
|
||||||
}
|
}
|
||||||
@@ -719,14 +718,10 @@
|
|||||||
init.body = JSON.stringify(newBody);
|
init.body = JSON.stringify(newBody);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Get rid of mini player above chat
|
// Get rid of mini player above chat - TODO: Reject this locally instead of having server reject it
|
||||||
if (init && typeof init.body === 'string' && init.body.includes('PlaybackAccessToken') && init.body.includes('picture-by-picture')) {
|
if (init && typeof init.body === 'string' && init.body.includes('PlaybackAccessToken') && init.body.includes('picture-by-picture')) {
|
||||||
init.body = '';
|
init.body = '';
|
||||||
}
|
}
|
||||||
var isPBYPRequest = url.includes('picture-by-picture');
|
|
||||||
if (isPBYPRequest) {
|
|
||||||
url = '';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return realFetch.apply(this, arguments);
|
return realFetch.apply(this, arguments);
|
||||||
|
|||||||
Reference in New Issue
Block a user