Greasy Fork is available in English.
Open "Video" tab of youtube channel by default
< Spätná väzba na YT video tab by default
Yes, it looks nice, but it has two problems:
1. It works only with English language of UI.
2. It does not pause preview video on Home tab.
I made ur script readable
// Monitor URL and DOM changes
const rootNode = document.querySelector("body");
if (rootNode) {
var urlAtLastCheck = "";
new MutationObserver(() => {
if (urlAtLastCheck !== document.location.href) {
urlAtLastCheck = document.location.href;
clickVideoTab();
}
}).observe(rootNode, { childList: true, subtree: true });
}
// Check if URL is a YouTube channel page
function isChannelPage(url) {
return /^https:\/\/www\.youtube\.com\/@[^\/]+$/.test(url);
}
// Find and click the "videos" tab on a channel page
function clickVideoTab() {
if (isChannelPage(window.location.href)) {
const intervalId = setInterval(() => {
const divTabs = document.querySelectorAll("div#tabsContainer > div#tabsContent yt-tab-shape, div#tabsContainer > div#tabsContent tp-yt-paper-tab");
let videoTab = null;
// Loop through the tabs to find the one with the text "videos"
for (let i = 0; i < divTabs.length; i++) {
if (divTabs[i].innerText.toLowerCase() === "videos") {
videoTab = divTabs[i];
break;
}
}
if (videoTab) {
videoTab.click();
clearInterval(intervalId);
}
}, 100);
}
};