mirror of
https://github.com/pixeltris/TwitchAdSolutions.git
synced 2024-11-22 10:22:51 +01:00
Fix quality reset on video-swap-new #156
- Change vaft priority to embed followed by 360p - Possibly fix mute/volume reset on video-swap-new #170
This commit is contained in:
parent
4452680765
commit
c3663da4a9
@ -57,10 +57,8 @@ twitch-videoad.js text/javascript
|
|||||||
scope.ClientID = 'kimne78kx3ncx6brgo4mv6wki5h1ko';
|
scope.ClientID = 'kimne78kx3ncx6brgo4mv6wki5h1ko';
|
||||||
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.PlayerType2 = 'embed'; //Source
|
||||||
scope.PlayerType2 = 'autoplay'; //360p
|
scope.PlayerType3 = 'autoplay'; //360p
|
||||||
scope.PlayerType3 = 'embed'; //Source
|
|
||||||
//scope.PlayerType4 = 'embed'; //Source
|
|
||||||
scope.CurrentChannelName = null;
|
scope.CurrentChannelName = null;
|
||||||
scope.UsherParams = null;
|
scope.UsherParams = null;
|
||||||
scope.WasShowingAd = false;
|
scope.WasShowingAd = false;
|
||||||
@ -284,9 +282,6 @@ twitch-videoad.js text/javascript
|
|||||||
if (weaverText.includes(AdSignifier)) {
|
if (weaverText.includes(AdSignifier)) {
|
||||||
weaverText = await processM3U8(url, responseText, realFetch, PlayerType3);
|
weaverText = await processM3U8(url, responseText, realFetch, PlayerType3);
|
||||||
}
|
}
|
||||||
//if (weaverText.includes(AdSignifier)) {
|
|
||||||
// weaverText = await processM3U8(url, responseText, realFetch, PlayerType4);
|
|
||||||
//}
|
|
||||||
resolve(new Response(weaverText));
|
resolve(new Response(weaverText));
|
||||||
};
|
};
|
||||||
var send = function() {
|
var send = function() {
|
||||||
|
@ -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.3
|
// @version 5.8.4
|
||||||
// @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
|
||||||
@ -68,10 +68,8 @@
|
|||||||
scope.ClientID = 'kimne78kx3ncx6brgo4mv6wki5h1ko';
|
scope.ClientID = 'kimne78kx3ncx6brgo4mv6wki5h1ko';
|
||||||
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.PlayerType2 = 'embed'; //Source
|
||||||
scope.PlayerType2 = 'autoplay'; //360p
|
scope.PlayerType3 = 'autoplay'; //360p
|
||||||
scope.PlayerType3 = 'embed'; //Source
|
|
||||||
//scope.PlayerType4 = 'embed'; //Source
|
|
||||||
scope.CurrentChannelName = null;
|
scope.CurrentChannelName = null;
|
||||||
scope.UsherParams = null;
|
scope.UsherParams = null;
|
||||||
scope.WasShowingAd = false;
|
scope.WasShowingAd = false;
|
||||||
@ -295,9 +293,6 @@
|
|||||||
if (weaverText.includes(AdSignifier)) {
|
if (weaverText.includes(AdSignifier)) {
|
||||||
weaverText = await processM3U8(url, responseText, realFetch, PlayerType3);
|
weaverText = await processM3U8(url, responseText, realFetch, PlayerType3);
|
||||||
}
|
}
|
||||||
//if (weaverText.includes(AdSignifier)) {
|
|
||||||
// weaverText = await processM3U8(url, responseText, realFetch, PlayerType4);
|
|
||||||
//}
|
|
||||||
resolve(new Response(weaverText));
|
resolve(new Response(weaverText));
|
||||||
};
|
};
|
||||||
var send = function() {
|
var send = function() {
|
||||||
|
@ -249,6 +249,32 @@ twitch-videoad.js text/javascript
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
var lowResLines = encodingsM3u8.replace('\r', '').split('\n');
|
||||||
|
var lowResBestUrl = null;
|
||||||
|
for (var j = 0; j < lowResLines.length; j++) {
|
||||||
|
if (lowResLines[j].startsWith('#EXT-X-STREAM-INF')) {
|
||||||
|
var res = parseAttributes(lowResLines[j])['RESOLUTION'];
|
||||||
|
if (res && lowResLines[j + 1].endsWith('.m3u8')) {
|
||||||
|
// Assumes resolutions are correctly ordered
|
||||||
|
lowResBestUrl = lowResLines[j + 1];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (lowResBestUrl != null && streamInfo.Encodings != null) {
|
||||||
|
var normalEncodingsM3u8 = streamInfo.Encodings;
|
||||||
|
var normalLines = normalEncodingsM3u8.replace('\r', '').split('\n');
|
||||||
|
for (var j = 0; j < normalLines.length - 1; j++) {
|
||||||
|
if (normalLines[j].startsWith('#EXT-X-STREAM-INF')) {
|
||||||
|
var res = parseAttributes(normalLines[j])['RESOLUTION'];
|
||||||
|
if (res) {
|
||||||
|
lowResBestUrl += ' ';// The stream doesn't load unless each url line is unique
|
||||||
|
normalLines[j + 1] = lowResBestUrl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
encodingsM3u8 = normalLines.join('\r\n');
|
||||||
|
}
|
||||||
streamInfo.BackupEncodings = encodingsM3u8;
|
streamInfo.BackupEncodings = encodingsM3u8;
|
||||||
}
|
}
|
||||||
var lines = encodingsM3u8.replace('\r', '').split('\n');
|
var lines = encodingsM3u8.replace('\r', '').split('\n');
|
||||||
@ -511,22 +537,25 @@ twitch-videoad.js text/javascript
|
|||||||
player.play();
|
player.play();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const sink = player.mediaSinkManager || (player.core ? player.core.mediaSinkManager : null);
|
const lsKeyQuality = 'video-quality';
|
||||||
if (sink && sink.video && sink.video._ffz_compressor) {
|
const lsKeyMuted = 'video-muted';
|
||||||
const video = sink.video;
|
const lsKeyVolume = 'volume';
|
||||||
const volume = video.volume ? video.volume : player.getVolume();
|
var currentQualityLS = localStorage.getItem(lsKeyQuality);
|
||||||
const muted = player.isMuted();
|
var currentMutedLS = localStorage.getItem(lsKeyMuted);
|
||||||
const newVideo = document.createElement('video');
|
var currentVolumeLS = localStorage.getItem(lsKeyVolume);
|
||||||
newVideo.volume = muted ? 0 : volume;
|
if (player?.core?.state) {
|
||||||
newVideo.playsInline = true;
|
localStorage.setItem(lsKeyMuted, JSON.stringify({default:player.core.state.muted}));
|
||||||
video.replaceWith(newVideo);
|
localStorage.setItem(lsKeyVolume, player.core.state.volume);
|
||||||
player.attachHTMLVideoElement(newVideo);
|
|
||||||
setImmediate(() => {
|
|
||||||
player.setVolume(volume);
|
|
||||||
player.setMuted(muted);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
playerState.setSrc({ isNewMediaPlayerInstance: true, refreshAccessToken: true });// ffz sets this false
|
if (player?.core?.state?.quality?.group) {
|
||||||
|
localStorage.setItem(lsKeyQuality, JSON.stringify({default:player.core.state.quality.group}));
|
||||||
|
}
|
||||||
|
playerState.setSrc({ isNewMediaPlayerInstance: true, refreshAccessToken: true });
|
||||||
|
setTimeout(() => {
|
||||||
|
localStorage.setItem(lsKeyQuality, currentQualityLS);
|
||||||
|
localStorage.setItem(lsKeyMuted, currentMutedLS);
|
||||||
|
localStorage.setItem(lsKeyVolume, currentVolumeLS);
|
||||||
|
}, 3000);
|
||||||
}
|
}
|
||||||
window.reloadTwitchPlayer = reloadTwitchPlayer;
|
window.reloadTwitchPlayer = reloadTwitchPlayer;
|
||||||
hookFetch();
|
hookFetch();
|
||||||
|
@ -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.20
|
// @version 1.21
|
||||||
// @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)
|
||||||
@ -260,6 +260,32 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
var lowResLines = encodingsM3u8.replace('\r', '').split('\n');
|
||||||
|
var lowResBestUrl = null;
|
||||||
|
for (var j = 0; j < lowResLines.length; j++) {
|
||||||
|
if (lowResLines[j].startsWith('#EXT-X-STREAM-INF')) {
|
||||||
|
var res = parseAttributes(lowResLines[j])['RESOLUTION'];
|
||||||
|
if (res && lowResLines[j + 1].endsWith('.m3u8')) {
|
||||||
|
// Assumes resolutions are correctly ordered
|
||||||
|
lowResBestUrl = lowResLines[j + 1];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (lowResBestUrl != null && streamInfo.Encodings != null) {
|
||||||
|
var normalEncodingsM3u8 = streamInfo.Encodings;
|
||||||
|
var normalLines = normalEncodingsM3u8.replace('\r', '').split('\n');
|
||||||
|
for (var j = 0; j < normalLines.length - 1; j++) {
|
||||||
|
if (normalLines[j].startsWith('#EXT-X-STREAM-INF')) {
|
||||||
|
var res = parseAttributes(normalLines[j])['RESOLUTION'];
|
||||||
|
if (res) {
|
||||||
|
lowResBestUrl += ' ';// The stream doesn't load unless each url line is unique
|
||||||
|
normalLines[j + 1] = lowResBestUrl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
encodingsM3u8 = normalLines.join('\r\n');
|
||||||
|
}
|
||||||
streamInfo.BackupEncodings = encodingsM3u8;
|
streamInfo.BackupEncodings = encodingsM3u8;
|
||||||
}
|
}
|
||||||
var lines = encodingsM3u8.replace('\r', '').split('\n');
|
var lines = encodingsM3u8.replace('\r', '').split('\n');
|
||||||
@ -522,22 +548,25 @@
|
|||||||
player.play();
|
player.play();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const sink = player.mediaSinkManager || (player.core ? player.core.mediaSinkManager : null);
|
const lsKeyQuality = 'video-quality';
|
||||||
if (sink && sink.video && sink.video._ffz_compressor) {
|
const lsKeyMuted = 'video-muted';
|
||||||
const video = sink.video;
|
const lsKeyVolume = 'volume';
|
||||||
const volume = video.volume ? video.volume : player.getVolume();
|
var currentQualityLS = localStorage.getItem(lsKeyQuality);
|
||||||
const muted = player.isMuted();
|
var currentMutedLS = localStorage.getItem(lsKeyMuted);
|
||||||
const newVideo = document.createElement('video');
|
var currentVolumeLS = localStorage.getItem(lsKeyVolume);
|
||||||
newVideo.volume = muted ? 0 : volume;
|
if (player?.core?.state) {
|
||||||
newVideo.playsInline = true;
|
localStorage.setItem(lsKeyMuted, JSON.stringify({default:player.core.state.muted}));
|
||||||
video.replaceWith(newVideo);
|
localStorage.setItem(lsKeyVolume, player.core.state.volume);
|
||||||
player.attachHTMLVideoElement(newVideo);
|
|
||||||
setImmediate(() => {
|
|
||||||
player.setVolume(volume);
|
|
||||||
player.setMuted(muted);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
playerState.setSrc({ isNewMediaPlayerInstance: true, refreshAccessToken: true });// ffz sets this false
|
if (player?.core?.state?.quality?.group) {
|
||||||
|
localStorage.setItem(lsKeyQuality, JSON.stringify({default:player.core.state.quality.group}));
|
||||||
|
}
|
||||||
|
playerState.setSrc({ isNewMediaPlayerInstance: true, refreshAccessToken: true });
|
||||||
|
setTimeout(() => {
|
||||||
|
localStorage.setItem(lsKeyQuality, currentQualityLS);
|
||||||
|
localStorage.setItem(lsKeyMuted, currentMutedLS);
|
||||||
|
localStorage.setItem(lsKeyVolume, currentVolumeLS);
|
||||||
|
}, 3000);
|
||||||
}
|
}
|
||||||
window.reloadTwitchPlayer = reloadTwitchPlayer;
|
window.reloadTwitchPlayer = reloadTwitchPlayer;
|
||||||
hookFetch();
|
hookFetch();
|
||||||
|
Loading…
Reference in New Issue
Block a user