Evolve Creative Mode Script
刚来的新人,脚本是网上找的,看您心情打赏吧
/**
* Evolve Creative Mode
* @author SimplyNo (u/zechatron)
*
*/
(function() {
let tabs = $($("nav")[0].firstChild);
let hackIsOpen = false;
let sections = $("#mainColumn > div > div > section");
let hackContent = `<div id="hackContent" style="padding: 20px;">
<span>Evolve Creative Mode\n[made by SimplyNo]</span>
<table>
<tr>
<th style="font-weight: normal;" class="has-text-warning">
Type
</th>
<th style="font-weight: normal;" class="has-text-warning">
Item
</th>
<th style="font-weight: normal;" class="has-text-warning">
Property
</th>
<th style="font-weight: normal;" class="has-text-warning">
New Value
</th>
<th style="font-weight: normal;" class="has-text-success">
Current Value
</th>
</tr>
</table>
<button class="button" onClick="newSet()">New Set</button>
<button class="button" onClick="save()" style="float: right;">Save Changes</button>
</div>`
tabs.append(`<li id="hackTab" class><a onClick="openHackTab()">Creative Mode</a></li>`);
/**
* Gets the game object
*/
window.getSession = () => JSON.parse(LZString.decompressFromBase64(exportGame()));
/**
*
* getKeys("resource") - gets the property 'resource' from game object and returns all the keys inside of it, if any, as HTML option elements
* getKeys("fill", {}) - same thing but it uses a predefined object instead of the game object
*/
window.getKeys = (key, fill) => {
let session = window.getSession();
let keys;
let obj;
if (key == "*") {
obj = session;
keys = Object.keys(obj);
} else if (key == "fill") {
obj = fill;
keys = Object.keys(obj);
} else {
obj = session[key];
keys = Object.keys(obj);
}
if (typeof obj != "object") return 0;
keys.sort((a, b) => {
if (a.toLowerCase() > b.toLowerCase()) {
return 1;
}
if (b.toLowerCase() > a.toLowerCase()) {
return -1;
}
return 0;
})
if (!keys.length) return -1;
return `<option>${keys.join("</option><option>")}</option>`;
}
/**
*
* @description is called whenever the TYPE dropdown box is changed and it controls what the other boxes will be
*
*/
window.handleType = (selector) => {
let table = $(selector.parentElement.parentElement);
let type = selector.value;
let newKeys = window.getKeys(type);
while (table[0].childElementCount > 1) {
$(table[0].lastChild).remove()
}
if (newKeys == -1) {
$(table[0]).append(`<td style="border:0;" class="hackItem">n/a</td>`)
$(table[0]).append(`<td style="border:0;" class="hackProp">n/a</td>`)
$(table[0]).append(`<td style="border:0;" class="hackVal">n/a</td>`)
$(table[0]).append(`<td style="border:0;">n/a</td>`)
} else if (!newKeys) {
$(table[0]).append(`<td style="border:0;" class="hackItem">n/a</td>`)
$(table[0]).append(`<td style="border:0;" class="hackProp">n/a</td>`)
$(table[0]).append(`<td style="border:0;"><input placeholder="New Value" class="hackVal"></input></td>`)
$(table[0]).append(`<td style="border:0;">${window.getSession()[type]}</td>`)
} else {
let tr = table.append(`<td style="border:0;"><select onchange="handleItem(this)" class="hackItem">${newKeys}</select></td>`);
window.handleItem(tr[0].children[1].firstChild)
}
}
/**
*
* @description is called whenever the ITEM dropdown box is changed and it controls what the other boxes will be
*
*/
window.handleItem = (selector) => {
let table = $(selector.parentElement.parentElement);
let type = table[0].children[0].children[0].value;
let item = selector.value;
let newKeys = window.getKeys('fill', window.getSession()[type][item]);
while (table[0].childElementCount > 2) {
$(table[0].lastChild).remove()
}
if (newKeys == -1) {
$(table[0]).append(`<td style="border:0;" class="hackProp">n/a</td>`)
$(table[0]).append(`<td style="border:0;" class="hackValue">n/a</td>`)
$(table[0]).append(`<td style="border:0;">n/a</td>`)
} else if (!newKeys) {
$(table[0]).append(`<td style="border:0;" class="hackProp">n/a</td>`)
$(table[0]).append(`<td style="border:0;"><input placeholder="New Value" class="hackVal"></input></td>`)
$(table[0]).append(`<td style="border:0;">${window.getSession()[type][item]}</td>`)
} else {
let tr = table.append(`<td style="border:0;"><select onchange="handleProp(this)" class="hackProp">${newKeys}</select></td>`)
window.handleProp(tr[0].children[2].firstChild)
}
}
/**
*
* @description is called whenever the PROP dropdown box is changed and it controls what the other boxes will be
*
*/
window.handleProp = (selector) => {
let table = $(selector.parentElement.parentElement);
let type = table[0].children[0].children[0].value;
let item = table[0].children[1].children[0].value
let prop = selector.value;
let newKeys = window.getKeys('fill', window.getSession()[type][item][prop]);
while (table[0].childElementCount > 3) {
$(table[0].lastChild).remove()
}
if (newKeys == -1) {
$(table[0]).append(`<td style="border:0;" class="hackValue">n/a</td>`)
$(table[0]).append(`<td style="border:0;" >n/a</td>`)
} else if (!newKeys) {
$(table[0]).append(`<td style="border:0;"><input placeholder="New Value" class="hackVal"></input></td>`)
$(table[0]).append(`<td style="border:0;">${window.getSession()[type][item][prop]}</td>`)
} else {
alert("oh")
}
}
window.newSet = () => {
let table = $("#hackContent > table > tbody");
let tr = table.append(` <tr>
<td style="border: 0;">
<select class="hackType" onchange="handleType(this)">
${getKeys('*')}
</select>
</td>
</tr>`)
window.handleType(tr[0].lastChild.children[0].children[0])
}
/**
* gets values from drop down boxes and appends it to a copy of the game object.
* encrypts game object to Base64 and imports it. (page reload)
*/
window.save = () => {
let newSave = window.getSession();
console.log(newSave.resource.Food.amount)
let sets = Array.from($("#hackContent > table > tbody")[0].children)
sets.forEach((el, i) => {
let type = document.getElementsByClassName("hackType")[i] ? document.getElementsByClassName("hackType")[i].value : null;
let item = document.getElementsByClassName("hackItem")[i] ? document.getElementsByClassName("hackItem")[i].value : null;
let prop = document.getElementsByClassName("hackProp")[i] ? document.getElementsByClassName("hackProp")[i].value : null;
let val = document.getElementsByClassName("hackVal")[i] ? document.getElementsByClassName("hackVal")[i].value : null;
let ary = [type, item, prop, val]
if (val) {
val = parseInt(val) || val;
if (prop) {
newSave[type][item][prop] = val;
} else if (item) {
newSave[type][item] = val;
} else if (type) {
newSave[type] = val;
}
}
})
let encrypted = LZString.compressToBase64(JSON.stringify(newSave));
console.log(newSave.resource.Food.amount)
importGame(encrypted);
}
/**
* makes everything invisible
*/
window.openHackTab = () => {
if (hackIsOpen) return;
hackIsOpen = true;
// remove other tabs
sections[0].childNodes.forEach(el => {
if (el.id !== "hackContent") {
el.setAttribute("style", "display: none");
}
})
/**
* @type HTMLElement
*/
let hacktab = $("#hackContent")[0];
hacktab.removeAttribute("style");
tabs[0].childNodes.forEach(el => {
if (el.id !== "hackTab") {
el.setAttribute("class", "");
el.setAttribute("onClick", "closeHackTab()");
} else {
el.setAttribute("class", "is-active");
}
})
}
window.closeHackTab = () => {
if (!hackIsOpen) return;
hackIsOpen = false;
tabs[0].childNodes.forEach(el => {
if (el.id !== "hackTab") {
el.setAttribute("onClick", "closeHackTab()");
} else {
el.setAttribute("class", "");
}
})
$("#hackContent")[0].setAttribute("style", "display: none");
}
$(sections[0]).append(hackContent);
window.openHackTab();
window.newSet();
})()
4 打赏
打赏 10 积分后可见
-
evolve
已经放弃玩进化了
小黑屋后期就没内容了,所以都跑去进化了
还是手动刚吧
问下这个脚本怎么用啊?
这是咩啊