Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/
- /* _____ _ _ _____ _ _ _ _ */
- /* / ____| | | (_) / ____| (_) | | /\ | | */
- /* | | ___ ___ | | ___ ___| | | |_ ___| | _____ _ __ / \ _ _| |_ ___ */
- /* | | / _ \ / _ \| |/ / |/ _ \ | | | |/ __| |/ / _ \ '__/ /\ \| | | | __/ _ \ */
- /* | |___| (_) | (_) | <| | __/ |____| | | (__| < __/ | / ____ \ |_| | || (_) | */
- /* \_____\___/ \___/|_|\_\_|\___|\_____|_|_|\___|_|\_\___|_|/_/ \_\__,_|\__\___/ */
- /* */
- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/
- /*
- * Cookie Clicker Auto - Version 1.0 by LordPankake
- */
- var setup = false;
- var upgrades_blackList = ["One Mind", "Revoke Elder Covenaunt"];
- var autoMap = [];
- // TODO: Doesn't prevent user clicking bookmark multiple times (Duplicates the menu)
- if (!setup) {
- // Setup data
- init();
- // Create gui based on data
- createGUI();
- setup = true;
- // Start the main loop
- requestAnimationFrame(mainLoop);
- }
- /**
- * Creates the automation tasks.
- */
- function init() {
- var auto_ClickCookie = new Automation(false, "Click Cookie", function() {
- // The game has a sort of anti-autoclick but we can break it by changing the lastClick time.
- Game.lastClick = Date.now() - 10000;
- // Send a click to the big cookie
- var elemCookie = document.getElementById("bigCookie");
- clickElement(elemCookie);
- });
- var auto_ClickGolden = new Automation(false, "Click Goldens", function() {
- var goldenCookies = document.getElementsByClassName("shimmer");
- var index;
- for (index = goldenCookies.length - 1; index >= 0; --index) {
- var goldenCookie = goldenCookies[index];
- if (goldenCookie.style.backgroundImage.indexOf("wrath") > -1){
- // Wrath cookie
- }
- else if (goldenCookie.style.backgroundImage.indexOf("spooky") > -1){
- // Wrath (spooky) cookie
- }
- else {
- //Gold cookie
- clickElement(goldenCookie);
- }
- }
- });
- var auto_ClickSeasonal = new Automation(false, "Click Season Popups", function() {
- var elemGolden = document.getElementById("seasonPopup");
- if (checkExists(elemGolden)) {
- clickElement(elemGolden);
- }
- });
- var auto_PopWrinklers = new Automation(false, "Pop Wrinklers", function() {
- var i = 0;
- var len = Game.wrinklers.length;
- for (i = 0; i < len; i++) {
- var wrink = Game.wrinklers[i];
- if (wrink.sucked > 100) { // we only pop if they eat so we get halloween drops
- wrink.hp = 0;
- }
- }
- });
- var auto_BuyBuildings = new Automation(false, "Buy Buildings", function() {
- var index;
- var elemBuilds = document.getElementsByClassName("product unlocked enabled");
- for (index = elemBuilds.length - 1; index >= 0; --index) {
- var elemBuild = elemBuilds[index];
- clickElement(elemBuild);
- }
- });
- var auto_BuyUpgrades = new Automation(false, "Buy Upgrades", function() {
- var upgradePanel = document.getElementById("upgrades");
- var index;
- var upgradePanelChildren = upgradePanel.childNodes;
- for (index = upgradePanelChildren.length - 1; index >= 0; --index) {
- var elemUpgrade = upgradePanelChildren[index];
- if (elemUpgrade.className.indexOf("enabled") > -1) {
- clickElement(elemUpgrade);
- }
- }
- });
- var auto_RespawnCookie = new Automation(false, "Respawn Golden", function() {
- Game.shimmerTypes.golden.time += 1000;
- });
- autoMap.push(auto_ClickCookie);
- autoMap.push(auto_ClickGolden);
- autoMap.push(auto_ClickSeasonal);
- autoMap.push(auto_PopWrinklers);
- autoMap.push(auto_BuyBuildings);
- autoMap.push(auto_BuyUpgrades);
- autoMap.push(auto_RespawnCookie);
- }
- /**
- * Creates the GUI based on automation tasks created in the init method.
- */
- function createGUI() {
- // Misc variables
- var colDisabled = "#4f3030";
- var colEnabled = "#374f30";
- // Buttons
- var btnArray = [];
- var index;
- for (index = 0; index < autoMap.length; index++) {
- var btnAuto = document.createElement("DIV");
- btnAuto.setAttribute('id', index);
- btnAuto.onclick = function() {
- var auto = autoMap[parseInt(this.getAttribute('id'))];
- auto.active = !auto.active;
- this.style.backgroundColor = auto.active ? colEnabled : colDisabled;
- this.innerHTML = auto.titleText;
- };
- btnArray.push(btnAuto);
- }
- // Style tweaking & appending
- var elemMenu = document.createElement("DIV");
- elemMenu.style.position = "relative";
- elemMenu.style.zIndex = "99999";
- elemMenu.style.backgroundColor = "#000";
- elemMenu.style.padding = "5px";
- elemMenu.style.margins = "2px 2px 2px 2px";
- for (index = 0; index < btnArray.length; index++) {
- var elemButton = btnArray[index];
- elemButton.innerHTML = autoMap[index].titleText;
- elemButton.style.padding = "5px";
- elemButton.style.border = "1px solid #FFF";
- elemButton.style.backgroundColor = autoMap[index].active ? colEnabled : colDisabled;
- elemButton.style.display = "inline-block";
- elemMenu.appendChild(elemButton);
- }
- varTopBar = document.getElementById("topBar");
- topBar.innerHTML = '';
- topBar.appendChild(elemMenu);
- }
- /**
- * The main loop. Requires the window to be open.
- */
- function mainLoop() {
- var index;
- for (index = 0; index < autoMap.length; index++) {
- var auto = autoMap[index];
- // Skip if not active
- if (!auto.active) {
- continue;
- }
- // Run task
- auto.autoTask();
- }
- requestAnimationFrame(mainLoop);
- }
- /**
- * Clicks a given element.
- */
- function clickElement(elem) {
- var clickEvent = new MouseEvent("click", {
- "view": window,
- "bubbles": true,
- "cancelable": false
- });
- elem.dispatchEvent(clickEvent);
- }
- /**
- * Checks if a given item exists.
- */
- function checkExists(item) {
- return (typeof(item) != 'undefined' && item != null);
- }
- /**
- * Class (Or whatever. Javascript is fucking weird) containing data about the task.
- */
- function Automation(param_active, param_titleText, param_autoTask) {
- this.titleText = param_titleText;
- this.autoTask = param_autoTask;
- this.active = param_active;
- }
Add Comment
Please, Sign In to add comment