Cookie Clicker HACKS!! {CHEAT}

Compact hacker-style cheat panel for Cookie Clicker with Enter-to-execute inputs.

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name        Cookie Clicker HACKS!! {CHEAT}
// @namespace    http://tampermonkey.net/
// @version      2.9
// @description  Compact hacker-style cheat panel for Cookie Clicker with Enter-to-execute inputs.
// @author       Phil 🥹👍 and DynaHacks
// @license      MIT
// @match        *://cookieclicker.com/*
// @match        *://*.cookieclicker.com/*
// @match        *://orteil.dashnet.org/cookieclicker/*
// @match        *://cookiegame.org/index.html
// @match        *://cookiegame.org/index.html*
// @grant        none
// @run-at       document-start
// ==/UserScript==

(function() {
    'use strict';

    let hudContainer = null;
    let isHidden = false;
    let clickCounterInterval = null;

    const styles = `
        #cc-hacks-hud {
            position: fixed;
            top: 10px;
            right: 10px;
            width: 300px;
            background: rgba(20, 20, 20, 0.95);
            color: #fff;
            border: 1px solid #00ff00;
            border-radius: 6px;
            font-family: monospace;
            box-shadow: 0 0 10px rgba(0, 255, 0, 0.2);
            z-index: 999999;
            user-select: none;
            font-size: 11px;
        }
        #cc-hacks-hud-header {
            background: #111;
            padding: 6px 10px;
            font-weight: bold;
            border-bottom: 1px solid #333;
            display: flex;
            justify-content: space-between;
            align-items: center;
            cursor: grab;
        }
        #cc-hacks-hud-header:active { cursor: grabbing; }
        #cc-hacks-hud-title { color: #00ff00; font-size: 10px; }
        .cc-hacks-btn {
            background: #333;
            border: 1px solid #555;
            color: #aaa;
            padding: 2px 6px;
            border-radius: 3px;
            cursor: pointer;
            font-size: 9px;
            font-family: monospace;
            transition: all 0.2s;
        }
        .cc-hacks-btn:hover { background: #444; color: #fff; }
        .cc-hacks-btn-danger { border-color: #ff0000; color: #ff0000; }
        .cc-hacks-btn-warning { border-color: #ffaa00; color: #ffaa00; }
        .cc-hacks-btn-success { border-color: #00ff00; color: #00ff00; }
        .cc-hacks-btn-critical { border-color: #ff00ff; color: #ff00ff; }
        .cc-hacks-btn-golden { border-color: #ffd700; color: #ffd700; }
        .cc-hacks-btn-heavenly { border-color: #00ffff; color: #00ffff; }
        .cc-hacks-btn-lumps { border-color: #ff8800; color: #ff8800; }
        .cc-hacks-btn-frenzy { border-color: #ff00ff; color: #ff00ff; }

        #cc-hacks-hud-body { padding: 8px 10px; }

        .cc-hacks-row {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 6px;
            background: #111;
            padding: 4px 6px;
            border: 1px solid #222;
            border-radius: 3px;
        }
        .cc-hacks-row span { color: #888; font-size: 10px; }
        .cc-hacks-input {
            background: #000;
            border: 1px solid #333;
            color: #00ff00;
            padding: 2px 4px;
            font-family: monospace;
            font-size: 10px;
            width: 60px;
            outline: none;
            text-align: center;
        }
        .cc-hacks-input:focus { border-color: #00ff00; }
        .cc-hacks-hidden { opacity: 0 !important; pointer-events: none !important; }
        .cc-hacks-stats-display {
            color: #00ff00;
            font-size: 11px;
            font-weight: bold;
        }
    `;

    function injectStyles() {
        if (document.getElementById('cc-hacks-styles')) return;
        const styleSheet = document.createElement('style');
        styleSheet.id = 'cc-hacks-styles';
        styleSheet.innerText = styles;
        document.head.appendChild(styleSheet);
    }

    const activeTimers = {};
    function showStatus(labelId, message, isSuccess) {
        const el = document.getElementById(labelId);
        if (!el) return;
        if (activeTimers[labelId]) clearTimeout(activeTimers[labelId]);

        const originalText = el.getAttribute('data-original') || el.innerText;
        if (!el.getAttribute('data-original')) el.setAttribute('data-original', originalText);

        el.innerText = message;
        el.style.color = isSuccess ? '#00ff00' : '#ff0000';

        activeTimers[labelId] = setTimeout(() => {
            el.innerText = el.getAttribute('data-original');
            el.style.color = '';
            delete activeTimers[labelId];
        }, 2000);
    }

    function createHUD() {
        if (document.getElementById('cc-hacks-hud')) return;

        hudContainer = document.createElement('div');
        hudContainer.id = 'cc-hacks-hud';

        hudContainer.innerHTML = `
            <div id="cc-hacks-hud-header">
                <span id="cc-hacks-hud-title">CC Hacks v1.94</span>
                <button class="cc-hacks-btn" id="cc-hacks-toggle-btn">HIDE</button>
            </div>
            <div id="cc-hacks-hud-body">
                <div class="cc-hacks-row">
                    <span id="cc-clicks-label">Clicks:</span>
                    <div id="cc-click-counter" class="cc-hacks-stats-display">0</div>
                </div>

                <div class="cc-hacks-row">
                    <span id="cc-headstart-label">Headstart</span>
                    <button class="cc-hacks-btn cc-hacks-btn-warning" id="cc-headstart-btn">RUN</button>
                </div>

                <div class="cc-hacks-row">
                    <span id="cc-build-label">Buildings (+All)</span>
                    <div style="display:flex; gap:4px;">
                        <input type="number" id="cc-build-amount" class="cc-hacks-input" value="700">
                        <button class="cc-hacks-btn cc-hacks-btn-critical" id="cc-free-buildings-btn">ADD</button>
                    </div>
                </div>

                <div class="cc-hacks-row">
                    <span id="cc-golden-label">Golden Cookies</span>
                    <div style="display:flex; gap:4px;">
                        <input type="number" id="cc-golden-amount" class="cc-hacks-input" value="10">
                        <button class="cc-hacks-btn cc-hacks-btn-golden" id="cc-golden-btn">SPAWN</button>
                    </div>
                </div>

                <div class="cc-hacks-row">
                    <span id="cc-heavenly-label">Heavenly Chips</span>
                    <div style="display:flex; gap:4px;">
                        <input type="number" id="cc-heavenly-amount" class="cc-hacks-input" value="1000">
                        <button class="cc-hacks-btn cc-hacks-btn-heavenly" id="cc-heavenly-btn">ADD</button>
                    </div>
                </div>

                <div class="cc-hacks-row">
                    <span id="cc-lumps-label">Sugar Lumps</span>
                    <div style="display:flex; gap:4px;">
                        <input type="number" id="cc-lumps-amount" class="cc-hacks-input" value="100">
                        <button class="cc-hacks-btn cc-hacks-btn-lumps" id="cc-lumps-btn">ADD</button>
                    </div>
                </div>

                <div class="cc-hacks-row">
                    <span id="cc-frenzy-label">Frenzy (sec)</span>
                    <div style="display:flex; gap:4px;">
                        <input type="number" id="cc-frenzy-amount" class="cc-hacks-input" value="77">
                        <button class="cc-hacks-btn cc-hacks-btn-frenzy" id="cc-frenzy-btn">BUFF</button>
                    </div>
                </div>

                <div class="cc-hacks-row">
                    <span id="cc-earn-label">Earn Cookies</span>
                    <div style="display:flex; gap:4px;">
                        <input type="number" id="cc-earn-input" class="cc-hacks-input" placeholder="Qty">
                        <button class="cc-hacks-btn cc-hacks-btn-success" id="cc-earn-btn">EARN</button>
                    </div>
                </div>

                <div class="cc-hacks-row" style="justify-content: center;">
                    <button class="cc-hacks-btn cc-hacks-btn-danger" style="width:100%; padding: 4px;" id="cc-infinite-btn">INFINITE COOKIES</button>
                </div>
                <div id="cc-infinite-status" style="font-size:9px; text-align:center; height:12px; margin-top:-4px; margin-bottom:4px;"></div>

                <div style="text-align:center; color:#444; font-size:8px;">
                    Press 'H' to toggle
                </div>
            </div>
        `;

        document.documentElement.appendChild(hudContainer);

        document.getElementById('cc-hacks-toggle-btn').addEventListener('click', toggleHUD);
        document.getElementById('cc-headstart-btn').addEventListener('click', doHeadstart);
        document.getElementById('cc-free-buildings-btn').addEventListener('click', doFreeBuildings);
        document.getElementById('cc-earn-btn').addEventListener('click', doEarn);
        document.getElementById('cc-infinite-btn').addEventListener('click', doInfinite);
        document.getElementById('cc-golden-btn').addEventListener('click', doSpawnGolden);
        document.getElementById('cc-heavenly-btn').addEventListener('click', doEarnHeavenly);
        document.getElementById('cc-lumps-btn').addEventListener('click', doAddLumps);
        document.getElementById('cc-frenzy-btn').addEventListener('click', doTriggerFrenzy);

        // Add Enter key listeners to all text inputs
        document.getElementById('cc-build-amount').addEventListener('keypress', (e) => {
            if (e.key === 'Enter') doFreeBuildings();
        });
        document.getElementById('cc-golden-amount').addEventListener('keypress', (e) => {
            if (e.key === 'Enter') doSpawnGolden();
        });
        document.getElementById('cc-heavenly-amount').addEventListener('keypress', (e) => {
            if (e.key === 'Enter') doEarnHeavenly();
        });
        document.getElementById('cc-lumps-amount').addEventListener('keypress', (e) => {
            if (e.key === 'Enter') doAddLumps();
        });
        document.getElementById('cc-frenzy-amount').addEventListener('keypress', (e) => {
            if (e.key === 'Enter') doTriggerFrenzy();
        });
        document.getElementById('cc-earn-input').addEventListener('keypress', (e) => {
            if (e.key === 'Enter') doEarn();
        });

        makeDraggable(hudContainer);
        startClickCounterLoop();
    }

    function ensureHUD() {
        if (!document.getElementById('cc-hacks-hud')) {
            createHUD();
            if (isHidden && hudContainer) hudContainer.classList.add('cc-hacks-hidden');
        }
    }

    const observer = new MutationObserver(() => ensureHUD());
    observer.observe(document.documentElement, { childList: true, subtree: true });
    setInterval(ensureHUD, 3000);

    function startClickCounterLoop() {
        if (clickCounterInterval) clearInterval(clickCounterInterval);
        clickCounterInterval = setInterval(() => {
            const counterEl = document.getElementById('cc-click-counter');
            if (!counterEl) return;
            if (typeof Game !== 'undefined' && typeof Game.clicksThisSession !== 'undefined') {
                counterEl.innerText = Game.clicksThisSession.toLocaleString();
            } else {
                counterEl.innerText = 'N/A';
            }
        }, 100);
    }

    function doHeadstart() {
        if (typeof Game !== 'undefined' && typeof Game.RuinTheFun === 'function') {
            Game.RuinTheFun();
            showStatus('cc-headstart-label', 'Headstart OK', true);
        } else {
            showStatus('cc-headstart-label', 'Error', false);
        }
    }

    function doFreeBuildings() {
        const input = document.getElementById('cc-build-amount');
        let amount = parseInt(input.value);
        if (!amount || amount < 0) {
            showStatus('cc-build-label', 'Invalid', false);
            return;
        }
        if (typeof Game === 'undefined' || typeof Game.Objects === 'undefined') {
            showStatus('cc-build-label', 'Error', false);
            return;
        }
        try {
            for (var i in Game.Objects) {
                if (Game.Objects.hasOwnProperty(i)) Game.Objects[i].amount += amount;
            }
            if(typeof Game.UpdateStore === 'function') Game.UpdateStore();
            if(typeof Game.RefreshStore === 'function') Game.RefreshStore();
            showStatus('cc-build-label', 'Buildings OK', true);
        } catch (e) {
            showStatus('cc-build-label', 'Error', false);
        }
    }

    function doEarn() {
        const input = document.getElementById('cc-earn-input');
        const amount = parseInt(input.value);
        if (!amount || amount <= 0) {
            showStatus('cc-earn-label', 'Invalid', false);
            return;
        }
        if (typeof Game !== 'undefined' && typeof Game.Earn === 'function') {
            Game.Earn(amount);
            input.value = '';
            showStatus('cc-earn-label', 'Earned OK', true);
        } else {
            showStatus('cc-earn-label', 'Error', false);
        }
    }

    function doEarnHeavenly() {
        const input = document.getElementById('cc-heavenly-amount');
        const amount = parseInt(input.value);
        if (!amount || amount <= 0) {
            showStatus('cc-heavenly-label', 'Invalid', false);
            return;
        }
        if (typeof Game !== 'undefined') {
            Game.heavenlyChips += amount;
            input.value = '';
            showStatus('cc-heavenly-label', 'Chips OK', true);
        } else {
            showStatus('cc-heavenly-label', 'Error', false);
        }
    }

    function doAddLumps() {
        const input = document.getElementById('cc-lumps-amount');
        const amount = parseInt(input.value);
        if (!amount || amount <= 0) {
            showStatus('cc-lumps-label', 'Invalid', false);
            return;
        }
        if (typeof Game !== 'undefined') {
            Game.lumps += amount;
            input.value = '';
            showStatus('cc-lumps-label', 'Lumps OK', true);
        } else {
            showStatus('cc-lumps-label', 'Error', false);
        }
    }

    function doTriggerFrenzy() {
        const input = document.getElementById('cc-frenzy-amount');
        const seconds = parseInt(input.value);
        if (!seconds || seconds <= 0) {
            showStatus('cc-frenzy-label', 'Invalid', false);
            return;
        }
        if (typeof Game !== 'undefined' && typeof Game.gainBuff === 'function') {
            Game.gainBuff('frenzy', seconds, 7);
            input.value = '';
            showStatus('cc-frenzy-label', 'Frenzy OK', true);
        } else {
            showStatus('cc-frenzy-label', 'Error', false);
        }
    }

    function doInfinite() {
        if (typeof Game !== 'undefined') {
            Game.cookies = Infinity;
            showStatus('cc-infinite-status', 'INFINITE COOKIES SET!', true);
        } else {
            showStatus('cc-infinite-status', 'Error', false);
        }
    }

    function doSpawnGolden() {
        const input = document.getElementById('cc-golden-amount');
        const amount = parseInt(input.value);
        if (!amount || amount <= 0) {
            showStatus('cc-golden-label', 'Invalid', false);
            return;
        }
        if (typeof Game === 'undefined' || typeof Game.shimmer === 'undefined') {
            showStatus('cc-golden-label', 'Error', false);
            return;
        }
        try {
            for (let i = 0; i < amount; i++) {
                new Game.shimmer("golden");
            }
            input.value = '';
            showStatus('cc-golden-label', 'Golden OK', true);
        } catch (e) {
            showStatus('cc-golden-label', 'Error', false);
        }
    }

    function toggleHUD() {
        isHidden = !isHidden;
        if (hudContainer) hudContainer.classList.toggle('cc-hacks-hidden', isHidden);
    }

    window.addEventListener('keydown', (e) => {
        if (e.key.toLowerCase() === 'h' && !e.ctrlKey && !e.metaKey) toggleHUD();
    });

    function makeDraggable(element) {
        const header = document.getElementById('cc-hacks-hud-header');
        if (!header) return;
        let pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0;
        header.onmousedown = dragMouseDown;

        function dragMouseDown(e) {
            if (e.target.classList && e.target.classList.contains('cc-hacks-btn')) return;
            e = e || window.event;
            e.preventDefault();
            pos3 = e.clientX;
            pos4 = e.clientY;
            document.onmouseup = closeDragElement;
            document.onmousemove = elementDrag;
        }

        function elementDrag(e) {
            e = e || window.event;
            e.preventDefault();
            pos1 = pos3 - e.clientX;
            pos2 = pos4 - e.clientY;
            pos3 = e.clientX;
            pos4 = e.clientY;
            element.style.top = (element.offsetTop - pos2) + "px";
            element.style.left = (element.offsetLeft - pos1) + "px";
            element.style.right = "auto";
        }

        function closeDragElement() {
            document.onmouseup = null;
            document.onmousemove = null;
        }
    }

    if (document.readyState === 'loading') {
        document.addEventListener('DOMContentLoaded', () => {
            injectStyles();
            createHUD();
        });
    } else {
        injectStyles();
        createHUD();
    }
})();