DE Item Tooltips

Change color of specific text

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         DE Item Tooltips
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Change color of specific text
// @author       BingGPT + NeKpoT
// @match        *://dungeoneyes.com/*
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    // Function to trim image name
    function trimImageName(src) {
        if (!src) return null; // Return null if src is undefined

        var imageName = src.split('/').pop(); // Get the file name
        imageName = imageName.replace(/\.[^/.]+$/, ""); // Remove extension
        imageName = imageName.replace(/[0-9A-Z]+$/, ""); // Remove trailing digits and capital letters
        return imageName;
    }

    // Function to process item description
    function processItemDescription(itemDescription) {
        var itemName = itemDescription.find('strong').text();
        var itemType = itemDescription.find('em').text();
        var itemEffect = itemDescription.contents().filter(function() {
            return this.nodeType === 3; // Node.TEXT_NODE
        }).get(0).nodeValue.trim();
        var itemWeightValue = itemDescription.contents().filter(function() {
            return this.nodeType === 3; // Node.TEXT_NODE
        }).get(1).nodeValue.trim();
        return itemName + '\n' + itemType + '\n' + itemEffect + '\n' + itemWeightValue;
    }

    // Fetch the item descriptions page
    jQuery.get('/items', function(data) {
        var itemDescriptions = jQuery(data).find('p');

        // Add mouseover event to each image
        jQuery('img').on('mouseover', function() {
            var src = trimImageName(jQuery(this).attr('src'));
            if (!src || !src.startsWith('ITEM')) return; // Skip if src is undefined or does not start with 'ITEM'

            var itemDescription;

            // Find the matching item description
            itemDescriptions.each(function() {
                var itemImgSrc = trimImageName(jQuery(this).find('img').attr('src'));
                if (itemImgSrc && itemImgSrc === src) {
                    itemDescription = jQuery(this);
                    return false; // break the loop
                }
            });

            if (itemDescription) {
                // Process the item description and show the tooltip
                jQuery(this).attr('title', processItemDescription(itemDescription));
            }
        });
    });

})();