// ==UserScript== // @name Zoom innit orig // @namespace https://s38-en.bitefight.gameforge.com // @version 0.1 // @license MIT // @description zoom // @author not me // @match https://s38-en.bitefight.gameforge.com/* // @grant GM_getValue // @grant GM_setValue // @grant GM_addStyle // @require https://code.jquery.com/jquery-2.1.4.min.js // ==/UserScript== /* globals $ */ (function () { 'use strict'; // Constants const DEFAULT_REQUEST_DELAY_IN_MILLISECONDS = 682 + (Math.random() * 424); const SKILLS = ["STR", "DEF", "DEX", "RES", "CHA"]; const RAISESKILLS = false; const DIFFICULTYOGROTTE = 2; // 0 = Easy | 1 = Medium | 2 = Hard const SERVERURL = "https://s38-en.bitefight.gameforge.com"; // Script storage keys const KEY_CHARACTER = 'character'; // Define character object const CHARACTER = GM_getValue(KEY_CHARACTER, { energy: 0, fragments: 0, gold: 0, health: 0, hellStones: 0, skills: { STR: 0, DEF: 0, DEX: 0, RES: 0, CHA: 0 }, maxEnergy: 0, maxHealth: 0 }); // Get Stats var allStatsElement = document.getElementsByClassName("gold")[0]; var statsValues = allStatsElement.textContent.split("\n"); statsValues = statsValues.map(value => value.trim()); statsValues.shift(); // Separate and assign values var energy = formatNumber(statsValues[3].substr(0, statsValues[3].indexOf("/") - 1)); if (energy) CHARACTER.energy = parseInt(energy); var fragments = formatNumber(statsValues[2]); if (fragments) CHARACTER.fragments = parseInt(fragments); var gold = formatNumber(statsValues[0]); if (gold) CHARACTER.gold = parseInt(gold); var health = formatNumber(statsValues[4].substr(0, statsValues[4].indexOf("/") - 1)); if (health) CHARACTER.health = parseInt(health); var hellStones = formatNumber(statsValues[1]); if (hellStones) CHARACTER.hellStones = parseInt(hellStones); var maxEnergy = formatNumber(statsValues[3].substring(statsValues[3].indexOf("/") + 1)); if (maxEnergy) CHARACTER.maxEnergy = parseInt(maxEnergy); var maxHealth = formatNumber(statsValues[4].substring(statsValues[4].indexOf("/") + 1)); if (maxHealth) CHARACTER.maxHealth = parseInt(maxHealth); updateCharacter(); setTimeout(() => { if(location.pathname.includes("/report/fightreport/")){ goToGrotte(); } }, DEFAULT_REQUEST_DELAY_IN_MILLISECONDS - 300); setTimeout(() => { switch (location.pathname) { case "/profile": case "/profile/index": var token = document.getElementsByClassName("btn")[2].href.split("=")[1]; var activeArray = document.getElementsByClassName("active"); var inactiveArray = document.getElementsByClassName("inactive"); if(energy < (maxEnergy-21)){ //165 //351 var energyPotionExist = false; for (let i = 0; i < activeArray.length; i++) { if (activeArray[i].textContent.includes("Energy Potion")){ energyPotionExist = true; } } for (let i = 0; i < inactiveArray.length; i++) { if (inactiveArray[i].textContent.includes("Energy Potion")){ location = "https://s38-en.bitefight.gameforge.com:443/profile/useItem/2/17?__token=" + token console.log("used potion") break; } } setTimeout(() => { if (!energyPotionExist) { goToMerchantPotions(); console.log("Go To Merchant"); } }, 3000); } /* var chosenSkill = 0; var skillsTable = document.querySelector("div#skills_tab > div > div > div > table"); getSkills(skillsTable, chosenSkill); updateCharacter(); RAISESKILLS ?? raiseSkills(skillsTable, chosenSkill); */ setTimeout(() => { goToGrotte(); }, 5000); break; case "/city/shop/potions/": token = document.getElementsByClassName("btn")[2].href.split("=")[1]; var btnArrayy = document.getElementsByClassName("btn") var purchaseAvailable = false; var x = 0; for (let i = 1; i < btnArrayy.length; i++){ try { console.log(i) if (btnArrayy[i].href.includes("/potions/buy/17/1/")){ purchaseAvailable = true; } if (btnArrayy[i].href.includes("/potions/buy/17/5/")){ purchaseAvailable = true; } if (btnArrayy[i].href.includes("/potions/buy/17/10/")){ purchaseAvailable = true; } x = i } catch(err) { console.log("error, probably no href") continue; } } if(purchaseAvailable) btnArrayy[x].click(); break; setTimeout(() => { goToProfile(); }, 5000); break case "/city/shop": setTimeout(() => { goToProfile(); }, 3000); break; case "/robbery/index": /* var cost = 1; var huntChances = []; var huntOptions = []; document.querySelectorAll("div.mjs").forEach(node => huntOptions.push(node)); huntOptions.forEach(option => { var lookupText = "chance of success: "; var text = option.innerHTML; cost = parseInt(option.innerText.substring(option.innerText.indexOf("(") + 1, option.innerText.indexOf(")")).trim()); huntChances.push(parseInt(text.substr(text.indexOf(lookupText) + lookupText.length, 2))); }); var chosenHunt = 1; for (let i = 0; i < huntChances.length; i++) { if (huntChances[i] >= 70 && CHARACTER.energy >= cost) chosenHunt = i + 1; } */ //doHunt(chosenHunt); break; case "/robbery/humanhunt/1": case "/robbery/humanhunt/2": case "/robbery/humanhunt/3": case "/robbery/humanhunt/4": case "/robbery/humanhunt/5": if (CHARACTER.energy > 0) document.forms[0].submit(); else goToAbilities(); break; case "/city/graveyard": if (CHARACTER.energy < 1) { var workOptions = document.getElementsByName("workDuration")[0]; if (workOptions) { workOptions.value = 1; document.forms[0].submit(); } } else goToGrotte(); break; case "/report/fightreport": goToGrotte(); break; case "/city/grotte": CHARACTER.energy > 0 ? huntDemons() : goToWork(); break; case "/user/working": var workDuration = timeToMilliseconds($("#graveyardCount span").text()); setTimeout(() => { goToProfile(); }, parseInt(workDuration) - 2000); break; default: goToProfile(); break; } }, DEFAULT_REQUEST_DELAY_IN_MILLISECONDS); // Format texts to return as numbers (no thousand separators) function formatNumber(value) { while (value.indexOf(".") > 0) value = value.replace(".", ""); return value; } function goToProfile() { location = SERVERURL + "/profile"; } function goHunting() { location = SERVERURL + "/robbery/index"; } function goToWork(){ location = SERVERURL + "/city/graveyard"; } function goToAbilities() { location = SERVERURL + "/profile/index#tabs-2"; } function goToGrotte() { location = SERVERURL + "/city/grotte"; } function goToMerchantPotions() { location = SERVERURL + "/city/shop/potions/"; } function huntDemons() { $("table.noBackground form.clearfix div input")[DIFFICULTYOGROTTE].click(); } // Gets the basic value for a skill in given table cell. function getSkillValue(cell) { return parseInt(cell.querySelector("table > tbody > tr:nth-child(5n) > td:nth-child(2n)").textContent); } function getSkills(skillsTable, chosenSkill) { var auxValue = Math.min(); for (let i = 0; i < SKILLS.length; i++) { let value = getSkillValue(skillsTable.rows[i].cells[1]); CHARACTER.skills[SKILLS[i]] = parseInt(value); if (value < auxValue) { auxValue = value; chosenSkill = i; } } } function raiseSkills(skillsTable, chosenSkill) { if (skillsTable.rows[chosenSkill].cells[2].textContent.indexOf("don't have enough gold") > -1) { CHARACTER.energy > 0 ? goHunting() : goToWork(); } else { skillsTable.rows[chosenSkill].cells[2].querySelector("div > a").click(); } } function timeToMilliseconds(time) { const [hours, minutes, seconds] = time.split(':').map(Number); const totalMilliseconds = (hours * 3600 + minutes * 60 + seconds) * 1000; return totalMilliseconds; } // Update character in local storage function updateCharacter() { GM_setValue(KEY_CHARACTER, CHARACTER); } })();