diff options
author | Ajay Ramachandran <[email protected]> | 2019-12-13 23:21:21 -0500 |
---|---|---|
committer | Ajay Ramachandran <[email protected]> | 2019-12-13 23:21:21 -0500 |
commit | 8578e96c3a9fa4433c4bd6c99ae49881a735cc40 (patch) | |
tree | 89c6f162fd69ff5599b9947e80517dc8b899b544 | |
parent | b42bdc6e6f21eb76ea8afe5b7983d049f173d314 (diff) | |
download | SponsorBlock-8578e96c3a9fa4433c4bd6c99ae49881a735cc40.tar.gz SponsorBlock-8578e96c3a9fa4433c4bd6c99ae49881a735cc40.zip |
Fixed channel whitelisting and channel finding on new YouTube layout.
-rw-r--r-- | content.js | 25 |
1 files changed, 10 insertions, 15 deletions
@@ -498,25 +498,20 @@ function updatePreviewBar() { function getChannelID() { //get channel id - let channelContainers = document.querySelectorAll(".ytd-channel-name#text"); - let channelURLContainer = null; + let channelNameContainer = document.getElementById("channel-name"); + let channelURLContainer = channelNameContainer.querySelector("#container").querySelector("#text-container").querySelector("#text").firstElementChild; + - for (let i = 0; i < channelContainers.length; i++) { - let child = channelContainers[i].firstElementChild; - if (child != null && child.getAttribute("href") != "") { - channelURLContainer = child; - } - } - if (channelContainers.length == 0) { + if (channelURLContainer === null) { //old YouTube theme - channelContainers = document.getElementsByClassName("yt-user-info"); + let channelContainers = document.getElementsByClassName("yt-user-info"); if (channelContainers.length != 0) { channelURLContainer = channelContainers[0].firstElementChild; } } - if (channelURLContainer == null) { + if (channelURLContainer === null) { //try later return false; } @@ -550,11 +545,9 @@ function whitelistCheck() { chrome.storage.sync.get(["whitelistedChannels"], function(result) { let whitelistedChannels = result.whitelistedChannels; - if (whitelistedChannels != undefined && whitelistedChannels.includes(channelURL)) { - //reset sponsor times to nothing - sponsorTimes = []; - UUIDs = []; + console.log(channelURL) + if (whitelistedChannels != undefined && whitelistedChannels.includes(channelURL)) { channelWhitelisted = true; } }); @@ -566,6 +559,8 @@ function sponsorCheck() { // Make sure this isn't called again v.ontimeupdate = null; return; + } else if (channelWhitelisted) { + return; } let skipHappened = false; |