喵国建设者作弊器 Kittens Game Cheat

可以添加任意数量的资源,注意,这将极大地破坏您的游戏体验。You can add as many resources as you like in the game, and this will greatly ruin your gaming experience.

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         喵国建设者作弊器 Kittens Game Cheat
// @version      0.3
// @description  可以添加任意数量的资源,注意,这将极大地破坏您的游戏体验。You can add as many resources as you like in the game, and this will greatly ruin your gaming experience.
// @author       Kong Weihang
// @match        *likexia.gitee.io/*
// @grant        none
// @name         zh-CN,en
// @run-at       document-start
// @license      GNU General Public License v3.0 or later
// @namespace    http://tampermonkey.net/
// ==/UserScript==


(function () {
    'use strict';
    var isShowed = false;

    function InsertInputElement(inputArea, elementName) {
        var row = document.createElement("div");
        var input = document.createElement("input");
        var span = document.createElement("span");
        input.type = "text";
        input.className = "input";
        input.id = elementName;
        input.placeholder = elementName;
        input.style.marginRight = "1.0em";
        span.textContent = elementName;
        row.style.padding = "0px 10px";
        row.appendChild(span);
        row.appendChild(input);
        inputArea.appendChild(row);
    }

    function ElementCheat(elementName, value) {
        var numValue = parseInt(value);
        if (!isNaN(numValue) && numValue !== 0) {
            gamePage.resPool.get(elementName).value += numValue;
        }
    }

    function CheatEvent() {
        if (isShowed) { return; }
        var cheatList = [
            "catnip",
            "wood",
            "minerals",
            "iron",
            "gold",
            "manpower",
            "science",
            "culture",
            "kittens",
            "furs",
            "ivory",
            "spice",
            "unicorns",
            "blueprint"];
        var inputArea = document.createElement("div");

        var observeButton = document.getElementById("observeButton");

        if (typeof observeButton !== 'undefined' &&
            observeButton !== null) {

            for (let i = 0; i < cheatList.length; i++) {
                const chaetElement = cheatList[i];
                InsertInputElement(inputArea, chaetElement);
            }

            var cheatButton = document.createElement("button");
            cheatButton.textContent = "Start Cheat";
            cheatButton.addEventListener('click', function () {
                for (let i = 0; i < cheatList.length; i++) {
                    const elementName = cheatList[i];
                    var value = document.getElementById(elementName).value;

                    ElementCheat(elementName, value);

                }
            }, false);

            var cheatMaxButton = document.createElement("button");
            cheatMaxButton.textContent = "To Max";
            cheatMaxButton.addEventListener('click', function () {
                for (let i = 0; i < cheatList.length; i++) {
                    const elementName = cheatList[i];
                    var value = gamePage.resPool.get(elementName).maxValue;

                    ElementCheat(elementName, value);


                }
            }, false);

            var parent = observeButton.parentNode;
            parent.insertBefore(inputArea, observeButton);
            parent.insertBefore(cheatButton, observeButton);
            parent.insertBefore(cheatMaxButton, observeButton);

            isShowed = true;
        }
    }

    var IntervalID = setInterval(CheatEvent, 10000);

    setTimeout(function () {
        clearInterval(IntervalID)
    }, 300000);


})();