Merge branch 'master' of https://github.com/ajayyy/SponsorBlock into improvements

This commit is contained in:
Ajay Ramachandran
2021-06-18 00:46:55 -04:00
23 changed files with 482 additions and 848 deletions

View File

@@ -22,10 +22,11 @@ class SkipNotice {
this.contentContainer = contentContainer;
//get reference node
let referenceNode = document.getElementById("player-container-id")
let referenceNode = document.getElementById("player-container-id")
?? document.getElementById("movie_player")
?? document.querySelector("#main-panel.ytmusic-player-page") // YouTube music
?? document.querySelector("#player-container .video-js") // Invidious
?? document.querySelector(".main-video-section > .video-container"); // Cloudtube
?? document.querySelector(".main-video-section > .video-container"); // Cloudtube
if (referenceNode == null) {
//for embeds
const player = document.getElementById("player");
@@ -33,16 +34,13 @@ class SkipNotice {
let index = 1;
//find the child that is the video player (sometimes it is not the first)
while (!referenceNode.classList.contains("html5-video-player") || !referenceNode.classList.contains("ytp-embed")) {
while (index < player.children.length && (!referenceNode.classList.contains("html5-video-player") || !referenceNode.classList.contains("ytp-embed"))) {
referenceNode = player.children[index] as HTMLElement;
index++;
}
}
// YouTube Music
if (new URL(document.URL).host === "music.youtube.com") {
referenceNode = document.querySelector("#main-panel.ytmusic-player-page");
}
const amountOfPreviousNotices = document.getElementsByClassName("sponsorSkipNotice").length;
//this is the suffix added at the end of every id