// ==UserScript==
// @name Shop Shortcut
// @namespace http://tampermonkey.net/
// @version 2
// @description Fast & Convenient
// @author vn_Havy
// @match http://zombs.io/*
// @grant none
// @downloadURL none
// ==/UserScript==
document.getElementsByClassName("hud-top-center")[0].innerHTML = `
`;
document.getElementById('shopshortcut1').addEventListener('click', buyPickaxe);
document.getElementById('shopshortcut2').addEventListener('click', buySpear);
document.getElementById('shopshortcut3').addEventListener('click', buyBow);
document.getElementById('shopshortcut4').addEventListener('click', buyBomb);
document.getElementById('shopshortcut5').addEventListener('click', heal);
document.getElementById('shopshortcut6').addEventListener('click', petHeal);
document.getElementById('shopshortcut7').addEventListener('click', buyZombieShield);
document.getElementById('shopshortcut8').addEventListener('click', revivePet);
document.getElementById('shopshortcut9').addEventListener('click', sellPet);
document.getElementById('shopshortcut10').addEventListener('click', miner);
document.getElementById('shopshortcut11').addEventListener('click', carl);
function equipPet(num) {
if (game.ui.playerTick.petUid !== 0) {
sellPet()
}
let i = 0
let clickEquip
clickEquip = setInterval(function() {
console.log(i)
document.querySelectorAll(".hud-shop-actions-equip")[num].click();
i++
if (i >= 20) {
i = 0
clearInterval(clickEquip)
}
},250)
}
function carl() {
equipPet(1)
}
function miner() {
equipPet(2)
}
function heal() {
shopShortcut("HealthPotion", 1)
}
function petHeal() {
shopShortcut("PetHealthPotion", 1)
}
function revivePet() {
shopShortcut("PetRevive", 1)
}
function equipItem(item, tier) {
game.network.sendRpc({
name: "EquipItem",
itemName: item,
tier: tier
})
};
function buyItem(item, tier) {
game.network.sendRpc({
name: "BuyItem",
itemName: item,
tier: tier
})
}
function shopShortcut(item, tier) {
buyItem(item, tier)
if (game.ui.playerWeaponName !== item) {
equipItem(item, tier)
}
}
function buyPickaxe() {
let gold = game.ui.playerTick.gold
let pickaxe = game.ui.inventory.Pickaxe
if (pickaxe.tier == 1 && gold >= 1000) {
shopShortcut("Pickaxe", 2)
return
}
if (pickaxe.tier == 2 && gold >= 3000) {
shopShortcut("Pickaxe", 3);
return
}
if (pickaxe.tier == 3 && gold >= 5000) {
shopShortcut("Pickaxe", 4);
return
}
if (pickaxe.tier == 4 && gold >= 8000) {
shopShortcut("Pickaxe", 5);
return
}
if (pickaxe.tier == 5 && gold >= 24000) {
shopShortcut("Pickaxe", 6);
return
}
if (pickaxe.tier == 6 && gold >= 90000) {
shopShortcut("Pickaxe", 7);
return
} else if (game.ui.playerWeaponName !== "Pickaxe") {
equipItem("Pickaxe", game.ui.inventory.Pickaxe.tier)
}
}
function buySpear() {
let gold = game.ui.playerTick.gold
let spear = game.ui.inventory.Spear
if (!spear && gold >= 1400) {
shopShortcut("Spear", 1)
return
}
if (spear.tier == 1 && gold >= 2800) {
shopShortcut("Spear", 2)
return
}
if (spear.tier == 2 && gold >= 5600) {
shopShortcut("Spear", 3)
return
}
if (spear.tier == 3 && gold >= 11200) {
shopShortcut("Spear", 4)
return
}
if (spear.tier == 4 && gold >= 22500) {
shopShortcut("Spear", 5)
return
}
if (spear.tier == 5 && gold >= 45000) {
shopShortcut("Spear", 6)
return
}
if (spear.tier == 6 && gold >= 90000) {
shopShortcut("Spear", 7)
return
} else if (game.ui.playerWeaponName !== "Spear"){
equipItem("Spear", game.ui.inventory.Spear.tier)
}
}
function buyBow() {
let gold = game.ui.playerTick.gold
let bow = game.ui.inventory.Bow
if (!bow && gold >= 100) {
shopShortcut("Bow", 1)
return
}
if (bow.tier == 1 && gold >= 400) {
shopShortcut("Bow", 2)
return
}
if (bow.tier == 2 && gold >= 2000) {
shopShortcut("Bow", 3)
return
}
if (bow.tier == 3 && gold >= 7000) {
shopShortcut("Bow", 4)
return
}
if (bow.tier == 4 && gold >= 24000) {
shopShortcut("Bow", 5)
return
}
if (bow.tier == 5 && gold >= 30000) {
shopShortcut("Bow", 6)
return
}
if (bow.tier == 6 && gold >= 90000) {
shopShortcut("Bow", 7)
return
} else if (game.ui.playerWeaponName !== "Bow"){
equipItem("Bow", game.ui.inventory.Bow.tier)
}
}
function buyBomb() {
let gold = game.ui.playerTick.gold
let bomb = game.ui.inventory.Bomb
if (!bomb && gold >= 100) {
shopShortcut("Bomb", 1)
return
}
if (bomb.tier == 1 && gold >= 400) {
shopShortcut("Bomb", 2)
return
}
if (bomb.tier == 2 && gold >= 3000) {
shopShortcut("Bomb", 3)
return
}
if (bomb.tier == 3 && gold >= 5000) {
shopShortcut("Bomb", 4)
return
}
if (bomb.tier == 4 && gold >= 24000) {
shopShortcut("Bomb", 5)
return
}
if (bomb.tier == 5 && gold >= 50000) {
shopShortcut("Bomb", 6)
return
}
if (bomb.tier == 6 && gold >= 90000) {
shopShortcut("Bomb", 7)
return
} else if (game.ui.playerWeaponName !== "Bomb"){
equipItem("Bomb", game.ui.inventory.Bomb.tier)
}
}
function buyZombieShield() {
let gold = game.ui.playerTick.gold
let shield = game.ui.inventory.ZombieShield
if (!shield && gold >= 1000) {
buyItem("ZombieShield", 1)
return
}
if (shield.tier == 1 && gold >= 3000) {
buyItem("ZombieShield", 2)
return
}
if (shield.tier == 2 && gold >= 7000) {
buyItem("ZombieShield", 3)
return
}
if (shield.tier == 3 && gold >= 14000) {
buyItem("ZombieShield", 4)
return
}
if (shield.tier == 4 && gold >= 18000) {
buyItem("ZombieShield", 5)
return
}
if (shield.tier == 5 && gold >= 22000) {
buyItem("ZombieShield", 6)
return
}
if (shield.tier == 6 && gold >= 24000) {
buyItem("ZombieShield", 7)
return
}
if (shield.tier == 7 && gold >= 30000) {
buyItem("ZombieShield", 8)
return
}
if (shield.tier == 8 && gold >= 45000) {
buyItem("ZombieShield", 9)
return
}
if (shield.tier == 9 && gold >= 70000) {
buyItem("ZombieShield", 10)
return
}
}
function sellPet() {
for(let uid in game.world.entities) {
if (game.world.entities[uid].fromTick.model == "PetCARL" || game.world.entities[uid].fromTick.model == "PetMiner") {
Game.currentGame.network.sendRpc({
name: "DeleteBuilding",
uid: game.world.entities[uid].fromTick.uid
});
}
}
}