Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Modding:Releases/SwupMod

From Corru Observer Wiki
Revision as of 12:28, 1 July 2024 by Newmoon (talk | contribs) (created swupmod page! probably inaccurate, please correct/expand if necessary!)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

SwupMod is a modification for corru.observer that was meant to be appended to other mods.

Prior to the addition of the official mod loader, mods were loaded by pasting code directly into the browser console. This caused their changes to be reverted upon changing the page, which happens relatively frequently. SwupMod, if appended to the code of any given mod, causes its changes to persist even upon page change, which was invaluable for the creation of some mods. However, the official mod loader automatically causes changes to persist throughout the website, which renders SwupMod currently obsolete.

To append SwupMod to any given mod, use this template:

env.swupmodInfo = {
    modURL: "https://file.garden/Y5_jdq2IF2n_McHn/corru%20modding/swuptesting.js", // put the url of your mod (the file this code is in)
    runOnce: () => {
        // put mod code in here that only runs once, and not on page change
        // e.g. CSS injection should go in here, as it doesn't get wiped on page change

        console.log("mod init ran!");
    },
    runMod: () => {
        // put mod code in here that runs on every page
        // basically all JS modifications should go in here

        console.log("mod main ran!")

        // if you want code to only run on certain pages, use:
        if (document.body.getAttribute("page") == "golem-maintenance") {
            // (the page name is stored in the html file)

            // put code in here
            console.log("WOOO we're in golem maintenance! time to do stuff here!")
        }
    }
}

function onModLoad() {(!!env.loading)?setTimeout(onModLoad, 100):addResources(["https://file.garden/Y5_jdq2IF2n_McHn/corru%20modding/swupModv2.js"])}
setTimeout(onModLoad, 100);
Cookies help us deliver our services. By using our services, you agree to our use of cookies.