// ==UserScript== // @name Cookie Clicker Editor // @namespace http://tampermonkey.net/ // @version 1.16 // @description A draggable, resizable menu with smooth transitions, themes, and more buttons. Includes a minimize button to hide/show the menu. For Cookie Clicker // @author Imnotwraith // @match https://orteil.dashnet.org/cookieclicker/* // @grant none // @downloadURL https://update.greasyfork.icu/scripts/509366/Cookie%20Clicker%20Editor.user.js // @updateURL https://update.greasyfork.icu/scripts/509366/Cookie%20Clicker%20Editor.meta.js // ==/UserScript== (function() { 'use strict'; // Add the menu HTML to the page const menuHTML = ` `; document.body.insertAdjacentHTML('beforeend', menuHTML); const menu = document.getElementById('customMenu'); const toggleButton = document.getElementById('toggleButton'); const menuHeader = document.getElementById('menuHeader'); const closeMenu = document.getElementById('closeMenu'); const minimizeMenu = document.getElementById('minimizeMenu'); const tabMain = document.getElementById('tabMain'); const tabAbout = document.getElementById('tabAbout'); const tabThemes = document.getElementById('tabThemes'); const tabContentMain = document.getElementById('tabContentMain'); const tabContentAbout = document.getElementById('tabContentAbout'); const tabContentThemes = document.getElementById('tabContentThemes'); const menuBgColorInput = document.getElementById('menuBgColor'); const textColorInput = document.getElementById('textColor'); const applyThemeButton = document.getElementById('applyTheme'); const loopMoneyButton = document.getElementById('loopMoneyButton'); const button2 = document.getElementById('button2'); let isHidden = true; let loopMoneyInterval; // Show menu smoothly const showMenuSmoothly = () => { menu.style.display = 'block'; // Make sure it's set to block first menu.style.opacity = '0'; setTimeout(() => { menu.style.opacity = '1'; menu.style.visibility = 'visible'; menu.style.top = `${(window.innerHeight - menu.clientHeight) / 2}px`; menu.style.left = `${(window.innerWidth - menu.clientWidth) / 2}px`; }, 10); // Allow display change to take effect }; // Hide menu smoothly const hideMenuSmoothly = () => { menu.style.opacity = '0'; setTimeout(() => { menu.style.visibility = 'hidden'; menu.style.display = 'none'; // Set display to none after opacity transition }, 500); // matches the transition time toggleButton.style.display = 'block'; // Show the toggle button }; // Minimize menu minimizeMenu.addEventListener('click', () => { hideMenuSmoothly(); isHidden = true; clearInterval(loopMoneyInterval); // Stop the loop if menu is minimized }); // Close menu on 'X' button click closeMenu.addEventListener('click', () => { menu.style.display = 'none'; // Set display to none immediately toggleButton.style.display = 'block'; // Show the toggle button clearInterval(loopMoneyInterval); // Stop the loop if menu is closed }); // Show menu on toggle button click toggleButton.addEventListener('click', () => { showMenuSmoothly(); isHidden = false; toggleButton.style.display = 'none'; // Hide the toggle button when menu is shown }); // Tab switching functionality const switchTab = (mainDisplay, aboutDisplay, themesDisplay) => { tabContentMain.style.display = mainDisplay; tabContentAbout.style.display = aboutDisplay; tabContentThemes.style.display = themesDisplay; }; tabMain.addEventListener('click', () => switchTab('block', 'none', 'none')); tabAbout.addEventListener('click', () => switchTab('none', 'block', 'none')); tabThemes.addEventListener('click', () => switchTab('none', 'none', 'block')); // Show Main tab by default tabMain.click(); // Initial setup setTimeout(() => { showMenuSmoothly(); isHidden = false; // Menu is now visible }, 100); // Apply theme colors applyThemeButton.addEventListener('click', () => { const menuBgColor = menuBgColorInput.value; const textColor = textColorInput.value; menu.style.backgroundColor = menuBgColor; menuHeader.style.color = textColor; tabMain.style.color = textColor; tabAbout.style.color = textColor; tabThemes.style.color = textColor; tabContentMain.style.color = textColor; tabContentAbout.style.color = textColor; tabContentThemes.style.color = textColor; // Adjust button colors const buttons = document.querySelectorAll('#buttonContainer button'); buttons.forEach(button => { button.style.backgroundColor = textColor; }); }); // Loop Money functionality loopMoneyButton.addEventListener('click', () => { loopMoneyButton.classList.toggle('active'); loopMoneyButton.style.backgroundColor = loopMoneyButton.classList.contains('active') ? '#4caf50' : '#777'; if (loopMoneyButton.classList.contains('active')) { loopMoneyInterval = setInterval(() => { Game.Earn(1000); // Adjust this line as needed }, 1); // Adjust interval as necessary } else { clearInterval(loopMoneyInterval); } }); // Button 2 functionality button2.addEventListener('click', () => { Game.Tosave = true; //alert('Game.Tosave is set to true'); // Optional alert for feedback }); // Draggable functionality let isDragging = false; let offsetX, offsetY; menuHeader.addEventListener('mousedown', (e) => { isDragging = true; offsetX = e.clientX - menu.getBoundingClientRect().left; offsetY = e.clientY - menu.getBoundingClientRect().top; menuHeader.style.cursor = 'grabbing'; }); document.addEventListener('mousemove', (e) => { if (isDragging) { menu.style.left = `${e.clientX - offsetX}px`; menu.style.top = `${e.clientY - offsetY}px`; } }); document.addEventListener('mouseup', () => { isDragging = false; menuHeader.style.cursor = 'move'; }); })();