你正在訪問的內容是外部程式的映像位址,僅用於使用者加速訪問,本站無法保證其可靠性。當前的連結位址(單點即可複製)為 https://greasyfork.org.cn/zh-CN/scripts/445640-yt-video-tab-by-default/discussions/251081,源站連結 點此以跳轉。
Open "Video" tab of youtube channel by default
< 脚本 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);
}
};