Config tweaks
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user