mirror of
https://github.com/pixeltris/TwitchAdSolutions.git
synced 2024-11-25 11:52:52 +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.ClientVersion = 'null';
|
||||
scope.ClientSession = 'null';
|
||||
//scope.PlayerType1 = 'site'; //Source - NOTE: This is unused as it's implicitly used by the website iself
|
||||
scope.PlayerType2 = 'autoplay'; //360p
|
||||
scope.PlayerType3 = 'embed'; //Source
|
||||
//scope.PlayerType4 = 'embed'; //Source
|
||||
scope.PlayerType2 = 'embed'; //Source
|
||||
scope.PlayerType3 = 'autoplay'; //360p
|
||||
scope.CurrentChannelName = null;
|
||||
scope.UsherParams = null;
|
||||
scope.WasShowingAd = false;
|
||||
@ -284,9 +282,6 @@ twitch-videoad.js text/javascript
|
||||
if (weaverText.includes(AdSignifier)) {
|
||||
weaverText = await processM3U8(url, responseText, realFetch, PlayerType3);
|
||||
}
|
||||
//if (weaverText.includes(AdSignifier)) {
|
||||
// weaverText = await processM3U8(url, responseText, realFetch, PlayerType4);
|
||||
//}
|
||||
resolve(new Response(weaverText));
|
||||
};
|
||||
var send = function() {
|
||||
|
@ -1,7 +1,7 @@
|
||||
// ==UserScript==
|
||||
// @name TwitchAdSolutions (vaft)
|
||||
// @namespace https://github.com/pixeltris/TwitchAdSolutions
|
||||
// @version 5.8.3
|
||||
// @version 5.8.4
|
||||
// @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
|
||||
@ -68,10 +68,8 @@
|
||||
scope.ClientID = 'kimne78kx3ncx6brgo4mv6wki5h1ko';
|
||||
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 = 'autoplay'; //360p
|
||||
scope.PlayerType3 = 'embed'; //Source
|
||||
//scope.PlayerType4 = 'embed'; //Source
|
||||
scope.PlayerType2 = 'embed'; //Source
|
||||
scope.PlayerType3 = 'autoplay'; //360p
|
||||
scope.CurrentChannelName = null;
|
||||
scope.UsherParams = null;
|
||||
scope.WasShowingAd = false;
|
||||
@ -295,9 +293,6 @@
|
||||
if (weaverText.includes(AdSignifier)) {
|
||||
weaverText = await processM3U8(url, responseText, realFetch, PlayerType3);
|
||||
}
|
||||
//if (weaverText.includes(AdSignifier)) {
|
||||
// weaverText = await processM3U8(url, responseText, realFetch, PlayerType4);
|
||||
//}
|
||||
resolve(new Response(weaverText));
|
||||
};
|
||||
var send = function() {
|
||||
|
@ -249,6 +249,32 @@ twitch-videoad.js text/javascript
|
||||
return;
|
||||
}
|
||||
} 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;
|
||||
}
|
||||
var lines = encodingsM3u8.replace('\r', '').split('\n');
|
||||
@ -511,22 +537,25 @@ twitch-videoad.js text/javascript
|
||||
player.play();
|
||||
return;
|
||||
}
|
||||
const sink = player.mediaSinkManager || (player.core ? player.core.mediaSinkManager : null);
|
||||
if (sink && sink.video && sink.video._ffz_compressor) {
|
||||
const video = sink.video;
|
||||
const volume = video.volume ? video.volume : player.getVolume();
|
||||
const muted = player.isMuted();
|
||||
const newVideo = document.createElement('video');
|
||||
newVideo.volume = muted ? 0 : volume;
|
||||
newVideo.playsInline = true;
|
||||
video.replaceWith(newVideo);
|
||||
player.attachHTMLVideoElement(newVideo);
|
||||
setImmediate(() => {
|
||||
player.setVolume(volume);
|
||||
player.setMuted(muted);
|
||||
});
|
||||
const lsKeyQuality = 'video-quality';
|
||||
const lsKeyMuted = 'video-muted';
|
||||
const lsKeyVolume = 'volume';
|
||||
var currentQualityLS = localStorage.getItem(lsKeyQuality);
|
||||
var currentMutedLS = localStorage.getItem(lsKeyMuted);
|
||||
var currentVolumeLS = localStorage.getItem(lsKeyVolume);
|
||||
if (player?.core?.state) {
|
||||
localStorage.setItem(lsKeyMuted, JSON.stringify({default:player.core.state.muted}));
|
||||
localStorage.setItem(lsKeyVolume, player.core.state.volume);
|
||||
}
|
||||
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;
|
||||
hookFetch();
|
||||
|
@ -1,7 +1,7 @@
|
||||
// ==UserScript==
|
||||
// @name TwitchAdSolutions (video-swap-new)
|
||||
// @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
|
||||
// @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)
|
||||
@ -260,6 +260,32 @@
|
||||
return;
|
||||
}
|
||||
} 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;
|
||||
}
|
||||
var lines = encodingsM3u8.replace('\r', '').split('\n');
|
||||
@ -522,22 +548,25 @@
|
||||
player.play();
|
||||
return;
|
||||
}
|
||||
const sink = player.mediaSinkManager || (player.core ? player.core.mediaSinkManager : null);
|
||||
if (sink && sink.video && sink.video._ffz_compressor) {
|
||||
const video = sink.video;
|
||||
const volume = video.volume ? video.volume : player.getVolume();
|
||||
const muted = player.isMuted();
|
||||
const newVideo = document.createElement('video');
|
||||
newVideo.volume = muted ? 0 : volume;
|
||||
newVideo.playsInline = true;
|
||||
video.replaceWith(newVideo);
|
||||
player.attachHTMLVideoElement(newVideo);
|
||||
setImmediate(() => {
|
||||
player.setVolume(volume);
|
||||
player.setMuted(muted);
|
||||
});
|
||||
const lsKeyQuality = 'video-quality';
|
||||
const lsKeyMuted = 'video-muted';
|
||||
const lsKeyVolume = 'volume';
|
||||
var currentQualityLS = localStorage.getItem(lsKeyQuality);
|
||||
var currentMutedLS = localStorage.getItem(lsKeyMuted);
|
||||
var currentVolumeLS = localStorage.getItem(lsKeyVolume);
|
||||
if (player?.core?.state) {
|
||||
localStorage.setItem(lsKeyMuted, JSON.stringify({default:player.core.state.muted}));
|
||||
localStorage.setItem(lsKeyVolume, player.core.state.volume);
|
||||
}
|
||||
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;
|
||||
hookFetch();
|
||||
|
Loading…
Reference in New Issue
Block a user