Hide ratings on backloggd.com

10/2/2025, 22:34:48

// ==UserScript==
// @name        Hide ratings on backloggd.com
// @namespace   Violentmonkey Scripts
// @icon        https://www.backloggd.com/favicon.ico
// @match       https://backloggd.com/*
// @match       https://www.backloggd.com/*
// @run-at      document-start
// @grant       none
// @version     1.0.1
// @author      epicBlast
// @description 10/2/2025, 22:34:48
// @license     MIT
// ==/UserScript==

(function() {
    'use strict';

    // Selector for the target element
    const selectorParent = "#interaction-sidebar > div:nth-child(1) > div.col.col-sm-12.mt-3.mt-sm-5 > div > div.col-ms-12.col.col-sm-12.d-none.d-sm-flex > div > div > div"
    const selectorScore = "#score > h1";
    const selectorGraph = "#ratings-bars-height"

    function hideElements() {
        console.log("hideElements entry")
        let style = document.getElementById("hide-elements-style")
        if (!style) {
            style = document.createElement("style");
            style.id = "hide-elements-style";
            style.innerHTML = `${selectorScore}, ${selectorGraph} { display: none !important; }`;
            document.head.appendChild(style);
            console.log("style created")
        }
        else {
            style.innerHTML = `${selectorScore}, ${selectorGraph} { display: none !important; }`;
        }
    }

    function showElements() {
        console.log("showElements entry")
        const style = document.getElementById("hide-elements-style")
        if (!style) return;
        style.innerHTML = `
            ${selectorScore} { display: block; }
            ${selectorGraph} { display: flex; }
        `;
    }

    function toggleElements() {
        const style = document.getElementById("hide-elements-style");
        if (!style) return;

        if (style.innerHTML.includes("display: none !important")) {
            showElements();
        } else {
            hideElements();
        }
    }

    function removeStyle() {
        const existingStyle = document.getElementById("hide-elements-style");
        if (existingStyle) {
            existingStyle.remove();
        }
    }

    function addEye() {
        const parent = document.querySelector(selectorParent);
        if (!parent || parent.querySelector(".eye-toggle")) return;

        // Create an eye icon button
        const eyeIcon = document.createElement("button");
        eyeIcon.innerHTML = "👁";
        eyeIcon.className = "eye-toggle";
        eyeIcon.style.cursor = "pointer";
        eyeIcon.style.background = "none";
        eyeIcon.style.border = "none";
        eyeIcon.style.fontSize = "20px";
        eyeIcon.style.padding = "5px";

        // Insert the eye icon as the first child of the parent element
        parent.insertBefore(eyeIcon, parent.firstChild);

        // Toggle visibility on click
        eyeIcon.addEventListener("click", function() {
            toggleElements();
        });
    }

    function mainExecutor() {
        console.log("mainExecutor entry")
        if (document.querySelector('#user-info, #profile-sidebar')) {
            removeStyle();
        } else {
            const style = document.getElementById("hide-elements-style");
            if (!style) {
                hideElements();
            }
            addEye();
        }
    }

    function observePageChanges() {
        new MutationObserver(mutations => {
            if (!document.body.matches('#game-body, #user-info, #profile-sidebar') && !mutations.some(m => m.addedNodes.length)) return;
            mainExecutor();
        }).observe(document.documentElement, { childList: true, subtree: true });
    }

    observePageChanges();
    window.addEventListener("load", mainExecutor);
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址