Greasy Fork

Greasy Fork is available in English.

Anilist Remove Hearts for Selected Users

Removes the heart icon for activities by selected users on the Anilist homepage only.

当前为 2024-11-25 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Anilist Remove Hearts for Selected Users
// @namespace    http://tampermonkey.net/
// @version      1.2
// @description  Removes the heart icon for activities by selected users on the Anilist homepage only.
// @author       DimitrovN
// @match        https://anilist.co/home
// @icon         https://www.google.com/s2/favicons?sz=64&domain=anilist.co
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Array of usernames whose heart icons should be removed
    const targetUsernames = ['YourUsername', 'User2', 'User3']; // Add or remove names here

    // Function to clean up modifications (reset state)
    function resetModifications() {
        document.querySelectorAll('.activity-entry').forEach(entry => {
            const userNameElement = entry.querySelector('.name');
            if (userNameElement && targetUsernames.includes(userNameElement.textContent.trim())) {
                // Restore any previously removed heart icons
                if (!entry.querySelector('svg[data-icon="heart"]')) {
                    const likeIconContainer = entry.querySelector('.like-icon-container'); // Adjust this selector if necessary
                    if (likeIconContainer) {
                        const svgHeart = document.createElementNS("http://www.w3.org/2000/svg", "svg");
                        svgHeart.setAttribute("data-icon", "heart");
                        svgHeart.setAttribute("fill", "currentColor");
                        svgHeart.setAttribute("class", "svg-inline--fa fa-heart fa-w-16 fa-sm");
                        likeIconContainer.appendChild(svgHeart);
                    }
                }
            }
        });
    }

    // Function to remove heart icons on the homepage
    function removeHeartIcons() {
        document.querySelectorAll('.activity-entry').forEach(entry => {
            const userNameElement = entry.querySelector('.name');
            if (userNameElement && targetUsernames.includes(userNameElement.textContent.trim())) {
                const heartIcon = entry.querySelector('svg[data-icon="heart"]');
                if (heartIcon) {
                    heartIcon.remove();
                }
            }
        });
    }

    // Observer to handle dynamic changes on the homepage
    const observer = new MutationObserver(() => {
        if (window.location.pathname === '/home') {
            removeHeartIcons();
        } else {
            resetModifications();
        }
    });

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

    // Cleanup observer when navigating away from the homepage
    window.addEventListener('popstate', () => {
        if (window.location.pathname !== '/home') {
            resetModifications();
        }
    });
})();