Cookie Setter GUI

Add GUI to set cookies in Cookie Clicker

当前为 2025-10-17 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Cookie Setter GUI
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Add GUI to set cookies in Cookie Clicker
// @author       You
// @match        https://orteil.dashnet.org/cookieclicker/*
// @license      CC BY-NC 4.0; https://creativecommons.org/licenses/by-nc/4.0/
// @grant        none
// ==/UserScript==

/*
    This work is licensed under the Creative Commons Attribution-NonCommercial 4.0 International License.
    To view a copy of this license, visit https://creativecommons.org/licenses/by-nc/4.0/

    You are free to share and adapt this code, but:
    - You must give appropriate credit.
    - You may not use this work for commercial purposes.
*/

(function() {
    'use strict';

    // Wait for the game to be ready
    function waitForGame() {
        if (typeof Game !== 'undefined' && Game.ready) {
            addGUI();
        } else {
            setTimeout(waitForGame, 1000); // check again in 1 second
        }
    }

    function addGUI() {
        const gui = document.createElement('div');
        gui.style.position = 'fixed';
        gui.style.top = '20px';
        gui.style.right = '20px';
        gui.style.padding = '10px';
        gui.style.backgroundColor = '#222';
        gui.style.color = '#fff';
        gui.style.border = '1px solid #555';
        gui.style.zIndex = 9999;

        const input = document.createElement('input');
        input.type = 'number';
        input.placeholder = 'Enter cookies';
        input.style.marginRight = '5px';

        const button = document.createElement('button');
        button.textContent = 'Set Cookies';
        button.onclick = function() {
            const value = parseFloat(input.value);
            if (!isNaN(value)) {
                Game.cookies = value;
                alert('Cookies set to ' + value);
            } else {
                alert('Please enter a valid number');
            }
        };

        gui.appendChild(input);
        gui.appendChild(button);
        document.body.appendChild(gui);
    }

    waitForGame();
})();