mirror of
https://github.com/pixeltris/TwitchAdSolutions.git
synced 2024-11-22 10:22:51 +01:00
Implement @level3tjg's 360p fallback
Ref: https://github.com/cleanlock/VideoAdBlockForTwitch/pull/96
This commit is contained in:
parent
e922bb7dce
commit
6a14447b9a
@ -58,9 +58,9 @@ twitch-videoad.js text/javascript
|
|||||||
scope.ClientVersion = 'null';
|
scope.ClientVersion = 'null';
|
||||||
scope.ClientSession = 'null';
|
scope.ClientSession = 'null';
|
||||||
//scope.PlayerType1 = 'site'; //Source - NOTE: This is unused as it's implicitly used by the website iself
|
//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.PlayerType3 = 'proxy'; //Source
|
||||||
scope.PlayerType4 = 'thunderdome'; //480p
|
scope.PlayerType4 = 'embed'; //Source
|
||||||
scope.CurrentChannelName = null;
|
scope.CurrentChannelName = null;
|
||||||
scope.UsherParams = null;
|
scope.UsherParams = null;
|
||||||
scope.WasShowingAd = false;
|
scope.WasShowingAd = false;
|
||||||
@ -163,8 +163,8 @@ twitch-videoad.js text/javascript
|
|||||||
if (OriginalVideoPlayerQuality == null) {
|
if (OriginalVideoPlayerQuality == null) {
|
||||||
OriginalVideoPlayerQuality = currentQuality;
|
OriginalVideoPlayerQuality = currentQuality;
|
||||||
}
|
}
|
||||||
if (!currentQuality.includes('480') || e.data.value != null) {
|
if (!currentQuality.includes('360') || e.data.value != null) {
|
||||||
if (!OriginalVideoPlayerQuality.includes('480')) {
|
if (!OriginalVideoPlayerQuality.includes('360')) {
|
||||||
var settingsMenu = document.querySelector('div[data-a-target="player-settings-menu"]');
|
var settingsMenu = document.querySelector('div[data-a-target="player-settings-menu"]');
|
||||||
if (settingsMenu == null) {
|
if (settingsMenu == null) {
|
||||||
var settingsCog = document.querySelector('button[data-a-target="player-settings-button"]');
|
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"');
|
var lowQuality = document.querySelectorAll('input[data-a-target="tw-radio"');
|
||||||
if (lowQuality) {
|
if (lowQuality) {
|
||||||
var qualityToSelect = lowQuality.length - 3;
|
var qualityToSelect = lowQuality.length - 2;
|
||||||
if (e.data.value != null) {
|
if (e.data.value != null) {
|
||||||
if (e.data.value.includes('original')) {
|
if (e.data.value.includes('original')) {
|
||||||
e.data.value = OriginalVideoPlayerQuality;
|
e.data.value = OriginalVideoPlayerQuality;
|
||||||
@ -223,6 +223,7 @@ twitch-videoad.js text/javascript
|
|||||||
}
|
}
|
||||||
var currentQualityLS = window.localStorage.getItem('video-quality');
|
var currentQualityLS = window.localStorage.getItem('video-quality');
|
||||||
lowQuality[qualityToSelect].click();
|
lowQuality[qualityToSelect].click();
|
||||||
|
settingsCog.click();
|
||||||
window.localStorage.setItem('video-quality', currentQualityLS);
|
window.localStorage.setItem('video-quality', currentQualityLS);
|
||||||
if (e.data.value != null) {
|
if (e.data.value != null) {
|
||||||
OriginalVideoPlayerQuality = null;
|
OriginalVideoPlayerQuality = null;
|
||||||
@ -643,7 +644,7 @@ twitch-videoad.js text/javascript
|
|||||||
}
|
}
|
||||||
function getAccessToken(channelName, playerType, realFetch) {
|
function getAccessToken(channelName, playerType, realFetch) {
|
||||||
var body = null;
|
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 = {
|
body = {
|
||||||
operationName: 'PlaybackAccessToken_Template',
|
operationName: 'PlaybackAccessToken_Template',
|
||||||
query: templateQuery,
|
query: templateQuery,
|
||||||
|
@ -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 5.8.0
|
// @version 5.8.1
|
||||||
// @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
|
||||||
@ -69,9 +69,9 @@
|
|||||||
scope.ClientVersion = 'null';
|
scope.ClientVersion = 'null';
|
||||||
scope.ClientSession = 'null';
|
scope.ClientSession = 'null';
|
||||||
//scope.PlayerType1 = 'site'; //Source - NOTE: This is unused as it's implicitly used by the website iself
|
//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.PlayerType3 = 'proxy'; //Source
|
||||||
scope.PlayerType4 = 'thunderdome'; //480p
|
scope.PlayerType4 = 'embed'; //Source
|
||||||
scope.CurrentChannelName = null;
|
scope.CurrentChannelName = null;
|
||||||
scope.UsherParams = null;
|
scope.UsherParams = null;
|
||||||
scope.WasShowingAd = false;
|
scope.WasShowingAd = false;
|
||||||
@ -174,8 +174,8 @@
|
|||||||
if (OriginalVideoPlayerQuality == null) {
|
if (OriginalVideoPlayerQuality == null) {
|
||||||
OriginalVideoPlayerQuality = currentQuality;
|
OriginalVideoPlayerQuality = currentQuality;
|
||||||
}
|
}
|
||||||
if (!currentQuality.includes('480') || e.data.value != null) {
|
if (!currentQuality.includes('360') || e.data.value != null) {
|
||||||
if (!OriginalVideoPlayerQuality.includes('480')) {
|
if (!OriginalVideoPlayerQuality.includes('360')) {
|
||||||
var settingsMenu = document.querySelector('div[data-a-target="player-settings-menu"]');
|
var settingsMenu = document.querySelector('div[data-a-target="player-settings-menu"]');
|
||||||
if (settingsMenu == null) {
|
if (settingsMenu == null) {
|
||||||
var settingsCog = document.querySelector('button[data-a-target="player-settings-button"]');
|
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"');
|
var lowQuality = document.querySelectorAll('input[data-a-target="tw-radio"');
|
||||||
if (lowQuality) {
|
if (lowQuality) {
|
||||||
var qualityToSelect = lowQuality.length - 3;
|
var qualityToSelect = lowQuality.length - 2;
|
||||||
if (e.data.value != null) {
|
if (e.data.value != null) {
|
||||||
if (e.data.value.includes('original')) {
|
if (e.data.value.includes('original')) {
|
||||||
e.data.value = OriginalVideoPlayerQuality;
|
e.data.value = OriginalVideoPlayerQuality;
|
||||||
@ -234,6 +234,7 @@
|
|||||||
}
|
}
|
||||||
var currentQualityLS = window.localStorage.getItem('video-quality');
|
var currentQualityLS = window.localStorage.getItem('video-quality');
|
||||||
lowQuality[qualityToSelect].click();
|
lowQuality[qualityToSelect].click();
|
||||||
|
settingsCog.click();
|
||||||
window.localStorage.setItem('video-quality', currentQualityLS);
|
window.localStorage.setItem('video-quality', currentQualityLS);
|
||||||
if (e.data.value != null) {
|
if (e.data.value != null) {
|
||||||
OriginalVideoPlayerQuality = null;
|
OriginalVideoPlayerQuality = null;
|
||||||
@ -654,7 +655,7 @@
|
|||||||
}
|
}
|
||||||
function getAccessToken(channelName, playerType, realFetch) {
|
function getAccessToken(channelName, playerType, realFetch) {
|
||||||
var body = null;
|
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 = {
|
body = {
|
||||||
operationName: 'PlaybackAccessToken_Template',
|
operationName: 'PlaybackAccessToken_Template',
|
||||||
query: templateQuery,
|
query: templateQuery,
|
||||||
|
@ -7,9 +7,11 @@ twitch-videoad.js text/javascript
|
|||||||
scope.OPT_MODE_STRIP_AD_SEGMENTS = true;
|
scope.OPT_MODE_STRIP_AD_SEGMENTS = true;
|
||||||
scope.OPT_MODE_NOTIFY_ADS_WATCHED = true;
|
scope.OPT_MODE_NOTIFY_ADS_WATCHED = true;
|
||||||
scope.OPT_MODE_NOTIFY_ADS_WATCHED_MIN_REQUESTS = false;
|
scope.OPT_MODE_NOTIFY_ADS_WATCHED_MIN_REQUESTS = false;
|
||||||
scope.OPT_BACKUP_PLAYER_TYPE = 'embed';
|
scope.OPT_BACKUP_PLAYER_TYPE = 'autoplay';
|
||||||
|
scope.OPT_BACKUP_PLATFORM = 'ios';
|
||||||
scope.OPT_REGULAR_PLAYER_TYPE = 'site';
|
scope.OPT_REGULAR_PLAYER_TYPE = 'site';
|
||||||
scope.OPT_ACCESS_TOKEN_PLAYER_TYPE = null;
|
scope.OPT_ACCESS_TOKEN_PLAYER_TYPE = null;
|
||||||
|
scope.OPT_SHOW_AD_BANNER = true;
|
||||||
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';
|
||||||
@ -73,7 +75,9 @@ twitch-videoad.js text/javascript
|
|||||||
var adDiv = getAdDiv();
|
var adDiv = getAdDiv();
|
||||||
if (adDiv != null) {
|
if (adDiv != null) {
|
||||||
adDiv.P.textContent = 'Blocking' + (e.data.isMidroll ? ' midroll' : '') + ' ads...';
|
adDiv.P.textContent = 'Blocking' + (e.data.isMidroll ? ' midroll' : '') + ' ads...';
|
||||||
//adDiv.style.display = 'block';
|
if (OPT_SHOW_AD_BANNER) {
|
||||||
|
adDiv.style.display = 'block';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (e.data.key == 'UboHideAdBanner') {
|
} else if (e.data.key == 'UboHideAdBanner') {
|
||||||
var adDiv = getAdDiv();
|
var adDiv = getAdDiv();
|
||||||
@ -213,7 +217,7 @@ twitch-videoad.js text/javascript
|
|||||||
for (var i = 0; i < 2; i++) {
|
for (var i = 0; i < 2; i++) {
|
||||||
var encodingsUrl = url;
|
var encodingsUrl = url;
|
||||||
if (i == 1) {
|
if (i == 1) {
|
||||||
var accessTokenResponse = await getAccessToken(channelName, OPT_BACKUP_PLAYER_TYPE);
|
var accessTokenResponse = await getAccessToken(channelName, OPT_BACKUP_PLAYER_TYPE, OPT_BACKUP_PLATFORM, realFetch);
|
||||||
if (accessTokenResponse != null && accessTokenResponse.status === 200) {
|
if (accessTokenResponse != null && accessTokenResponse.status === 200) {
|
||||||
var accessToken = await accessTokenResponse.json();
|
var accessToken = await accessTokenResponse.json();
|
||||||
var urlInfo = new URL('https://usher.ttvnw.net/api/channel/hls/' + channelName + '.m3u8' + (new URL(url)).search);
|
var urlInfo = new URL('https://usher.ttvnw.net/api/channel/hls/' + channelName + '.m3u8' + (new URL(url)).search);
|
||||||
@ -286,9 +290,12 @@ twitch-videoad.js text/javascript
|
|||||||
},
|
},
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
function getAccessToken(channelName, playerType, realFetch) {
|
function getAccessToken(channelName, playerType, platform, realFetch) {
|
||||||
|
if (!platform) {
|
||||||
|
platform = 'web';
|
||||||
|
}
|
||||||
var body = null;
|
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: "' + platform + '", playerBackend: "mediaplayer", playerType: $playerType}) @include(if: $isLive) { value signature __typename } videoPlaybackAccessToken(id: $vodID, params: {platform: "' + platform + '", playerBackend: "mediaplayer", playerType: $playerType}) @include(if: $isVod) { value signature __typename }}';
|
||||||
body = {
|
body = {
|
||||||
operationName: 'PlaybackAccessToken_Template',
|
operationName: 'PlaybackAccessToken_Template',
|
||||||
query: templateQuery,
|
query: templateQuery,
|
||||||
|
@ -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.17
|
// @version 1.18
|
||||||
// @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)
|
||||||
@ -18,9 +18,11 @@
|
|||||||
scope.OPT_MODE_STRIP_AD_SEGMENTS = true;
|
scope.OPT_MODE_STRIP_AD_SEGMENTS = true;
|
||||||
scope.OPT_MODE_NOTIFY_ADS_WATCHED = true;
|
scope.OPT_MODE_NOTIFY_ADS_WATCHED = true;
|
||||||
scope.OPT_MODE_NOTIFY_ADS_WATCHED_MIN_REQUESTS = false;
|
scope.OPT_MODE_NOTIFY_ADS_WATCHED_MIN_REQUESTS = false;
|
||||||
scope.OPT_BACKUP_PLAYER_TYPE = 'embed';
|
scope.OPT_BACKUP_PLAYER_TYPE = 'autoplay';
|
||||||
|
scope.OPT_BACKUP_PLATFORM = 'ios';
|
||||||
scope.OPT_REGULAR_PLAYER_TYPE = 'site';
|
scope.OPT_REGULAR_PLAYER_TYPE = 'site';
|
||||||
scope.OPT_ACCESS_TOKEN_PLAYER_TYPE = null;
|
scope.OPT_ACCESS_TOKEN_PLAYER_TYPE = null;
|
||||||
|
scope.OPT_SHOW_AD_BANNER = true;
|
||||||
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';
|
||||||
@ -84,7 +86,9 @@
|
|||||||
var adDiv = getAdDiv();
|
var adDiv = getAdDiv();
|
||||||
if (adDiv != null) {
|
if (adDiv != null) {
|
||||||
adDiv.P.textContent = 'Blocking' + (e.data.isMidroll ? ' midroll' : '') + ' ads...';
|
adDiv.P.textContent = 'Blocking' + (e.data.isMidroll ? ' midroll' : '') + ' ads...';
|
||||||
//adDiv.style.display = 'block';
|
if (OPT_SHOW_AD_BANNER) {
|
||||||
|
adDiv.style.display = 'block';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (e.data.key == 'UboHideAdBanner') {
|
} else if (e.data.key == 'UboHideAdBanner') {
|
||||||
var adDiv = getAdDiv();
|
var adDiv = getAdDiv();
|
||||||
@ -224,7 +228,7 @@
|
|||||||
for (var i = 0; i < 2; i++) {
|
for (var i = 0; i < 2; i++) {
|
||||||
var encodingsUrl = url;
|
var encodingsUrl = url;
|
||||||
if (i == 1) {
|
if (i == 1) {
|
||||||
var accessTokenResponse = await getAccessToken(channelName, OPT_BACKUP_PLAYER_TYPE);
|
var accessTokenResponse = await getAccessToken(channelName, OPT_BACKUP_PLAYER_TYPE, OPT_BACKUP_PLATFORM, realFetch);
|
||||||
if (accessTokenResponse != null && accessTokenResponse.status === 200) {
|
if (accessTokenResponse != null && accessTokenResponse.status === 200) {
|
||||||
var accessToken = await accessTokenResponse.json();
|
var accessToken = await accessTokenResponse.json();
|
||||||
var urlInfo = new URL('https://usher.ttvnw.net/api/channel/hls/' + channelName + '.m3u8' + (new URL(url)).search);
|
var urlInfo = new URL('https://usher.ttvnw.net/api/channel/hls/' + channelName + '.m3u8' + (new URL(url)).search);
|
||||||
@ -297,9 +301,12 @@
|
|||||||
},
|
},
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
function getAccessToken(channelName, playerType, realFetch) {
|
function getAccessToken(channelName, playerType, platform, realFetch) {
|
||||||
|
if (!platform) {
|
||||||
|
platform = 'web';
|
||||||
|
}
|
||||||
var body = null;
|
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: "' + platform + '", playerBackend: "mediaplayer", playerType: $playerType}) @include(if: $isLive) { value signature __typename } videoPlaybackAccessToken(id: $vodID, params: {platform: "' + platform + '", playerBackend: "mediaplayer", playerType: $playerType}) @include(if: $isVod) { value signature __typename }}';
|
||||||
body = {
|
body = {
|
||||||
operationName: 'PlaybackAccessToken_Template',
|
operationName: 'PlaybackAccessToken_Template',
|
||||||
query: templateQuery,
|
query: templateQuery,
|
||||||
|
Loading…
Reference in New Issue
Block a user