Base Saver

Record Base 8 Base

当前为 2021-12-23 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Base Saver
// @namespace    http://tampermonkey.net/
// @version      1
// @author       Havy
// @description  Record Base 8 Base 
// @match        zombs.io
// @grant        none
// ==/UserScript==

let css2 = `
.hud-menu-zipp3 {
display: none;
position: fixed;
top: 50%;
left: 50%;
width: 370px;
height: 376px;
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="Zippity3"]::before {
background-image: url("https://cdn-icons-png.flaticon.com/512/599/599063.png");
}
.hud-menu-zipp3 .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", "Zippity3");
spell.classList.add("hud-zipp3-icon");
document.getElementsByClassName("hud-spell-icons")[0].appendChild(spell);

let modHTML = `
<div class="hud-menu-zipp3">
<div class="hud-zipp-grid3">
</div>
</div>
`;
document.body.insertAdjacentHTML("afterbegin", modHTML);
let zipz123 = document.getElementsByClassName("hud-menu-zipp3")[0];

document.getElementsByClassName("hud-zipp3-icon")[0].addEventListener("click", function() {
    if(zipz123.style.display == "none" || zipz123.style.display == "") {
        zipz123.style.display = "block";
    } else {
        zipz123.style.display = "none";
    }
});

document.getElementsByClassName("hud-zipp-grid3")[0].innerHTML = `
<div style="text-align:center"><br>
<button class="0i3" onclick="RecordBase();">Record Base 1</button>
<button class="1i3" onclick="buildRecordedBase();">Build Base 1</button>
<button class="2i3" onclick="DeleteRecordedbase();">Delete Base 1</button>
<br class="3i3"><br class="4i3">

<button class="5i3" onclick="RecordBase2();">Record Base 2</button>
<button class="6i3" onclick="buildRecordedBase2();">Build Base 2</button>
<button class="7i3" onclick="DeleteRecordedbase2();">Delete Base 2</button>
<br class="8i3"><br class="9i3">

<button class="10i3" onclick="RecordBase3();">Record Base 3</button>
<button class="11i3" onclick="buildRecordedBase3();">Build Base 3</button>
<button class="12i3" onclick="DeleteRecordedbase3();">Delete Base 3</button>
<br class="13i3"><br class="14i3">

<button class="15i3" onclick="RecordBase4();">Record Base 4</button>
<button class="16i3" onclick="buildRecordedBase4();">Build Base 4</button>
<button class="17i3" onclick="DeleteRecordedbase4();">Delete Base 4</button>
<br class="18i3"><br class="19i3">

<button class="20i3" onclick="RecordBase5();">Record Base 5</button>
<button class="21i3" onclick="buildRecordedBase5();">Build Base 5</button>
<button class="22i3" onclick="DeleteRecordedbase5();">Delete Base 5</button>
<br class="23i3"><br class="24i3">

<button class="25i3" onclick="RecordBase6();">Record Base 6</button>
<button class="26i3" onclick="buildRecordedBase6();">Build Base 6</button>
<button class="27i3" onclick="DeleteRecordedbase6();">Delete Base 6</button>
<br class="28i3"><br class="29i3">

<button class="30i3" onclick="RecordBase7();">Record Base 7</button>
<button class="31i3" onclick="buildRecordedBase7();">Build Base 7</button>
<button class="32i3" onclick="DeleteRecordedbase7();">Delete Base 7</button>
<br class="33i3"><br class="34i3">

<button class="35i3" onclick="RecordBase8();">Record Base 8</button>
<button class="36i3" onclick="buildRecordedBase8();">Build Base 8</button>
<button class="37i3" onclick="DeleteRecordedbase8();">Delete Base 8</button>
<br class="38i3"><br class="39i3">

`;
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;
    })
}