Skip to content

Instantly share code, notes, and snippets.

@Antonabi
Last active April 27, 2024 18:10
Show Gist options
  • Save Antonabi/98de19b4c41fd62efa09e12a1f7ebc17 to your computer and use it in GitHub Desktop.
Save Antonabi/98de19b4c41fd62efa09e12a1f7ebc17 to your computer and use it in GitHub Desktop.
A little script that lets you add custom items to infinite craft.

infiniteAdd

-your mom is fadd-

(yes, I think its funny)

How to use

With infiniteAdd you can add elements to infinite craft.
Just paste this code into your browser console and type the emoji and name of the element (the AI only knows the name and doesent care about the emojis).
To open the browser console, press ctrl + alt + i on Windows or cmd + alt + i on Mac and click on console.

For this to work you need to have crafted one thing before or else you will get this error: Uncaught TypeError: Cannot read properties of null (reading 'elements') at <anonymous>:3:18.

WARNING: Dont use this your normal game or backup the localStorage before. I would recommend an incognito tab.

PEASE: Dont use this for cheating. I only made this to get better at javaScript (thats why the code is so terrible). Maybe you can look through this and understand how it works and learn from this.

Extra

If you dont want to set the emoji or name of the element every time, you can change them from nothing to what you want at line 45.
The "discovered" attribute sets if the client thinks youve discovered the element.

//infiniteAdd by Antonabi (https://gist.github.com/Antonabi/98de19b4c41fd62efa09e12a1f7ebc17)
// _ __ _ _ _ _ _ _
//(_) _ __ / _|(_) _ __ (_)| |_ ___ / \ __| | __| |
//| || '_ \ | |_ | || '_ \ | || __| / _ \ / _ \ / _` | / _` |
//| || | | || _|| || | | || || |_ | __/ / ___ \ | (_| || (_| |
//|_||_| |_||_| |_||_| |_||_| \__| \___|/_/ \_\ \__,_| \__,_|
// -your mom is fadd-
//thx for using it I guess. But dont cheat, only use it for testing crafts. Or I will find you. (joking)
//btw if you dont trust my code, you can just look through it. I tried to comment it but its meh.
//define the icData and elements as vars at the beginning
icData = getIcData()
elements = icData["elements"]
//get the infinite craft local storage
function getIcData(){
icData = JSON.parse(localStorage.getItem("infinite-craft-data"))
return icData
}
//modify the elements in local storage
function modifyElements(newData){
console.log(icData)
localStorage.setItem("infinite-craft-data", JSON.stringify(icData))
}
//checks if the element data is empty
function checkElementData(elementData){
//checks the element text
if (elementData["text"] == ""){
elementData["text"] = prompt("The text of the element is empty. To what do you want to set it? (Just leave it empty to set it to empty)")
}
//checks the element emoji
if (elementData["emoji"] == ""){
elementData["emoji"] = prompt("The text of the emoji is empty. To what do you want to set it? (Just leave it empty to set it to empty)")
}
return elementData
}
//prints intro and clears the console
function intro(){
//clears console
console.clear()
//the logo in ascii art
logo = " _ __ _ _ _ _ _ _ \n(_) _ __ / _|(_) _ __ (_)| |_ ___ / \\ __| | __| |\n| || '_ \\ | |_ | || '_ \\ | || __| / _ \\ / _ \\ / _` | / _` |\n| || | | || _|| || | | || || |_ | __/ / ___ \\ | (_| || (_| |\n|_||_| |_||_| |_||_| |_||_| \\__| \\___|/_/ \\_\\ \\__,_| \\__,_|\n \n"
console.log(logo)
console.log("\t\t\t\t\t\t-your mom is fadd-")
}
function main(){
//the data structure of the element
//change this to not be prompted every time
elementData = {
"text": "Water", //the text of the element
"emoji": "💧", //the emoji of the element (can also be text)
"discovered": true //if you are the first who discovered it (only clientside)
}
//checks the elementData to be empty
elementData = checkElementData(elementData)
//adds the new element to the elemnts
elements.push(elementData)
console.log("Added to local elements")
//adds it to the actual localStorage
modifyElements(elements)
console.log("Added to the actual elements in local storage")
//reloads the page so the element gets shown
console.log("Reloading page...")
location.reload()
console.log("Done!")
}
intro()
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment