Idlescape No Gathering Ironman

Hides Gathering Skills Nodes

当前为 2021-03-09 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Idlescape No Gathering Ironman
// @namespace    NGI
// @version      1.1
// @description  Hides Gathering Skills Nodes
// @author       Dael
// @match        *://*.idlescape.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    function _isIronManCharacter(){
        return document.getElementsByClassName("header-league-icon")[0].getAttribute("src").includes("ironman");
    }

    function _isValidSkill(skillDOM){
        if (skillDOM.getElementsByClassName("max-skill-glow").length > 0) return false;
        if (skillDOM.getElementsByClassName("max-skill-glow30").length > 0) return false;

        let skillInfo = skillDOM.getElementsByClassName("CircularProgressbar-text")
        if (skillInfo.length === 0) skillInfo = skillDOM.getElementsByClassName("skill-level-bar-exp-level");

        const skillLevel = skillInfo[0].innerHTML;
        return parseInt(skillLevel) === 1;
    }

    function isValidPlayer(){
        if (!_isIronManCharacter()) return false;
        let miningSkill = false;
        let foragingSkill = false;
        let fishingSkill = false;
        document.querySelectorAll('[data-for="miningHeader"]').forEach(e=> { miningSkill = _isValidSkill(e) });
        document.querySelectorAll('[data-for="foragingHeader"]').forEach(e=> { foragingSkill = _isValidSkill(e) });
        document.querySelectorAll('[data-for="fishingHeader"]').forEach(e=> { fishingSkill = _isValidSkill(e) });
        return miningSkill && foragingSkill && fishingSkill;
    }

    function injectCSS(){
        const NGIStyle="<style>.theme-mining .resource-wrapper{display: none;}.theme-foraging .resource-wrapper{display: none;}.theme-fishing .resource-wrapper{display: none;}</style>";
        const head = document.querySelector('head');
        head.insertAdjacentHTML('beforeend', NGIStyle);
    }

    function blockGatheringSkills(){
        const callback = function(mutationsList, observer) {
            document.querySelectorAll(".theme-mining").forEach(e=>{e.querySelectorAll(".resource-wrapper").forEach(e=>e.parentNode.removeChild(e))});
            document.querySelectorAll(".theme-foraging").forEach(e=>{e.querySelectorAll(".resource-wrapper").forEach(e=>e.parentNode.removeChild(e))});
            document.querySelectorAll(".theme-fishing").forEach(e=>{e.querySelectorAll(".resource-wrapper").forEach(e=>e.parentNode.removeChild(e))});
        };

        // Observe Play Area DOM changes
        const playAreaContainer = document.getElementsByClassName("play-area-container")[0];
        const config = {attributes: true, childList: true, subtree: true };
        const observer = new MutationObserver(callback);
        observer.observe(playAreaContainer, config);
    }

    function onGameReady(callback) {
        const gameContainer = document.getElementsByClassName("play-area-container");
        if(gameContainer.length === 0) {
            setTimeout(function(){onGameReady(callback);}, 500 );
        } else {
            callback();
        }
    }

    function init(){
        if (!isValidPlayer()) return;
        injectCSS();
        blockGatheringSkills();
    }

    onGameReady(function(){init()});
})();