Greasy Fork

Greasy Fork is available in English.

Bangumi排行榜隐藏已收藏条目

排行榜隐藏已收藏条目

当前为 2024-08-26 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Bangumi排行榜隐藏已收藏条目
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  排行榜隐藏已收藏条目
// @author       KunimiSaya
// @match        https://bgm.tv/*/browser*
// @match        https://bangumi.tv/*/browser*
// @match        https://chii.in/*/browser*
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    // Function to hide collected items
    function hideCollectedItems() {
        // Select all items
        let items = document.querySelectorAll('.item');

        items.forEach(function(item) {
            // Check if the item is collected by looking for the "collectModify" element
            if (item.querySelector('.collectModify')) {
                // Hide the item
                item.style.display = 'none';
            }
        });
    }

    // Initial hiding of collected items
    hideCollectedItems();

    // Observe the page for any new nodes being added
    let observer = new MutationObserver(function(mutations) {
        mutations.forEach(function(mutation) {
            if (mutation.addedNodes.length) {
                hideCollectedItems();
            }
        });
    });

    // Start observing the body for changes
    observer.observe(document.body, {
        childList: true, // Detect when new elements are added or removed
        subtree: true    // Observe all nodes, not just the direct children of the body
    });
})();