FurAffinity - Tags on Hover

Shows tags as tooltip when hovering over submissions

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         FurAffinity - Tags on Hover
// @namespace    Tampermonkey
// @version      2025-11-25
// @description  Shows tags as tooltip when hovering over submissions
// @author       CameronsAccount
// @match        *://*.furaffinity.net/*
// @icon         https://www.furaffinity.net/themes/beta/img/banners/fa_logo.png
// @grant        GM_getValue
// @grant        GM_setValue
// @grant        GM_registerMenuCommand
// @grant        GM_unregisterMenuCommand
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    let useNewlines = GM_getValue('useNewlines', false);
    let menuCommandId = null;

    function updateTags() {
        const images = document.querySelectorAll('img[data-tags]');
        images.forEach(img => {
            const tags = img.getAttribute('data-tags');
            if (tags) {
                const formattedTags = tags.replace(/\s+/g, useNewlines ? '\n' : ', ');
                const existingTitle = img.getAttribute('title');

                if (!img.hasAttribute('data-original-title')) {
                    img.setAttribute('data-original-title', existingTitle || '');
                }

                const originalTitle = img.getAttribute('data-original-title');

                if (originalTitle) {
                    img.setAttribute('title', originalTitle + '\n\n' + formattedTags);
                } else {
                    img.setAttribute('title', formattedTags);
                }
            }
        });
    }

    function registerMenu() {
        if (menuCommandId !== null) {
            GM_unregisterMenuCommand(menuCommandId);
        }
        menuCommandId = GM_registerMenuCommand(
            useNewlines ? 'Switch to comma-separated' : 'Switch to newline-separated',
            () => {
                useNewlines = !useNewlines;
                GM_setValue('useNewlines', useNewlines);
                updateTags();
                registerMenu();
            }
        );
    }

    window.addEventListener('storage', (e) => {
        if (e.key === 'useNewlines') {
            useNewlines = GM_getValue('useNewlines', false);
            updateTags();
            registerMenu();
        }
    });

    registerMenu();
    updateTags();
})();