// if(document.URL.indexOf("youtube.com/@") >= 0 && document.URL.endsWith("featured") >= 0) {
function getChildIndex(node) {
return Array.prototype.indexOf.call(node.parentNode.childNodes, node);
}
function switchToVideos() {
console.log('Got tab switch event, checking if need to switch to videos');
let tabInd = getChildIndex(document.getElementsByClassName("style-scope ytd-c4-tabbed-header-renderer iron-selected")[0]);
if(document.URL.indexOf("youtube.com/@") >= 0
&& tabInd < 4) {
document.getElementById("tabsContent").children[3].click()
} else {
console.log('No need to switch. ind of @: ', document.URL.indexOf("youtube.com/@"),
'\nTab index: ', tabInd);
}
}
document.addEventListener("yt-navigate-finish", ()=>setTimeout(()=>switchToVideos(), 400));
Comments