Melvor Idle - Queue End Fight

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

当前为 2022-04-30 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Melvor Idle - Queue End Fight
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  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. // @exclude https://wiki.melvoridle.com/*
  10. // @exclude https://*.wiki.melvoridle.com/*
  11. // @icon https://www.google.com/s2/favicons?sz=64&domain=melvoridle.com
  12. // @grant none
  13. // ==/UserScript==
  14.  
  15. function script() {
  16. var runQueued = false;
  17. var _oldFunction = combatManager.onEnemyDeath;
  18.  
  19. let queueRunButton = '<button type="button" id="queueRunButton" class="btn btn-sm btn-warning m-1 w-100">Queue Leave Encounter</button>';
  20.  
  21. let combatButtons = document.querySelector("#combat-enemy-options").parentNode;
  22. let runButton = document.querySelector("#combat-enemy-options");
  23.  
  24. combatButtons.children[0].className = "col-4";
  25. combatButtons.children[1].className = "col-4";
  26. combatButtons.children[1].insertAdjacentHTML("afterend", '<div class="col-4"></div>');
  27. combatButtons.children[2].innerHTML += queueRunButton
  28.  
  29. document.getElementById("queueRunButton").addEventListener("click", toggleQueue);
  30.  
  31. function toggleQueue() {
  32. if(runQueued) {
  33. document.getElementById("queueRunButton").className = "btn btn-sm btn-warning m-1 w-100";
  34. runQueued = false;
  35. } else {
  36. document.getElementById("queueRunButton").className = "btn btn-sm btn-danger m-1 w-100";
  37. runQueued = true;
  38. }
  39. }
  40.  
  41. combatManager.onEnemyDeath = function onEnemyDeath() {
  42. var encounterCompleted = false;
  43. var dungeonCompleted = this.dungeonProgress+1==this.areaData.monsters.length;
  44.  
  45. _oldFunction.apply(this);
  46. if(runQueued) {
  47. if(this.areaData.type==="Dungeon"&&!dungeonCompleted) {
  48. encounterCompleted = false;
  49. } else {
  50. encounterCompleted = true;
  51. this.stopCombat();
  52. toggleQueue();
  53. }
  54. }
  55.  
  56. return encounterCompleted;
  57. }
  58. }
  59.  
  60.  
  61.  
  62.  
  63. (() => {
  64. function loadScript() {
  65. if (typeof confirmedLoaded !== typeof undefined && confirmedLoaded) {
  66. clearInterval(scriptLoader);
  67.  
  68. const scriptElem = document.createElement("script");
  69. scriptElem.textContent = `try {(${script})();} catch (e) {console.log(e);}`;
  70. document.body.appendChild(scriptElem).parentNode.removeChild(scriptElem);
  71. }
  72. }
  73. const scriptLoader = setInterval(loadScript, 200);
  74. })();

QingJ © 2025

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