Crunchyroll Watchlist

Hide watched animes so it is easier to spot new episodes

当前为 2022-01-02 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Crunchyroll Watchlist
// @version      1
// @description  Hide watched animes so it is easier to spot new episodes
// @match        https://beta.crunchyroll.com/*
// @icon         https://www.google.com/s2/favicons?domain=crunchyroll.com
// @grant        none
// @namespace   https://greasyfork.org/users/206408
// ==/UserScript==

(function() {
    'use strict';

    // Your code here...
    function l(...args){
        console.log('[Watchlist]', ...args)
    }

    function filter(){
        let container = document.querySelector("#content > div > div.app-body-wrapper > div > div > div.erc-watchlist > div.watchlist-body > div:nth-child(1) > div > div")
        for(let row of container.children){
            row = row.children[0]
            for(let item of row.children){
                let card = item.querySelector('.c-watchlist-card')
                if(card){ //not a loading placeholder
                    let subtitle = card.querySelector('.c-watchlist-card__subtitle').textContent
                    if(subtitle.includes('Watch Again')){
                        //Do something with animes watched
                        card.style.filter = 'brightness(0.1)'
                    }
                }
            }
        }
    }

    //Observe changes to the DOM since there are no events that can be used
    const observer = new MutationObserver((mutationsList, observer) => {
        if(window.location.href === 'https://beta.crunchyroll.com/watchlist'){
            for(const mutation of mutationsList){
                //Items added to the watchlist grid
                if(['ReactVirtualized__Grid__innerScrollContainer', 'ReactVirtualized__Grid ReactVirtualized__List'].includes(mutation.target.className)){
                    filter()
                }
            }
        }
    })

    observer.observe(document, {subtree:true, childList:true, attributes:true})
})();