Set cookies and smoothly speed up Cookie Clicker using Date.now() override
当前为
// ==UserScript==
// @name Cookie Clicker Speed & Cookies GUI
// @namespace http://tampermonkey.net/
// @version 1.2
// @description Set cookies and smoothly speed up Cookie Clicker using Date.now() override
// @author notfamous
// @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';
let speed = 1; // speed multiplier, fractional allowed
const baseIncrement = 16.67; // approx 1 frame @ 60fps in ms
let fakeNow = Date.now();
// Save original Date.now
const realDateNow = Date.now.bind(Date);
// Override Date.now to speed up time smoothly
Date.now = function() {
fakeNow += speed * baseIncrement;
return Math.floor(fakeNow);
};
function waitForGame() {
if (typeof Game !== 'undefined' && Game.ready) {
setupGUI();
} else {
setTimeout(waitForGame, 1000);
}
}
function setupGUI() {
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.borderRadius = '5px';
gui.style.zIndex = 9999;
gui.style.fontFamily = 'sans-serif';
gui.style.fontSize = '14px';
gui.style.minWidth = '180px';
// Cookie input and button
const input = document.createElement('input');
input.type = 'number';
input.placeholder = 'Enter cookies';
input.style.marginRight = '5px';
input.style.width = '120px';
const button = document.createElement('button');
button.textContent = 'Set Cookies';
button.onclick = function() {
const val = parseFloat(input.value);
if (!isNaN(val)) {
Game.cookies = val;
alert('Cookies set to ' + val);
} else {
alert('Please enter a valid number');
}
};
// Speed slider label
const speedLabel = document.createElement('label');
speedLabel.textContent = 'Speed: 1.0x';
speedLabel.style.display = 'block';
speedLabel.style.marginTop = '10px';
// Speed slider (1x to 10x, fractional steps)
const speedSlider = document.createElement('input');
speedSlider.type = 'range';
speedSlider.min = '1';
speedSlider.max = '10';
speedSlider.value = '1';
speedSlider.step = '0.1';
speedSlider.style.width = '120px';
speedSlider.oninput = function() {
speed = parseFloat(speedSlider.value);
speedLabel.textContent = `Speed: ${speed.toFixed(1)}x`;
};
// Append everything
gui.appendChild(input);
gui.appendChild(button);
gui.appendChild(speedLabel);
gui.appendChild(speedSlider);
document.body.appendChild(gui);
}
waitForGame();
})();