try to take over the world over and over again!
// ==UserScript== // @name repeat order is a good order // @version 2024-05-04 // @description try to take over the world over and over again! // @author Your friend // @match https://www.erepublik.com/es/military/battlefield/* // @icon https://www.google.com/s2/favicons?sz=64&domain=erepublik.com // @grant none // @namespace https://greasyfork.org/users/1144622 // ==/UserScript== (function() { 'use strict'; const capthca = checkSessionValidationExists(); if (!capthca) { main(); } async function main() { const zs = SERVER_DATA.zoneStarted; const bf = SERVER_DATA.battleFinished; const rw = SERVER_DATA.isResistance; const dp = SERVER_DATA.points.defender; const ap = SERVER_DATA.points.attacker; const health = SERVER_DATA.health; const bId = SERVER_DATA.battleId; const zId = SERVER_DATA.battleZoneId; const side = SERVER_DATA.mySideCountryId; const div = SERVER_DATA.currentDivision; const round = SERVER_DATA.currentRoundNumber; const loc = erepublik.citizen.countryLocationId; const tok = csrfToken; let weapQu = -1; if (div != 11) { weapQu = 7; } await delay(2000); if (zs == true && bf == 0 && rw == false && dp < 1700 && ap < 1700 && health > 599 && side == loc) { const loops = Math.floor(health / 600); for (let i = 0; i < loops; i++) { const getInventory = "https://www.erepublik.com/en/military/fightDeploy-getInventory"; const inventoryLoad = inventoryPayload(bId, loc, zId, tok); const inventory = await PostRequest(inventoryLoad, getInventory); const bag = skinAndDph(inventory, weapQu); let pool = inventory.poolEnergy; const skin = bag.skinId; const damage = bag.damageBonus; const wAmount = bag.weaponAmount; const damageHit = 600; if (pool > damageHit) { const rocketLoad = deployLoad(bId, zId, loc, weapQu, damageHit, skin, tok); const Deployurl = 'https://www.erepublik.com/en/military/fightDeploy-startDeploy'; console.log(rocketLoad); await PostRequest(rocketLoad, Deployurl); let restTime; if (weapQu == 10) { restTime = (damageHit / 10) * 1010; } else { restTime = (damageHit / 10) * 366; } await delay(restTime); } await delay(1000); } } } function checkSessionValidationExists() { if (typeof SERVER_DATA !== 'undefined' && SERVER_DATA.sessionValidation !== undefined) { return true; } else { return false; } } //payload for inventory function inventoryPayload(battleId, sideCountryId, battleZoneId, _token) { return { battleId, sideCountryId, battleZoneId, _token }; } //function to deploy function deployLoad(battleId, battleZoneId, sideCountryId, weaponQuality, totalEnergy, skinId, _token) { return { battleId, battleZoneId, sideCountryId, weaponQuality, totalEnergy, skinId, _token }; } function skinAndDph(inventory, weapQu) { const listweapon = inventory.weapons; const vehicles = inventory.vehicles; let weaponAmount; let dph; let skinId; let skinBonus; const objectWithQuality = listweapon.find(item => item.quality === weapQu); if (objectWithQuality) { weaponAmount = objectWithQuality.amount; dph = objectWithQuality.damageperHit; } const skinRecommended = vehicles.find(skin => skin.isRecommended === true); if (skinRecommended) { skinId = skinRecommended.id; skinBonus = skinRecommended.countryData.damageBonus; } let percentage = 0; if (skinBonus !== null) { percentage = skinBonus / 100; } let damageBonus = dph + (dph * percentage); return { damageBonus, skinId, weaponAmount }; } // Function to send the payload using POST request async function PostRequest(payload, url) { try { const response = await fetch(url, { method: "POST", headers: { "Content-Type": "application/x-www-form-urlencoded" }, body: Object.keys(payload) .map(key => `${encodeURIComponent(key)}=${encodeURIComponent(payload[key])}`) .join('&') }); const responseData = await response.json(); return responseData; } catch (error) { console.error("Error:", error); return null; } } function delay(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } })();