Remove "Feed" from Genius

This Tampermonkey script removes the feed button from Genius.com and allows you to easily toggle the removal on or off through the Tampermonkey menu

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Remove "Feed" from Genius
// @namespace    http://tampermonkey.net/
// @version      1.0.1
// @description  This Tampermonkey script removes the feed button from Genius.com and allows you to easily toggle the removal on or off through the Tampermonkey menu
// @author       Fri
// @license MIT
// @match        https://genius.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=genius.com
// @grant        GM_registerMenuCommand
// @grant        GM_unregisterMenuCommand
// @grant        GM_setValue
// @grant        GM_getValue
// ==/UserScript==

(function() {
    'use strict';

    // Default option to remove elements (enabled)
    let isEnabled = GM_getValue('removeElements', true);

    // Function to toggle the element removal option
    function toggleRemoval() {
        isEnabled = !isEnabled;
        GM_setValue('removeElements', isEnabled);
        alert(`Element removal is now ${isEnabled ? 'ENABLED' : 'DISABLED'}.`);
        location.reload();
        updateMenu();
    }

    // Update the Tampermonkey menu
    function updateMenu() {
        GM_unregisterMenuCommand('toggleRemoval');
        GM_registerMenuCommand(`Disable removal (Currently: ${isEnabled ? 'ENABLED' : 'DISABLED'})`, toggleRemoval, 't');
    }

    // Register the initial menu
    updateMenu();

    // Wait until the page has fully loaded
    window.addEventListener('load', function() {
        if (!isEnabled) {
            console.log('Feed removal is disabled.');
            return;
        }

        // Try remove the feed in bagon pages
        var bagon = document.querySelector('inbox-icon[inbox-name="newsfeed_inbox"]');
        if (bagon) {
            bagon.remove();
            console.log('Removed in bagon.');
        }

        // Try remove the feed in react pages if there are at least 5 elements in total
        var reactItems = document.querySelectorAll("div.StickyNavLoggedIn__Item-sc-1lrodac-0");
        if (reactItems.length >= 5) {
            reactItems[1].remove();
            console.log('Removed in react.');
        }

        //Try remove the feed in the main page (genius.com/)
        var mainItems = document.querySelectorAll("div.PageHeaderLoggedIn__Item-on81eb-0 ");
               if (mainItems.length >= 5) {
            mainItems[1].remove();
            console.log('Removed in main page.');
        }

    }, false);

})();