Skip to content

Commit

Permalink
Fixed channel whitelisting and channel finding on new YouTube layout.
Browse files Browse the repository at this point in the history
  • Loading branch information
ajayyy committed Dec 14, 2019
1 parent b42bdc6 commit 8578e96
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions content.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
});
Expand All @@ -566,6 +559,8 @@ function sponsorCheck() {
// Make sure this isn't called again
v.ontimeupdate = null;
return;
} else if (channelWhitelisted) {
return;
}

let skipHappened = false;
Expand Down

0 comments on commit 8578e96

Please sign in to comment.