// ==UserScript== // @name eRep Energy Recovery // @name:ro Recuperare energie eRep // @description Energy recovery for eRebuglik // @description:ro Recuperare energie pentru eRebuglik // @namespace http://www.linuxmint.ro/ // @version 1.1 // @license CC BY 4.0 // @author Nicolae Crefelean // @include http*://www.erepublik.com/* // @grant none // @downloadURL none // ==/UserScript== if (typeof jQuery !== "undefined") { jQuery(function() { var gameInactivity = 0; var gameRefresh = 0; // returns true|false whether energy can be recovered (bar not filled) function energyAvailable() { return jQuery(".tooltip_health_limit").length && parseInt(jQuery(".tooltip_health_limit").text().trim()) > 0; } // return true|false whether the energy can be recovered with food function foodAvailable() { return jQuery("#foodText").length && jQuery("#eat_food_text").val().trim() == jQuery("#foodText").text().trim() || jQuery("#heal_btn").length && jQuery("#heal_btn").attr("class") == "food_btn"; } // resets the inactivity counter if the user is active in the game jQuery(document).on("click mousemove keyup keydown keypress", function() { gameInactivity = 0; }); // check the user's game activity and feed if not active for more than 5 seconds; also, refresh if inactive for more than 1 hour setInterval(function() { if (energyAvailable() && foodAvailable() && gameInactivity >= 5) { energy.eatFood(); if (gameRefresh > 3600) { location.reload(); gameRefresh = 0; } gameInactivity = 0; } gameInactivity++; gameRefresh++; }, 1000); }); }