mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-10 13:37:04 +03:00
Fixed channel whitelisting and channel finding on new YouTube layout.
This commit is contained in:
25
content.js
25
content.js
@@ -498,25 +498,20 @@ function updatePreviewBar() {
|
|||||||
|
|
||||||
function getChannelID() {
|
function getChannelID() {
|
||||||
//get channel id
|
//get channel id
|
||||||
let channelContainers = document.querySelectorAll(".ytd-channel-name#text");
|
let channelNameContainer = document.getElementById("channel-name");
|
||||||
let channelURLContainer = null;
|
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
|
//old YouTube theme
|
||||||
channelContainers = document.getElementsByClassName("yt-user-info");
|
let channelContainers = document.getElementsByClassName("yt-user-info");
|
||||||
if (channelContainers.length != 0) {
|
if (channelContainers.length != 0) {
|
||||||
channelURLContainer = channelContainers[0].firstElementChild;
|
channelURLContainer = channelContainers[0].firstElementChild;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (channelURLContainer == null) {
|
if (channelURLContainer === null) {
|
||||||
//try later
|
//try later
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -550,11 +545,9 @@ function whitelistCheck() {
|
|||||||
chrome.storage.sync.get(["whitelistedChannels"], function(result) {
|
chrome.storage.sync.get(["whitelistedChannels"], function(result) {
|
||||||
let whitelistedChannels = result.whitelistedChannels;
|
let whitelistedChannels = result.whitelistedChannels;
|
||||||
|
|
||||||
if (whitelistedChannels != undefined && whitelistedChannels.includes(channelURL)) {
|
console.log(channelURL)
|
||||||
//reset sponsor times to nothing
|
|
||||||
sponsorTimes = [];
|
|
||||||
UUIDs = [];
|
|
||||||
|
|
||||||
|
if (whitelistedChannels != undefined && whitelistedChannels.includes(channelURL)) {
|
||||||
channelWhitelisted = true;
|
channelWhitelisted = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -566,6 +559,8 @@ function sponsorCheck() {
|
|||||||
// Make sure this isn't called again
|
// Make sure this isn't called again
|
||||||
v.ontimeupdate = null;
|
v.ontimeupdate = null;
|
||||||
return;
|
return;
|
||||||
|
} else if (channelWhitelisted) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let skipHappened = false;
|
let skipHappened = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user