// ==UserScript== // @name 猫国建设者修改器 // @namespace http://tampermonkey.net/ // @version 0.2 // @description 猫国建设者资源修改,随便用用,都能改,缺啥又着急不想等的时候可以。。。毕竟是个挂机游戏,注意游戏体验 // @author rxdey // @match https://likexia.gitee.io/cat-zh/ // @grant none // @downloadURL https://update.greasyfork.icu/scripts/413069/%E7%8C%AB%E5%9B%BD%E5%BB%BA%E8%AE%BE%E8%80%85%E4%BF%AE%E6%94%B9%E5%99%A8.user.js // @updateURL https://update.greasyfork.icu/scripts/413069/%E7%8C%AB%E5%9B%BD%E5%BB%BA%E8%AE%BE%E8%80%85%E4%BF%AE%E6%94%B9%E5%99%A8.meta.js // ==/UserScript== (function () { 'use strict'; const render = (array) => { let li = ''; Object.keys(array).map(item => array[item]).forEach(item => { li += `
  • ${item.title}
    增加100 加满
  • `; }); return li; }; const dialog = ``; function handleAdd (target, count) { const type = $(target).parent().parent().attr('data-type'); const maxValue = game.resPool.resourceMap[type].maxValue; count = count || maxValue const value = game.resPool.resourceMap[type].value; if (maxValue) { if ((value + count) < maxValue) { game.resPool.resourceMap[type].value = value + count; } else { game.resPool.resourceMap[type].value = maxValue; } return; } game.resPool.resourceMap[type].value = value + (count || 1000); }; var rxmenu = '修改器'; $('body').append(rxmenu); $('#rx-editor').click(function () { if (document.querySelector('.rx-dialog')) { $('.rx-dialog').toggle(); } else { const liRender = render(game.resPool.resourceMap); $('body').append(dialog); $('.rx-ul').append(liRender); $('.rx-add-button').click(function() { handleAdd(this, 100) }); $('.rx-add-1000').click(function() { handleAdd(this, 0) }); $('.rx-dialog').toggle(); } }); })();