Skip to content

Modding

FifthTundraG edited this page Jun 16, 2024 · 3 revisions

Warning!

Adding mods without verifying their legitimacy can result in unintended side effects! We are not responsible for any damages that may be caused by mods!

Installing a mod

URL Method (Recommended)

To install via a URL, a mod author should supply a link to the direct Javascript of this mod. This can be pasted into the "From URL" form on the Add Mod popup accessible via Options.

File Method

To install via a file, a mod author should supply a file with the extension .js with the source code of their mod. This can be navigated to in the file explorer menu popup given when clicking the button next to "From File".

Creating a mod

How To

Warning: Modding API may change at any time!
The current modding API works almost identically to Cookie Clicker (with a few differences for legal reasons). The start of a mod file should always have the mods.addModData function called, and its two parameters filled. The first one should be your mod's name. The second parameter will be your mod's entire source code contained within an object. Inside this object should be a function called initialization. This is all of the code that will be run as soon as the mod is loaded in. You can also create other functions within this object to run inside initialization. Currently, no system is in place for anything to run in a loop, although this may be changed in a future update to this API. An example of a functioning mod is below:

mods.addModData("test mod",{
    initialization:function() {
        console.log("mod ran!");
    }
});

Your mod can interact with any of the DOM elements and edit pre-existing functions. As an example, if you wanted to change the cookie click to add 1000 cookies instead of the users cookiesPerClick amount, you can use the following script:

mods.addModData("test mod",{
    initialization:function() {
        core.cookieClicked = function() {
            core.cookies += 1000;
            core.cookieBeenClickedTimes += 1;
            core.totalCookies += 1000;
            helper.reloadCookieCounter();
        }
    }
});

There are certain functions that shouldn't be messed with because they may have a core feature that is integral to the function of the site, so always check what a function does before editing it.

Choosing an installation method

There are two options for distributing your mod to other people. The URL Method is the one I recommend for ease of use but it's longer and might not be suitable for some people.

From URL (Recommended)

Distributing your mod to others from a URL will require a service to host your file on. Before you get worried, you can actually host your file directly on GitHub by creating a GitHub Pages site and placing your mod file among your site's directory. To get started with a GitHub Pages site, read this documentation article from GitHub.
Once completed, simply place your mod's file among your site's root folder (or whatever folder you choose to build from) and wait for Jekyll to build your site. After this process (usually about a minute), navigate to your JS file in web browser.
Example:
> In your GitHub repo your index.html file is in your root folder (if you have a index.html file) and your mod file is in another folder inside your repo's tree, in this scenario, /mods/mod.js. In your browser, navigate to this file. It would be under <your username>.github.io/mods/mod.js. If you see your mod's source code after navigating here, congrats! You have a link to your mod that can be used in-game!
> If this doesn't succeed, this could be because your repo isn't named <your username>.github.io. It might be named something unique, in which case the link to find your file will be slightly different. In our scenario, it would look something like <your username>.github.io/<your repo name>/mods/mod.js.

From File

Distributing your mod from a file is simpler to set up, but also has some downsides, mainly being users having to manually update their mod file when you release a new update. To distribute from file, just supply the user with your JS file containing your source code.