您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Automatically selects "Recently uploaded" on the YouTube homepage.
// ==UserScript== // @name Reposition and Click Recently Uploaded Chip // @namespace http://tampermonkey.net/ // @version 1.5 // @description Automatically selects "Recently uploaded" on the YouTube homepage. // @author Simon Jones // @match https://www.youtube.com/* // @icon https://www.google.com/s2/favicons?domain=youtube.com // @grant none // @license MIT // ==/UserScript== (function() { 'use strict'; function debounce(func) { let timer; return (...args) => { clearTimeout(timer); timer = setTimeout(() => func.apply(this, args), 300); }; } const updateAndClickRecentlyUploaded = debounce(() => { // Ensure we are on the main YouTube homepage if (window.location.pathname !== '/') { return; } const chips = [...document.querySelectorAll('iron-selector.ytd-feed-filter-chip-bar-renderer yt-chip-cloud-chip-renderer')]; if (chips.length === 0) { return; } const recentlyUploadedChip = chips.find(chip => chip.innerText.includes('Recently uploaded')); const allChip = chips.find(chip => chip.innerText.includes('All')); // Check if the "All" chip is currently selected and the "Recently uploaded" chip is not const shouldClick = allChip && allChip.hasAttribute('selected') && recentlyUploadedChip && !recentlyUploadedChip.hasAttribute('selected'); if (shouldClick) { // Move the chip to the front const parent = recentlyUploadedChip.parentNode; parent.prepend(recentlyUploadedChip); // Simulate a click on the "Recently uploaded" chip recentlyUploadedChip.click(); } }); // Set up the mutation observer const observer = new MutationObserver(updateAndClickRecentlyUploaded); // Start observing the entire document for changes observer.observe(document, { childList: true, subtree: true }); })();