Implement @level3tjg's 360p fallback

Ref: https://github.com/cleanlock/VideoAdBlockForTwitch/pull/96
This commit is contained in:
pixeltris
2023-06-01 09:21:49 +01:00
parent e922bb7dce
commit 6a14447b9a
4 changed files with 40 additions and 24 deletions
+7 -6
View File
@@ -58,9 +58,9 @@ twitch-videoad.js text/javascript
scope.ClientVersion = 'null';
scope.ClientSession = 'null';
//scope.PlayerType1 = 'site'; //Source - NOTE: This is unused as it's implicitly used by the website iself
scope.PlayerType2 = 'embed'; //Source
scope.PlayerType2 = 'autoplay'; //360p
scope.PlayerType3 = 'proxy'; //Source
scope.PlayerType4 = 'thunderdome'; //480p
scope.PlayerType4 = 'embed'; //Source
scope.CurrentChannelName = null;
scope.UsherParams = null;
scope.WasShowingAd = false;
@@ -163,8 +163,8 @@ twitch-videoad.js text/javascript
if (OriginalVideoPlayerQuality == null) {
OriginalVideoPlayerQuality = currentQuality;
}
if (!currentQuality.includes('480') || e.data.value != null) {
if (!OriginalVideoPlayerQuality.includes('480')) {
if (!currentQuality.includes('360') || e.data.value != null) {
if (!OriginalVideoPlayerQuality.includes('360')) {
var settingsMenu = document.querySelector('div[data-a-target="player-settings-menu"]');
if (settingsMenu == null) {
var settingsCog = document.querySelector('button[data-a-target="player-settings-button"]');
@@ -176,7 +176,7 @@ twitch-videoad.js text/javascript
}
var lowQuality = document.querySelectorAll('input[data-a-target="tw-radio"');
if (lowQuality) {
var qualityToSelect = lowQuality.length - 3;
var qualityToSelect = lowQuality.length - 2;
if (e.data.value != null) {
if (e.data.value.includes('original')) {
e.data.value = OriginalVideoPlayerQuality;
@@ -223,6 +223,7 @@ twitch-videoad.js text/javascript
}
var currentQualityLS = window.localStorage.getItem('video-quality');
lowQuality[qualityToSelect].click();
settingsCog.click();
window.localStorage.setItem('video-quality', currentQualityLS);
if (e.data.value != null) {
OriginalVideoPlayerQuality = null;
@@ -643,7 +644,7 @@ twitch-videoad.js text/javascript
}
function getAccessToken(channelName, playerType, realFetch) {
var body = null;
var templateQuery = 'query PlaybackAccessToken_Template($login: String!, $isLive: Boolean!, $vodID: ID!, $isVod: Boolean!, $playerType: String!) { streamPlaybackAccessToken(channelName: $login, params: {platform: "web", playerBackend: "mediaplayer", playerType: $playerType}) @include(if: $isLive) { value signature __typename } videoPlaybackAccessToken(id: $vodID, params: {platform: "web", playerBackend: "mediaplayer", playerType: $playerType}) @include(if: $isVod) { value signature __typename }}';
var templateQuery = 'query PlaybackAccessToken_Template($login: String!, $isLive: Boolean!, $vodID: ID!, $isVod: Boolean!, $playerType: String!) { streamPlaybackAccessToken(channelName: $login, params: {platform: "ios", playerBackend: "mediaplayer", playerType: $playerType}) @include(if: $isLive) { value signature __typename } videoPlaybackAccessToken(id: $vodID, params: {platform: "ios", playerBackend: "mediaplayer", playerType: $playerType}) @include(if: $isVod) { value signature __typename }}';
body = {
operationName: 'PlaybackAccessToken_Template',
query: templateQuery,
+8 -7
View File
@@ -1,7 +1,7 @@
// ==UserScript==
// @name TwitchAdSolutions (vaft)
// @namespace https://github.com/pixeltris/TwitchAdSolutions
// @version 5.8.0
// @version 5.8.1
// @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
@@ -69,9 +69,9 @@
scope.ClientVersion = 'null';
scope.ClientSession = 'null';
//scope.PlayerType1 = 'site'; //Source - NOTE: This is unused as it's implicitly used by the website iself
scope.PlayerType2 = 'embed'; //Source
scope.PlayerType2 = 'autoplay'; //360p
scope.PlayerType3 = 'proxy'; //Source
scope.PlayerType4 = 'thunderdome'; //480p
scope.PlayerType4 = 'embed'; //Source
scope.CurrentChannelName = null;
scope.UsherParams = null;
scope.WasShowingAd = false;
@@ -174,8 +174,8 @@
if (OriginalVideoPlayerQuality == null) {
OriginalVideoPlayerQuality = currentQuality;
}
if (!currentQuality.includes('480') || e.data.value != null) {
if (!OriginalVideoPlayerQuality.includes('480')) {
if (!currentQuality.includes('360') || e.data.value != null) {
if (!OriginalVideoPlayerQuality.includes('360')) {
var settingsMenu = document.querySelector('div[data-a-target="player-settings-menu"]');
if (settingsMenu == null) {
var settingsCog = document.querySelector('button[data-a-target="player-settings-button"]');
@@ -187,7 +187,7 @@
}
var lowQuality = document.querySelectorAll('input[data-a-target="tw-radio"');
if (lowQuality) {
var qualityToSelect = lowQuality.length - 3;
var qualityToSelect = lowQuality.length - 2;
if (e.data.value != null) {
if (e.data.value.includes('original')) {
e.data.value = OriginalVideoPlayerQuality;
@@ -234,6 +234,7 @@
}
var currentQualityLS = window.localStorage.getItem('video-quality');
lowQuality[qualityToSelect].click();
settingsCog.click();
window.localStorage.setItem('video-quality', currentQualityLS);
if (e.data.value != null) {
OriginalVideoPlayerQuality = null;
@@ -654,7 +655,7 @@
}
function getAccessToken(channelName, playerType, realFetch) {
var body = null;
var templateQuery = 'query PlaybackAccessToken_Template($login: String!, $isLive: Boolean!, $vodID: ID!, $isVod: Boolean!, $playerType: String!) { streamPlaybackAccessToken(channelName: $login, params: {platform: "web", playerBackend: "mediaplayer", playerType: $playerType}) @include(if: $isLive) { value signature __typename } videoPlaybackAccessToken(id: $vodID, params: {platform: "web", playerBackend: "mediaplayer", playerType: $playerType}) @include(if: $isVod) { value signature __typename }}';
var templateQuery = 'query PlaybackAccessToken_Template($login: String!, $isLive: Boolean!, $vodID: ID!, $isVod: Boolean!, $playerType: String!) { streamPlaybackAccessToken(channelName: $login, params: {platform: "ios", playerBackend: "mediaplayer", playerType: $playerType}) @include(if: $isLive) { value signature __typename } videoPlaybackAccessToken(id: $vodID, params: {platform: "ios", playerBackend: "mediaplayer", playerType: $playerType}) @include(if: $isVod) { value signature __typename }}';
body = {
operationName: 'PlaybackAccessToken_Template',
query: templateQuery,