Greasy Fork is available in English.

Melvor Auto Battler & Auto Thiever

Will auto loot, and auto eat for you. If you run out of food it will exit combat. 100% afk-able. Also works for thieving

// ==UserScript==
// @name         Melvor Auto Battler & Auto Thiever
// @match https://melvoridle.com/*
// @version       2.1.7
// @description Will auto loot, and auto eat for you. If you run out of food it will exit combat. 100% afk-able. Also works for thieving
// @description
// @description
// @author @Shock#5170
// @namespace https://greasyfork.org/users/686982
// ==/UserScript==





function getCurrentLootInBag(){ return parseInt(document.querySelector("#combat-loot-text").innerHTML.substring(17,19));}
function getCurrentHp(){ var hpClass = document.getElementById('combat-player-hitpoints-current');var tempCurrentHp= hpClass.innerHTML; return parseInt(tempCurrentHp);}
function getMaxHp(){ var hpClass = document.getElementById('combat-player-hitpoints-max'); var tempMaxHp = hpClass.innerHTML; return parseInt(tempMaxHp);}



function eatFood(max){
     var foodButton = document.getElementsByClassName("btn-outline-secondary")[0];
    try{
     var enemyDamage = parseInt(document.getElementById("combat-enemy-strength-bonus").innerHTML.split("(").join('').split(")").join(""));
    }catch(e){
    }

    //if user has no food equipped
     if(foodButton.innerText.trim() == "Empty"){
        exitFight();
     }

    else{

    //if user has food
     var food_AmountOfHealth = parseInt(foodButton.innerText.split("+").join(",").split("HP").join(",").split(",")[1]);
     var healthDifference = max - getCurrentHp();
     var eatable = healthDifference / food_AmountOfHealth;
     var timesToEat = Math.floor(eatable);

    
     if(eatable > 1){
       Math.floor(eatable);
      } 

     if(enemyDamage > getCurrentHp()){
            foodButton.click();
            timesToEat--;
            for(let i=1; i <= timesToEat;i++){
                foodButton.click();

        }
     }
        if(Number.isNaN(enemyDamage)){
            for(let i=1; i <= timesToEat;i++){
                foodButton.click();
                
            }
            
        }
}
}
function exitFight(){
     var runButton = document.getElementById("combat-btn-run");
     runButton.click();
}

function loot(){
 var button = $("button.btn-sm.btn-success")[1];
 var currentLoot = parseInt(document.querySelector("#combat-loot-text").innerHTML.substring(17,19));
 if(currentLoot >= 14){
     button.click();
 }

}

function main(){
 try{
    eatFood(getMaxHp());
    loot();
 }catch(Exception){
 }


}
function init() {
   window.setInterval(main,2000);
}



init();