Melvor Idle - Queue End Fight

Adds a button to the combat interface to leave combat after defeating the current enemy or dungeon.

  1. // ==UserScript==
  2. // @name Melvor Idle - Queue End Fight
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.13
  5. // @description Adds a button to the combat interface to leave combat after defeating the current enemy or dungeon.
  6. // @author Seil#1780
  7. // @license MIT
  8. // @match https://melvoridle.com/*
  9. // @match https://*.melvoridle.com/*
  10. // @exclude https://wiki.melvoridle.com/*
  11. // @exclude https://*.wiki.melvoridle.com/*
  12. // @icon https://www.google.com/s2/favicons?sz=64&domain=melvoridle.com
  13. // @grant none
  14. // ==/UserScript==
  15.  
  16. ((main) => {
  17. const script = document.createElement('script');
  18. script.textContent = `try { (${main})(); } catch (e) { console.log(e); }`;
  19. document.body.appendChild(script).parentNode.removeChild(script);
  20. })(() => {
  21.  
  22. function queueEndFight() {
  23. var runQueued = false;
  24. var _oldOnEnemyDeath = combatManager.onEnemyDeath;
  25.  
  26. let queueRunButton = '<button type="button" id="queueRunButton" class="btn btn-sm btn-success m-1 w-100">Queue Leave Encounter</button>';
  27.  
  28. let combatButtons = document.querySelector("#combat-enemy-options").parentNode;
  29.  
  30. combatButtons.children[0].className = "col-4";
  31. combatButtons.children[1].className = "col-4";
  32. combatButtons.children[1].insertAdjacentHTML("afterend", '<div class="col-4"></div>');
  33. combatButtons.children[2].innerHTML += queueRunButton;
  34.  
  35. document.getElementById("queueRunButton").addEventListener("click", toggleQueue);
  36.  
  37. function toggleQueue() {
  38. if(runQueued) {
  39. document.getElementById("queueRunButton").className = "btn btn-sm btn-success m-1 w-100";
  40. document.getElementById("queueRunButton").textContent = "Queue Leave Encounter";
  41. runQueued = false;
  42. } else {
  43. document.getElementById("queueRunButton").className = "btn btn-sm btn-danger m-1 w-100";
  44. document.getElementById("queueRunButton").textContent = "Cancel Queued Action";
  45. runQueued = true;
  46. }
  47. }
  48.  
  49. combatManager.onEnemyDeath = function onEnemyDeath() {
  50. var encounterCompleted = false;
  51. var dungeonCompleted = this.dungeonProgress+1==this.areaData.monsters.length;
  52.  
  53. _oldOnEnemyDeath.apply(this);
  54. if(runQueued) {
  55. if(this.areaData.type==="Dungeon"&&!dungeonCompleted) {
  56. encounterCompleted = false;
  57. } else {
  58. encounterCompleted = true;
  59. this.stopCombat();
  60. toggleQueue();
  61. }
  62. } else {
  63. if(this.areaData.type==="Dungeon"&&dungeonCompleted&&!autoRestartDungeon) {
  64. encounterCompleted = true;
  65. this.stopCombat();
  66. }
  67. }
  68.  
  69. return encounterCompleted;
  70. }
  71. }
  72.  
  73. function loadScript() {
  74. if (typeof isLoaded !== typeof undefined && isLoaded) {
  75. // Only load script after game has opened
  76. clearInterval(scriptLoader);
  77. queueEndFight();
  78. }
  79. }
  80.  
  81. const scriptLoader = setInterval(loadScript, 200);
  82. });

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址