您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Adds 3 buttons on each YouTube profile under Videos (All videos + shorts, All videos, Shorts only)
当前为
// ==UserScript== // @name YouTube Autoplay Buttons. Adding “Play all videos” buttons back // @namespace http://tampermonkey.net/ // @version 0.3 // @description Adds 3 buttons on each YouTube profile under Videos (All videos + shorts, All videos, Shorts only) // @author Nieme // @match https://www.youtube.com/* // @grant none // @license GPLv2 // ==/UserScript== (function() { 'use strict'; function getChannelId() { let cId = null; if (typeof ytInitialData !== 'undefined') { cId = ytInitialData?.metadata?.channelMetadataRenderer?.externalId; } if (!cId) { cId = document.querySelector('.ytp-ce-link[href]')?.href?.split('/')?.pop() || document.querySelector('[itemprop="identifier"]')?.content; } return cId; } function addCustomButtons() { const chipsContainer = document.querySelector('ytd-feed-filter-chip-bar-renderer #chips'); if (chipsContainer && !document.querySelector('.custom-play-all-button')) { function createButton(text, playlistLinkGenerator) { const newButton = document.createElement('a'); newButton.style.marginLeft = '10px'; newButton.href = '#'; newButton.classList.add('custom-play-all-button'); // Behalte die yt-chip-cloud-chip-renderer Struktur bei const newChip = document.createElement('yt-chip-cloud-chip-renderer'); newChip.className = 'style-scope ytd-feed-filter-chip-bar-renderer'; newChip.setAttribute('modern', ''); newChip.setAttribute('aria-selected', 'false'); newChip.setAttribute('role', 'tab'); newChip.setAttribute('tabindex', '0'); newChip.setAttribute('chip-style', 'STYLE_DEFAULT'); const newText = document.createElement('span'); newText.textContent = text; newChip.appendChild(newText); newButton.appendChild(newChip); newButton.addEventListener('click', (e) => { e.preventDefault(); const cId = getChannelId(); if (cId) { const playlistLink = playlistLinkGenerator(cId); window.location.href = playlistLink; } else { console.error('Channel-ID konnte nicht abgerufen werden.'); } }); chipsContainer.appendChild(newButton); } createButton('Play Standard and Shorts together', (cId) => `https://www.youtube.com/playlist?list=UU${cId.slice(2)}`); createButton('Play Standard only', (cId) => `https://www.youtube.com/playlist?list=UULF${cId.slice(2)}`); createButton('Play Shorts only', (cId) => `https://www.youtube.com/playlist?list=UUSH${cId.slice(2)}`); } } function checkAndAddButtons() { if (window.location.pathname.includes('/videos')) { addCustomButtons(); } } // Stil sicherstellen für custom Buttons const style = document.createElement('style'); style.innerHTML = ` .custom-play-all-button { font-size: 14px; text-decoration: none; } .custom-play-all-button yt-chip-cloud-chip-renderer { display: inline-flex; align-items: center; padding: 0 12px; height: 36px; border-radius: 18px; background-color: #f1f1f1; color: #000; cursor: pointer; transition: background-color 0.3s ease; } .custom-play-all-button yt-chip-cloud-chip-renderer:hover { background-color: #e1e1e1; } `; document.head.appendChild(style); const observer = new MutationObserver(() => { checkAndAddButtons(); }); observer.observe(document, { childList: true, subtree: true }); let oldHref = document.location.href; setInterval(() => { const currentHref = document.location.href; if (oldHref !== currentHref) { oldHref = currentHref; checkAndAddButtons(); } }, 5000); })();