Infinite Craft Rarity Highlighter

Highlight words with rarity based on difficulty when dragged out of the panel

目前為 2025-01-22 提交的版本,檢視 最新版本

// ==UserScript==
// @name         Infinite Craft Rarity Highlighter
// @namespace    http://tampermonkey.net/
// @version      1.9
// @description  Highlight words with rarity based on difficulty when dragged out of the panel
// @author       carbonara crab
// @license      MIT
// @match        https://neal.fun/infinite-craft/
// @grant        none
// @run-at       document-end
// ==/UserScript==

(function() {
    'use strict';

    function getRarity(textLength) {
        if (textLength <= 30) return 'common';
        if (textLength <= 55) return 'uncommon';
        if (textLength <= 75) return 'rare';
        if (textLength <= 98) return 'epic';
        if (textLength <= 120) return 'legendary';
        return 'exotic';
    }

    function getColor(rarity) {
        const colors = {
            common: 'white',
            uncommon: 'lightgreen',
            rare: 'cornflowerblue',
            epic: 'plum',
            legendary: 'gold',
            exotic: 'cyan'
        };
        return colors[rarity] || 'black';
    }

    function highlightElement(element) {
        const textContent = element.textContent.trim();
        if (textContent) {
            const rarity = getRarity(textContent.length);
            element.style.color = getColor(rarity);
        }
    }

    const observer = new MutationObserver((mutations) => {
        mutations.forEach((mutation) => {
            mutation.addedNodes.forEach((node) => {
                if (node.nodeType === Node.ELEMENT_NODE && node.classList.contains('instance')) {
                    highlightElement(node);
                }
            });
        });
    });

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

QingJ © 2025

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