IdleHacking - Cursor Cleanup

Keep normal text as arrow cursor while preserving pointer cursor on interactive game UI.

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

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

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

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

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

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

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

Advertisement:

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

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

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

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

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

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

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

Advertisement:

// ==UserScript==
// @name         IdleHacking - Cursor Cleanup
// @namespace    https://greasyfork.org/
// @version      1.02
// @description  Keep normal text as arrow cursor while preserving pointer cursor on interactive game UI.
// @match        https://www.idlehacking.com/*
// @grant        none
// @run-at       document-idle
// ==/UserScript==

(function () {
    'use strict';

    if (window.__idlehackingCursorCleanupInstalled) return;
    window.__idlehackingCursorCleanupInstalled = true;

    const STYLE_ID = 'idlehacking-cursor-cleanup-style';

    function installStyle() {
        if (document.getElementById(STYLE_ID)) return;

        const style = document.createElement('style');
        style.id = STYLE_ID;
        style.textContent = `
            /* Default everything non-editable to normal arrow */
            *:not(input):not(textarea):not(select):not(option):not(button):not(a):not([contenteditable="true"]) {
                cursor: default !important;
            }

            /* Preserve hand cursor on interactive elements */
            a,
            button,
            select,
            option,
            [role="button"],
            .panel-collapse-indicator,
            .panel-header-collapsible {
                cursor: pointer !important;
            }

            /* Keep text-entry controls behaving normally */
            input,
            textarea,
            [contenteditable="true"] {
                cursor: text !important;
            }
        `;

        document.head.appendChild(style);
    }

    function init() {
        if (!document.head) return;
        installStyle();
    }

    if (document.readyState === 'loading') {
        document.addEventListener('DOMContentLoaded', init, { once: true });
    } else {
        init();
    }

    window.__idlehackingCursorCleanupRemove = function () {
        const style = document.getElementById(STYLE_ID);
        if (style) style.remove();
        delete window.__idlehackingCursorCleanupInstalled;
        delete window.__idlehackingCursorCleanupRemove;
    };
})();