diff --git a/vaft/vaft-ublock-origin.js b/vaft/vaft-ublock-origin.js index 5b8dd6f..f910c28 100644 --- a/vaft/vaft-ublock-origin.js +++ b/vaft/vaft-ublock-origin.js @@ -2,7 +2,7 @@ twitch-videoad.js text/javascript (function() { if ( /(^|\.)twitch\.tv$/.test(document.location.hostname) === false ) { return; } '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) { console.log("skipping vaft as there's another script active. ourVersion:" + ourTwitchAdSolutionsVersion + " activeVersion:" + window.twitchAdSolutionsVersion); window.twitchAdSolutionsVersion = ourTwitchAdSolutionsVersion; @@ -14,17 +14,17 @@ twitch-videoad.js text/javascript scope.ClientID = 'kimne78kx3ncx6brgo4mv6wki5h1ko'; scope.BackupPlayerTypes = [ 'embed',//Source - 'site',//Source + 'popout',//Source '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.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.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.PlayerReloadMinimalRequestsTime = 1500; - scope.PlayerReloadMinimalRequestsPlayerIndex = 0;//embed + scope.PlayerReloadMinimalRequestsPlayerIndex = 2;//autoplay scope.HasTriggeredPlayerReload = false; scope.StreamInfos = []; scope.StreamInfosByUrl = []; @@ -698,7 +698,7 @@ twitch-videoad.js text/javascript const bufferDuration = player.getBufferDuration(); //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 - 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.bufferedPosition == bufferedPosition && playerBufferState.bufferDuration >= bufferDuration && @@ -923,18 +923,17 @@ twitch-videoad.js text/javascript postTwitchWorkerMessage('UpdateAuthorizationHeader', AuthorizationHeader = init.headers['Authorization']); } if (ForceAccessTokenPlayerType && typeof init.body === 'string' && init.body.includes('PlaybackAccessToken')) { - const targetPlayerType = 'embed'; let replacedPlayerType = ''; const newBody = JSON.parse(init.body); if (Array.isArray(newBody)) { 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; newBody[i].variables.playerType = ForceAccessTokenPlayerType; } } } else { - if (newBody?.variables?.playerType && newBody?.variables?.playerType === targetPlayerType) { + if (newBody?.variables?.playerType && newBody?.variables?.playerType !== ForceAccessTokenPlayerType) { replacedPlayerType = newBody.variables.playerType; newBody.variables.playerType = ForceAccessTokenPlayerType; } @@ -944,14 +943,10 @@ twitch-videoad.js text/javascript 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')) { init.body = ''; } - var isPBYPRequest = url.includes('picture-by-picture'); - if (isPBYPRequest) { - url = ''; - } } } return realFetch.apply(this, arguments); diff --git a/vaft/vaft.user.js b/vaft/vaft.user.js index 53095fa..362b231 100644 --- a/vaft/vaft.user.js +++ b/vaft/vaft.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name TwitchAdSolutions (vaft) // @namespace https://github.com/pixeltris/TwitchAdSolutions -// @version 32.0.0 +// @version 33.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 @@ -13,7 +13,7 @@ // ==/UserScript== (function() { '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) { console.log("skipping vaft as there's another script active. ourVersion:" + ourTwitchAdSolutionsVersion + " activeVersion:" + window.twitchAdSolutionsVersion); window.twitchAdSolutionsVersion = ourTwitchAdSolutionsVersion; @@ -25,17 +25,17 @@ scope.ClientID = 'kimne78kx3ncx6brgo4mv6wki5h1ko'; scope.BackupPlayerTypes = [ 'embed',//Source - 'site',//Source + 'popout',//Source '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.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.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.PlayerReloadMinimalRequestsTime = 1500; - scope.PlayerReloadMinimalRequestsPlayerIndex = 0;//embed + scope.PlayerReloadMinimalRequestsPlayerIndex = 2;//autoplay scope.HasTriggeredPlayerReload = false; scope.StreamInfos = []; scope.StreamInfosByUrl = []; @@ -709,7 +709,7 @@ const bufferDuration = player.getBufferDuration(); //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 - 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.bufferedPosition == bufferedPosition && playerBufferState.bufferDuration >= bufferDuration && @@ -934,18 +934,17 @@ postTwitchWorkerMessage('UpdateAuthorizationHeader', AuthorizationHeader = init.headers['Authorization']); } if (ForceAccessTokenPlayerType && typeof init.body === 'string' && init.body.includes('PlaybackAccessToken')) { - const targetPlayerType = 'embed'; let replacedPlayerType = ''; const newBody = JSON.parse(init.body); if (Array.isArray(newBody)) { 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; newBody[i].variables.playerType = ForceAccessTokenPlayerType; } } } else { - if (newBody?.variables?.playerType && newBody?.variables?.playerType === targetPlayerType) { + if (newBody?.variables?.playerType && newBody?.variables?.playerType !== ForceAccessTokenPlayerType) { replacedPlayerType = newBody.variables.playerType; newBody.variables.playerType = ForceAccessTokenPlayerType; } @@ -955,14 +954,10 @@ 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')) { init.body = ''; } - var isPBYPRequest = url.includes('picture-by-picture'); - if (isPBYPRequest) { - url = ''; - } } } return realFetch.apply(this, arguments); diff --git a/video-swap-new/video-swap-new-ublock-origin.js b/video-swap-new/video-swap-new-ublock-origin.js index ca2ec92..9ac847d 100644 --- a/video-swap-new/video-swap-new-ublock-origin.js +++ b/video-swap-new/video-swap-new-ublock-origin.js @@ -1,7 +1,7 @@ twitch-videoad.js text/javascript (function() { 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) { console.log("skipping video-swap-new as there's another script active. ourVersion:" + ourTwitchAdSolutionsVersion + " activeVersion:" + window.twitchAdSolutionsVersion); window.twitchAdSolutionsVersion = ourTwitchAdSolutionsVersion; @@ -10,8 +10,8 @@ twitch-videoad.js text/javascript window.twitchAdSolutionsVersion = ourTwitchAdSolutionsVersion; function declareOptions(scope) { // Options / globals - scope.OPT_BACKUP_PLAYER_TYPES = [ 'autoplay', 'picture-by-picture', 'autoplay-ALT', 'embed' ]; - scope.OPT_FORCE_ACCESS_TOKEN_PLAYER_TYPE = 'site'; + scope.OPT_BACKUP_PLAYER_TYPES = [ 'autoplay', 'picture-by-picture', /*'autoplay-ALT',*/ 'embed' ]; + scope.OPT_FORCE_ACCESS_TOKEN_PLAYER_TYPE = 'popout'; scope.AD_SIGNIFIER = 'stitched-ad'; scope.LIVE_SIGNIFIER = ',live'; scope.CLIENT_ID = 'kimne78kx3ncx6brgo4mv6wki5h1ko'; @@ -686,18 +686,17 @@ twitch-videoad.js text/javascript postTwitchWorkerMessage('UpdateAuthorizationHeader', AuthorizationHeader = init.headers['Authorization']); } if (OPT_FORCE_ACCESS_TOKEN_PLAYER_TYPE && typeof init.body === 'string' && init.body.includes('PlaybackAccessToken')) { - const targetPlayerType = 'embed'; let replacedPlayerType = ''; const newBody = JSON.parse(init.body); if (Array.isArray(newBody)) { 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; newBody[i].variables.playerType = OPT_FORCE_ACCESS_TOKEN_PLAYER_TYPE; } } } 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; newBody.variables.playerType = OPT_FORCE_ACCESS_TOKEN_PLAYER_TYPE; } @@ -707,14 +706,10 @@ twitch-videoad.js text/javascript 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')) { init.body = ''; } - var isPBYPRequest = url.includes('picture-by-picture'); - if (isPBYPRequest) { - url = ''; - } } } return realFetch.apply(this, arguments); diff --git a/video-swap-new/video-swap-new.user.js b/video-swap-new/video-swap-new.user.js index f25bd58..41ab5b4 100644 --- a/video-swap-new/video-swap-new.user.js +++ b/video-swap-new/video-swap-new.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name TwitchAdSolutions (video-swap-new) // @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 // @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) @@ -13,7 +13,7 @@ // ==/UserScript== (function() { '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) { console.log("skipping video-swap-new as there's another script active. ourVersion:" + ourTwitchAdSolutionsVersion + " activeVersion:" + window.twitchAdSolutionsVersion); window.twitchAdSolutionsVersion = ourTwitchAdSolutionsVersion; @@ -22,8 +22,8 @@ window.twitchAdSolutionsVersion = ourTwitchAdSolutionsVersion; function declareOptions(scope) { // Options / globals - scope.OPT_BACKUP_PLAYER_TYPES = [ 'autoplay', 'picture-by-picture', 'autoplay-ALT', 'embed' ]; - scope.OPT_FORCE_ACCESS_TOKEN_PLAYER_TYPE = 'site'; + scope.OPT_BACKUP_PLAYER_TYPES = [ 'autoplay', 'picture-by-picture', /*'autoplay-ALT',*/ 'embed' ]; + scope.OPT_FORCE_ACCESS_TOKEN_PLAYER_TYPE = 'popout'; scope.AD_SIGNIFIER = 'stitched-ad'; scope.LIVE_SIGNIFIER = ',live'; scope.CLIENT_ID = 'kimne78kx3ncx6brgo4mv6wki5h1ko'; @@ -698,18 +698,17 @@ postTwitchWorkerMessage('UpdateAuthorizationHeader', AuthorizationHeader = init.headers['Authorization']); } if (OPT_FORCE_ACCESS_TOKEN_PLAYER_TYPE && typeof init.body === 'string' && init.body.includes('PlaybackAccessToken')) { - const targetPlayerType = 'embed'; let replacedPlayerType = ''; const newBody = JSON.parse(init.body); if (Array.isArray(newBody)) { 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; newBody[i].variables.playerType = OPT_FORCE_ACCESS_TOKEN_PLAYER_TYPE; } } } 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; newBody.variables.playerType = OPT_FORCE_ACCESS_TOKEN_PLAYER_TYPE; } @@ -719,14 +718,10 @@ 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')) { init.body = ''; } - var isPBYPRequest = url.includes('picture-by-picture'); - if (isPBYPRequest) { - url = ''; - } } } return realFetch.apply(this, arguments);