// ==UserScript==
// @name Base Saver
// @namespace http://tampermonkey.net/
// @version 1.2
// @author Havy
// @description Record Base
// @match zombs.io
// @grant none
// ==/UserScript==
let css2 = `
.hud-menu-zipp4 {
display: none;
position: fixed;
top: 50%;
left: 50%;
width: 370px;
height: 220px;
margin: -200px 0 0 -182px;
background: rgba(0, 0, 0, 0.6);
color: #eee;
z-index: 5;
}
.hud-spell-icons .hud-spell-icon[data-type="Zippity4"]::before {
background-image: url("https://cdn-icons-png.flaticon.com/512/599/599063.png");
}
.hud-menu-zipp4 .hud-the-tab:hover {
background: rgba(0, 0, 0, 0.2);
color: #eee;
}
`;
let styles = document.createElement("style");
styles.appendChild(document.createTextNode(css2));
document.head.appendChild(styles);
styles.type = "text/css";
let spell = document.createElement("div");
spell.classList.add("hud-spell-icon");
spell.setAttribute("data-type", "Zippity4");
spell.classList.add("hud-zipp4-icon");
document.getElementsByClassName("hud-spell-icons")[0].appendChild(spell);
let modHTML = `
<div class="hud-menu-zipp4">
<div class="hud-zipp-grid4">
</div>
</div>
`;
document.body.insertAdjacentHTML("afterbegin", modHTML);
let zipz123 = document.getElementsByClassName("hud-menu-zipp4")[0];
document.getElementsByClassName("hud-zipp4-icon")[0].addEventListener("click", function () {
if (zipz123.style.display == "none" || zipz123.style.display == "") {
document.getElementById("hud-menu-shop")
.style.display = "none";
document.getElementById("hud-menu-party")
.style.display = "none";
document.getElementById("hud-menu-settings")
.style.display = "none";
zipz123.style.display = "block";
} else {
zipz123.style.display = "none";
};
});
let allIcon = [
document.getElementsByClassName("hud-menu-icon")[0],
document.getElementsByClassName("hud-menu-icon")[1],
document.getElementsByClassName("hud-menu-icon")[2],
document.getElementsByClassName("hud-spell-icon")[0],
document.getElementsByClassName("hud-spell-icon")[1]
];
allIcon.forEach(function (elem) {
elem.addEventListener("click", function () {
if (zipz123.style.display == "block") {
zipz123.style.display = "none";
};
});
});
document.getElementsByClassName("hud-zipp-grid4")[0].innerHTML = `
<div style="text-align:center"><br>
<button class="1bs" onclick="RecordBase();">Record Base 1</button>
<button class="2bs" onclick="buildRecordedBase();">Build Base 1</button>
<button class="3bs" onclick="DeleteRecordedbase();">Delete Base 1</button>
<button class="4bs" onclick="RecordBase2();">Record Base 2</button>
<button class="5bs" onclick="buildRecordedBase2();">Build Base 2</button>
<button class="6bs" onclick="DeleteRecordedbase2();">Delete Base 2</button>
<button class="7bs" onclick="RecordBase3();">Record Base 3</button>
<button class="8bs" onclick="buildRecordedBase3();">Build Base 3</button>
<button class="9bs" onclick="DeleteRecordedbase3();">Delete Base 3</button>
<button class="10bs" onclick="RecordBase4();">Record Base 4</button>
<button class="11bs" onclick="buildRecordedBase4();">Build Base 4</button>
<button class="12bs" onclick="DeleteRecordedbase4();">Delete Base 4</button>
<button class="13bs" onclick="RecordBase5();">Record Base 5</button>
<button class="14bs" onclick="buildRecordedBase5();">Build Base 5</button>
<button class="15bs" onclick="DeleteRecordedbase5();">Delete Base 5</button>
<button class="16bs" onclick="RecordBase6();">Record Base 6</button>
<button class="17bs" onclick="buildRecordedBase6();">Build Base 6</button>
<button class="18bs" onclick="DeleteRecordedbase6();">Delete Base 6</button>
<button class="19bs" onclick="RecordBase7();">Record Base 7</button>
<button class="20bs" onclick="buildRecordedBase7();">Build Base 7</button>
<button class="21bs" onclick="DeleteRecordedbase7();">Delete Base 7</button>
<button class="22bs" onclick="RecordBase8();">Record Base 8</button>
<button class="23bs" onclick="buildRecordedBase8();">Build Base 8</button>
<button class="24bs" onclick="DeleteRecordedbase8();">Delete Base 8</button>
`;
function GetGoldStash() {
for (let i in game.ui.buildings) {
if (game.ui.buildings[i].type == "GoldStash") {
return game.ui.buildings[i];
}
}
}
window.PlaceBuilding = function(x, y, building, yaw) {
Game.currentGame.network.sendRpc({
name: "MakeBuilding",
x: x,
y: y,
type: building,
yaw: yaw
})
}
//Base 1
window.RecordBase = function(baseName) {
Game.currentGame.ui.getComponent("PopupOverlay").showConfirmation("Are you sure you want to record base? If you recorded it twice, the first recorded base will be deleted.", 1e4, function() {
game.ui.components.PopupOverlay.showHint("Successfully recorded!");
let buildings = Game.currentGame.ui.buildings;
let base = "";
let stash = GetGoldStash();
if (stash == undefined) {
return
}
let stashPosition = {
x: stash.x,
y: stash.y
}
for (var uid in buildings) {
if (!buildings.hasOwnProperty(uid)) {
continue
}
let obj = buildings[uid]
let x = Game.currentGame.ui.buildings[obj.uid].x - stashPosition.x
let y = Game.currentGame.ui.buildings[obj.uid].y - stashPosition.y
let building = Game.currentGame.ui.buildings[obj.uid].type
let yaw = 180;
base += "PlaceBuilding(stashPosition.x + " + x + ", stashPosition.y + " + y + ", '" + building + "', " + yaw + ");"
}
localStorage.RecordedBase1 = base
})
}
window.buildRecordedBase = function() {
let waitForGoldStash = setInterval(function() {
if (document.querySelectorAll("[data-building]")[10].classList[1] == "is-disabled") {
stash = GetGoldStash();
if (stash == undefined) return
stashPosition = {
x: stash.x,
y: stash.y
}
clearInterval(waitForGoldStash)
game.ui.components.PopupOverlay.showHint("Successfully recorded base were built!");
var basecode = localStorage.RecordedBase1
basecode = new Function(basecode)
return basecode()
}
}, 275)
}
window.DeleteRecordedbase = function() {
Game.currentGame.ui.getComponent("PopupOverlay").showConfirmation("Are you sure you want to delete recorded base?", 1e4, function() {
game.ui.components.PopupOverlay.showHint("Successfully recorded base has been deleted!");
localStorage.RecordedBase1 = null;
})
}
//Base 2
window.RecordBase2 = function(baseName) {
Game.currentGame.ui.getComponent("PopupOverlay").showConfirmation("Are you sure you want to record base? If you recorded it twice, the first recorded base will be deleted.", 1e4, function() {
game.ui.components.PopupOverlay.showHint("Successfully recorded!");
let buildings = Game.currentGame.ui.buildings;
let base = "";
let stash = GetGoldStash();
if (stash == undefined) {
return
}
let stashPosition = {
x: stash.x,
y: stash.y
}
for (var uid in buildings) {
if (!buildings.hasOwnProperty(uid)) {
continue
}
let obj = buildings[uid]
let x = Game.currentGame.ui.buildings[obj.uid].x - stashPosition.x
let y = Game.currentGame.ui.buildings[obj.uid].y - stashPosition.y
let building = Game.currentGame.ui.buildings[obj.uid].type
let yaw = 180;
base += "PlaceBuilding(stashPosition.x + " + x + ", stashPosition.y + " + y + ", '" + building + "', " + yaw + ");"
}
localStorage.RecordedBase2 = base
})
}
window.buildRecordedBase2 = function() {
var waitForGoldStash = setInterval(function() {
if (document.querySelectorAll("[data-building]")[10].classList[1] == "is-disabled") {
stash = GetGoldStash();
if (stash == undefined) return
stashPosition = {
x: stash.x,
y: stash.y
}
clearInterval(waitForGoldStash)
game.ui.components.PopupOverlay.showHint("Successfully recorded base were built!");
var basecode = localStorage.RecordedBase2
basecode = new Function(basecode)
return basecode()
}
}, 275)
}
window.DeleteRecordedbase2 = function() {
Game.currentGame.ui.getComponent("PopupOverlay").showConfirmation("Are you sure you want to delete recorded base?", 1e4, function() {
game.ui.components.PopupOverlay.showHint("Successfully recorded base has been deleted!");
localStorage.RecordedBase2 = null;
})
}
//Base 3
window.RecordBase3 = function(baseName) {
Game.currentGame.ui.getComponent("PopupOverlay").showConfirmation("Are you sure you want to record base? If you recorded it twice, the first recorded base will be deleted.", 1e4, function() {
game.ui.components.PopupOverlay.showHint("Successfully recorded!");
let buildings = Game.currentGame.ui.buildings;
let base = "";
let stash = GetGoldStash();
if (stash == undefined) {
return
}
let stashPosition = {
x: stash.x,
y: stash.y
}
for (var uid in buildings) {
if (!buildings.hasOwnProperty(uid)) {
continue
}
let obj = buildings[uid]
let x = Game.currentGame.ui.buildings[obj.uid].x - stashPosition.x
let y = Game.currentGame.ui.buildings[obj.uid].y - stashPosition.y
let building = Game.currentGame.ui.buildings[obj.uid].type
let yaw = 180;
base += "PlaceBuilding(stashPosition.x + " + x + ", stashPosition.y + " + y + ", '" + building + "', " + yaw + ");"
}
localStorage.RecordedBase3 = base
})
}
window.buildRecordedBase3 = function() {
var waitForGoldStash = setInterval(function() {
if (document.querySelectorAll("[data-building]")[10].classList[1] == "is-disabled") {
stash = GetGoldStash();
if (stash == undefined) return
stashPosition = {
x: stash.x,
y: stash.y
}
clearInterval(waitForGoldStash)
game.ui.components.PopupOverlay.showHint("Successfully recorded base were built!");
var basecode = localStorage.RecordedBase3
basecode = new Function(basecode)
return basecode()
}
}, 275)
}
window.DeleteRecordedbase3 = function() {
Game.currentGame.ui.getComponent("PopupOverlay").showConfirmation("Are you sure you want to delete recorded base?", 1e4, function() {
game.ui.components.PopupOverlay.showHint("Successfully recorded base has been deleted!");
localStorage.RecordedBase3 = null;
})
}
//Base 4
window.RecordBase4 = function(baseName) {
Game.currentGame.ui.getComponent("PopupOverlay").showConfirmation("Are you sure you want to record base? If you recorded it twice, the first recorded base will be deleted.", 1e4, function() {
game.ui.components.PopupOverlay.showHint("Successfully recorded!");
let buildings = Game.currentGame.ui.buildings;
let base = "";
let stash = GetGoldStash();
if (stash == undefined) {
return
}
let stashPosition = {
x: stash.x,
y: stash.y
}
for (var uid in buildings) {
if (!buildings.hasOwnProperty(uid)) {
continue
}
let obj = buildings[uid]
let x = Game.currentGame.ui.buildings[obj.uid].x - stashPosition.x
let y = Game.currentGame.ui.buildings[obj.uid].y - stashPosition.y
let building = Game.currentGame.ui.buildings[obj.uid].type
let yaw = 180;
base += "PlaceBuilding(stashPosition.x + " + x + ", stashPosition.y + " + y + ", '" + building + "', " + yaw + ");"
}
localStorage.RecordedBase4 = base
})
}
window.buildRecordedBase4 = function() {
var waitForGoldStash = setInterval(function() {
if (document.querySelectorAll("[data-building]")[10].classList[1] == "is-disabled") {
stash = GetGoldStash();
if (stash == undefined) return
stashPosition = {
x: stash.x,
y: stash.y
}
clearInterval(waitForGoldStash)
game.ui.components.PopupOverlay.showHint("Successfully recorded base were built!");
var basecode = localStorage.RecordedBase4
basecode = new Function(basecode)
return basecode()
}
}, 275)
}
window.DeleteRecordedbase4 = function() {
Game.currentGame.ui.getComponent("PopupOverlay").showConfirmation("Are you sure you want to delete recorded base?", 1e4, function() {
game.ui.components.PopupOverlay.showHint("Successfully recorded base has been deleted!");
localStorage.RecordedBase4 = null;
})
}
//Base 5
window.RecordBase5 = function(baseName) {
Game.currentGame.ui.getComponent("PopupOverlay").showConfirmation("Are you sure you want to record base? If you recorded it twice, the first recorded base will be deleted.", 1e4, function() {
game.ui.components.PopupOverlay.showHint("Successfully recorded!");
let buildings = Game.currentGame.ui.buildings;
let base = "";
let stash = GetGoldStash();
if (stash == undefined) {
return
}
let stashPosition = {
x: stash.x,
y: stash.y
}
for (var uid in buildings) {
if (!buildings.hasOwnProperty(uid)) {
continue
}
let obj = buildings[uid]
let x = Game.currentGame.ui.buildings[obj.uid].x - stashPosition.x
let y = Game.currentGame.ui.buildings[obj.uid].y - stashPosition.y
let building = Game.currentGame.ui.buildings[obj.uid].type
let yaw = 180;
base += "PlaceBuilding(stashPosition.x + " + x + ", stashPosition.y + " + y + ", '" + building + "', " + yaw + ");"
}
localStorage.RecordedBase5 = base
})
}
window.buildRecordedBase5 = function() {
var waitForGoldStash = setInterval(function() {
if (document.querySelectorAll("[data-building]")[10].classList[1] == "is-disabled") {
stash = GetGoldStash();
if (stash == undefined) return
stashPosition = {
x: stash.x,
y: stash.y
}
clearInterval(waitForGoldStash)
game.ui.components.PopupOverlay.showHint("Successfully recorded base were built!");
var basecode = localStorage.RecordedBase5
basecode = new Function(basecode)
return basecode()
}
}, 275)
}
window.DeleteRecordedbase5 = function() {
Game.currentGame.ui.getComponent("PopupOverlay").showConfirmation("Are you sure you want to delete recorded base?", 1e4, function() {
game.ui.components.PopupOverlay.showHint("Successfully recorded base has been deleted!");
localStorage.RecordedBase5 = null;
})
}
//Base 6
window.RecordBase6 = function(baseName) {
Game.currentGame.ui.getComponent("PopupOverlay").showConfirmation("Are you sure you want to record base? If you recorded it twice, the first recorded base will be deleted.", 1e4, function() {
game.ui.components.PopupOverlay.showHint("Successfully recorded!");
let buildings = Game.currentGame.ui.buildings;
let base = "";
let stash = GetGoldStash();
if (stash == undefined) {
return
}
let stashPosition = {
x: stash.x,
y: stash.y
}
for (var uid in buildings) {
if (!buildings.hasOwnProperty(uid)) {
continue
}
let obj = buildings[uid]
let x = Game.currentGame.ui.buildings[obj.uid].x - stashPosition.x
let y = Game.currentGame.ui.buildings[obj.uid].y - stashPosition.y
let building = Game.currentGame.ui.buildings[obj.uid].type
let yaw = 180;
base += "PlaceBuilding(stashPosition.x + " + x + ", stashPosition.y + " + y + ", '" + building + "', " + yaw + ");"
}
localStorage.RecordedBase6 = base
})
}
window.buildRecordedBase6 = function() {
var waitForGoldStash = setInterval(function() {
if (document.querySelectorAll("[data-building]")[10].classList[1] == "is-disabled") {
stash = GetGoldStash();
if (stash == undefined) return
stashPosition = {
x: stash.x,
y: stash.y
}
clearInterval(waitForGoldStash)
game.ui.components.PopupOverlay.showHint("Successfully recorded base were built!");
var basecode = localStorage.RecordedBase6
basecode = new Function(basecode)
return basecode()
}
}, 275)
}
window.DeleteRecordedbase6 = function() {
Game.currentGame.ui.getComponent("PopupOverlay").showConfirmation("Are you sure you want to delete recorded base?", 1e4, function() {
game.ui.components.PopupOverlay.showHint("Successfully recorded base has been deleted!");
localStorage.RecordedBase6 = null;
})
}
//Base 7
window.RecordBase7 = function(baseName) {
Game.currentGame.ui.getComponent("PopupOverlay").showConfirmation("Are you sure you want to record base? If you recorded it twice, the first recorded base will be deleted.", 1e4, function() {
game.ui.components.PopupOverlay.showHint("Successfully recorded!");
let buildings = Game.currentGame.ui.buildings;
let base = "";
let stash = GetGoldStash();
if (stash == undefined) {
return
}
let stashPosition = {
x: stash.x,
y: stash.y
}
for (var uid in buildings) {
if (!buildings.hasOwnProperty(uid)) {
continue
}
let obj = buildings[uid]
let x = Game.currentGame.ui.buildings[obj.uid].x - stashPosition.x
let y = Game.currentGame.ui.buildings[obj.uid].y - stashPosition.y
let building = Game.currentGame.ui.buildings[obj.uid].type
let yaw = 180;
base += "PlaceBuilding(stashPosition.x + " + x + ", stashPosition.y + " + y + ", '" + building + "', " + yaw + ");"
}
localStorage.RecordedBase7 = base
})
}
window.buildRecordedBase7 = function() {
var waitForGoldStash = setInterval(function() {
if (document.querySelectorAll("[data-building]")[10].classList[1] == "is-disabled") {
stash = GetGoldStash();
if (stash == undefined) return
stashPosition = {
x: stash.x,
y: stash.y
}
clearInterval(waitForGoldStash)
game.ui.components.PopupOverlay.showHint("Successfully recorded base were built!");
var basecode = localStorage.RecordedBase7
basecode = new Function(basecode)
return basecode()
}
}, 275)
}
window.DeleteRecordedbase7 = function() {
Game.currentGame.ui.getComponent("PopupOverlay").showConfirmation("Are you sure you want to delete recorded base?", 1e4, function() {
game.ui.components.PopupOverlay.showHint("Successfully recorded base has been deleted!");
localStorage.RecordedBase7 = null;
})
}
//Base 8
window.RecordBase8 = function(baseName) {
Game.currentGame.ui.getComponent("PopupOverlay").showConfirmation("Are you sure you want to record base? If you recorded it twice, the first recorded base will be deleted.", 1e4, function() {
game.ui.components.PopupOverlay.showHint("Successfully recorded!");
let buildings = Game.currentGame.ui.buildings;
let base = "";
let stash = GetGoldStash();
if (stash == undefined) {
return
}
let stashPosition = {
x: stash.x,
y: stash.y
}
for (var uid in buildings) {
if (!buildings.hasOwnProperty(uid)) {
continue
}
let obj = buildings[uid]
let x = Game.currentGame.ui.buildings[obj.uid].x - stashPosition.x
let y = Game.currentGame.ui.buildings[obj.uid].y - stashPosition.y
let building = Game.currentGame.ui.buildings[obj.uid].type
let yaw = 180;
base += "PlaceBuilding(stashPosition.x + " + x + ", stashPosition.y + " + y + ", '" + building + "', " + yaw + ");"
}
localStorage.RecordedBase8 = base
})
}
window.buildRecordedBase8 = function() {
var waitForGoldStash = setInterval(function() {
if (document.querySelectorAll("[data-building]")[10].classList[1] == "is-disabled") {
stash = GetGoldStash();
if (stash == undefined) return
stashPosition = {
x: stash.x,
y: stash.y
}
clearInterval(waitForGoldStash)
game.ui.components.PopupOverlay.showHint("Successfully recorded base were built!");
var basecode = localStorage.RecordedBase8
basecode = new Function(basecode)
return basecode()
}
}, 275)
}
window.DeleteRecordedbase8 = function() {
Game.currentGame.ui.getComponent("PopupOverlay").showConfirmation("Are you sure you want to delete recorded base?", 1e4, function() {
game.ui.components.PopupOverlay.showHint("Successfully recorded base has been deleted!");
localStorage.RecordedBase8 = null;
})
}