Add GUI to set cookies in Cookie Clicker
当前为
// ==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();
})();