Add UserScript files, and dyn-skip solution

This commit is contained in:
pixeltris
2020-12-25 20:11:28 +00:00
parent 3d7a8514e1
commit f7d76f52a8
9 changed files with 1540 additions and 47 deletions
+51 -41
View File
@@ -99,7 +99,7 @@ twitch-videoad.js application/javascript
if (liveVid.length) {
disabledVideo = liveVid = liveVid[0];
if (!disabledVideo) {
console.log('skipppp');
//console.log('skipppp');
return;
}
//mute
@@ -141,9 +141,8 @@ twitch-videoad.js application/javascript
tempVideo = document.createElement('video');
tempVideo.autoplay = true;
tempVideo.volume = originalVolume;
console.log(disabledVideo);
//console.log(disabledVideo);
disabledVideo.parentElement.insertBefore(tempVideo, disabledVideo.nextSibling);
console.log('123');
if (Hls.isSupported()) {
tempVideo.hls = new Hls();
tempVideo.hls.loadSource(tempM3u8);
@@ -157,49 +156,60 @@ twitch-videoad.js application/javascript
}
}
}
window.addEventListener("DOMContentLoaded", function() {
function checkForAd() {
//check ad by looking for text banner
var adBanner = document.querySelectorAll("span.tw-c-text-overlay");
var foundAd = false;
for (var i = 0; i < adBanner.length; i++) {
if (adBanner[i].attributes["data-test-selector"]) {
foundAd = true;
foundBannerPrev = true;
break;
}
function checkForAd() {
//check ad by looking for text banner
var adBanner = document.querySelectorAll("span.tw-c-text-overlay");
var foundAd = false;
for (var i = 0; i < adBanner.length; i++) {
if (adBanner[i].attributes["data-test-selector"]) {
foundAd = true;
foundBannerPrev = true;
break;
}
if (tempVideo && disabledVideo && tempVideo.paused != disabledVideo.paused) {
if (disabledVideo.paused) {
tempVideo.pause();
} else {
tempVideo.play();
}
}
if (foundAd && typeof Hls !== 'undefined') {
onFoundAd();
} else if (!foundAd && foundBannerPrev) {
//if no ad and video blacked out, unmute and disable black out
if (disabledVideo) {
disabledVideo.volume = originalVolume;
disabledVideo.style.filter = "";
disabledVideo = null;
foundAdContainer = false;
foundBannerPrev = false;
if (tempVideo) {
tempVideo.hls.stopLoad();
tempVideo.remove();
tempVideo = null;
}
}
}
setTimeout(checkForAd,100);
}
checkForAd();
if (tempVideo && disabledVideo && tempVideo.paused != disabledVideo.paused) {
if (disabledVideo.paused) {
tempVideo.pause();
} else {
tempVideo.play();//TODO: Fix issue with Firefox
}
}
if (foundAd && typeof Hls !== 'undefined') {
onFoundAd();
} else if (!foundAd && foundBannerPrev) {
//if no ad and video blacked out, unmute and disable black out
if (disabledVideo) {
disabledVideo.volume = originalVolume;
disabledVideo.style.filter = "";
disabledVideo = null;
foundAdContainer = false;
foundBannerPrev = false;
if (tempVideo) {
tempVideo.hls.stopLoad();
tempVideo.remove();
tempVideo = null;
}
}
}
setTimeout(checkForAd,100);
}
function dynOnContentLoaded() {
if (typeof Hls === 'undefined') {
var script = document.createElement('script');
script.src = "https://cdn.jsdelivr.net/npm/hls.js@latest";
script.onload = function() {
checkForAd();
}
document.head.appendChild(script);
} else {
checkForAd();
}
});
}
if (document.readyState === "complete" || document.readyState === "loaded" || document.readyState === "interactive") {
dynOnContentLoaded();
} else {
window.addEventListener("DOMContentLoaded", function() {
dynOnContentLoaded();
});
}
})();