您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Adds a button to remove all watched videos from the subscription page
当前为
- // ==UserScript==
- // @name YouTube - Remove watched videos button
- // @description Adds a button to remove all watched videos from the subscription page
- // @author MetalTxus
- // @version 1.0.5
- // @icon https://www.youtube.com/favicon.ico
- // @match https://www.youtube.com/*
- // @namespace https://github.com/jesuscc1993/user-js
- // @require https://code.jquery.com/jquery-3.2.1.min.js
- // ==/UserScript==
- /* globals jQuery */
- (() => {
- 'use strict';
- const shouldRender = () => {
- return location.href.includes('/subscriptions') || location.href.includes('/videos') || location.href.includes('/results');
- }
- const removeWatchedVideos = () => {
- const watchedVideos = jQuery('[id="progress"]').parents('ytd-grid-video-renderer, ytd-video-renderer');
- watchedVideos.remove();
- const videousLeft = jQuery('ytd-grid-video-renderer, ytd-video-renderer');
- buttonElement.text(`Remove Watched (${watchedVideos.length} videos removed / ${videousLeft.length} videos left)`)
- }
- const buttonElement = jQuery(`
- <tp-yt-paper-button class="style-scope ytd-subscribe-button-renderer" style="margin-top: 24px;">
- Remove Watched
- </tp-yt-paper-button>
- `);
- const handleButtonPresence = () => {
- if (shouldRender()) {
- const gridContainerElement = jQuery('ytd-section-list-renderer, ytd-shelf-renderer, ytd-browse:first ytd-two-column-browse-results-renderer #primary #header-container').first();
- if (gridContainerElement.length && !gridContainerElement.find(buttonElement).length) {
- buttonElement.click(removeWatchedVideos);
- gridContainerElement.prepend(buttonElement);
- }
- } else {
- buttonElement.remove();
- }
- };
- setInterval(handleButtonPresence, 150);
- })();