Greasy Fork

Greasy Fork is available in English.

Crunchyroll Hide Watch Again

Hides watched shows on Crunchyroll's watchlist and adds a toggleable list of hidden shows

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Crunchyroll Hide Watch Again
// @version      1.0
// @author       Jacob Capper
// @description  Hides watched shows on Crunchyroll's watchlist and adds a toggleable list of hidden shows
// @match        https://www.crunchyroll.com/watchlist
// @grant        none
// @license      MIT
// @namespace http://greasyfork.icu/users/1016996
// ==/UserScript==

(function () {
    'use strict';

    // Array to store hidden shows
    let hiddenShows = [];

    // Create the UI container
    function createUI() {
        const uiContainer = document.createElement('div');
        uiContainer.id = 'watchlist-hider-ui';
        uiContainer.style.position = 'fixed';
        uiContainer.style.bottom = '10px';
        uiContainer.style.right = '10px';
        uiContainer.style.backgroundColor = 'rgba(0, 0, 0, 0.8)';
        uiContainer.style.color = '#fff';
        uiContainer.style.padding = '10px';
        uiContainer.style.borderRadius = '5px';
        uiContainer.style.fontFamily = 'Arial, sans-serif';
        uiContainer.style.fontSize = '14px';
        uiContainer.style.maxWidth = '300px';
        uiContainer.style.zIndex = '1000';
        uiContainer.innerHTML = `
            <div style="margin-bottom: 5px;">
                <strong>Hidden Shows</strong>
                <button id="toggle-hidden" style="float: right; background: #fff; color: #000; border: none; padding: 2px 5px; border-radius: 3px; cursor: pointer;">Show</button>
            </div>
            <ul id="hidden-list" style="display: none; list-style: none; padding: 0; max-height: 150px; overflow-y: auto;"></ul>
        `;
        document.body.appendChild(uiContainer);

        // Toggle button functionality
        document.getElementById('toggle-hidden').addEventListener('click', () => {
            const hiddenList = document.getElementById('hidden-list');
            const button = document.getElementById('toggle-hidden');
            if (hiddenList.style.display === 'none') {
                hiddenList.style.display = 'block';
                button.textContent = 'Hide';
            } else {
                hiddenList.style.display = 'none';
                button.textContent = 'Show';
            }
        });
    }

    // Function to add a show to the hidden list
    function addToHiddenList(title) {
        if (!hiddenShows.includes(title)) {
            hiddenShows.push(title);
            const listItem = document.createElement('li');
            listItem.textContent = title;
            document.getElementById('hidden-list').appendChild(listItem);
        }
    }

    // Function to filter and hide watched shows
    function hideWatchedShows() {
        const cards = document.querySelectorAll('div.watchlist-card--YfKgo[data-t="watch-list-card"]');
        if (!cards.length) {
            console.log('[Watchlist Hider] No cards found.');
            return;
        }

        cards.forEach((card) => {
            const subtitleElement = card.querySelector('h5.watchlist-card-subtitle--IROsU');
            const titleElement = card.querySelector('h4.watchlist-card-title__text--chGlt');
            if (subtitleElement && titleElement) {
                const subtitleText = subtitleElement.textContent || '';
                const titleText = titleElement.textContent || '';
                console.log('[Watchlist Hider] Subtitle:', subtitleText);

                if (subtitleText.includes('Watch Again')) {
                    console.log('[Watchlist Hider] Hiding card:', card);
                    card.style.display = 'none'; // Hide the card
                    addToHiddenList(titleText); // Add to the hidden list
                }
            }
        });
    }

    // Mutation observer to handle dynamic loading
    const observer = new MutationObserver(() => {
        console.log('[Watchlist Hider] DOM updated, re-filtering watched shows.');
        hideWatchedShows();
    });

    // Start observing the page for changes
    observer.observe(document.body, { childList: true, subtree: true });

    // Initial run
    createUI();
    hideWatchedShows();
})();