IdlePixel Quick Fight Buttons

DEPRECATED - Added to SlapChop plugin

  1. // ==UserScript==
  2. // @name IdlePixel Quick Fight Buttons
  3. // @namespace com.anwinity.idlepixel
  4. // @version 1.3.0
  5. // @description DEPRECATED - Added to SlapChop plugin
  6. // @author Anwinity
  7. // @license MIT
  8. // @match *://idle-pixel.com/login/play*
  9. // @grant none
  10. // @require https://gf.qytechs.cn/scripts/441206-idlepixel/code/IdlePixel+.js?anticache=20220905
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. class QuickFightButtonsPlugin extends IdlePixelPlusPlugin {
  17. constructor() {
  18. super("quickfight", {
  19. about: {
  20. name: GM_info.script.name,
  21. version: GM_info.script.version,
  22. author: GM_info.script.author,
  23. description: GM_info.script.description
  24. },
  25. config: [
  26. {
  27. id: "confirm",
  28. label: "Show Confirm",
  29. type: "boolean",
  30. default: false
  31. }
  32. ]
  33. });
  34. }
  35.  
  36. quickFight(zoneId) {
  37. const confirm = this.getConfig("confirm");
  38. if(confirm) {
  39. if(window.confirm(`FIGHT: ${zoneId} ?`)) {
  40. Combat.modal_area_last_selected = zoneId;
  41. IdlePixelPlus.sendMessage(`START_FIGHT=${zoneId}`);
  42. }
  43. }
  44. else {
  45. Combat.modal_area_last_selected = zoneId;
  46. IdlePixelPlus.sendMessage(`START_FIGHT=${zoneId}`);
  47. }
  48. }
  49.  
  50. refreshButtonStates() {
  51. const fp = IdlePixelPlus.getVarOrDefault("fight_points", 0, "int");
  52. const energy = IdlePixelPlus.getVarOrDefault("energy", 0, "int");
  53. Object.values(IdlePixelPlus.info.combatZones).forEach(zone => {
  54. let disabled = fp < zone.fightPointCost || energy < zone.energyCost;
  55. if(zone.id == "volcano" && IdlePixelPlus.getVar("volcano_unlocked")!="1") {
  56. disabled = true;
  57. }
  58. else if(zone.id == "northern_field" && IdlePixelPlus.getVar("northern_field_unlocked")!="1") {
  59. disabled = true;
  60. }
  61. $(`button#quickfight-${zone.id}`).prop("disabled", disabled);
  62. });
  63. }
  64.  
  65. onVariableSet(key, valueBefore, valueAfter) {
  66. // fp increments every tick, so don't bother refreshing when energy changes
  67. if(["fight_points", "energy", "volcano_unlocked", "northern_field_unlocked"].includes(key)) {
  68. this.refreshButtonStates();
  69. }
  70. }
  71.  
  72. onLogin() {
  73. let html = '<h5>Quick Fight:</h5><div style="display: flex; flex-direction: row">';
  74. Object.values(IdlePixelPlus.info.combatZones).forEach(zone => {
  75. html += `<button id="quickfight-${zone.id}" class="m-1" type="button" onclick="IdlePixelPlus.plugins.quickfight.quickFight('${zone.id}')">${zone.id}</button>`;
  76. });
  77. html += `</div><span style="color: red"><strong>Quick Fight DEPRECATED:</strong> Use <a href="https://gf.qytechs.cn/en/scripts/448025-idlepixel-slap-chop" target="_blank">SlapChop Plugin</a> instead.</span><hr>`;
  78. $("#panel-combat hr").first().after(html);
  79. this.refreshButtonStates();
  80. }
  81.  
  82. }
  83.  
  84. const plugin = new QuickFightButtonsPlugin();
  85. IdlePixelPlus.registerPlugin(plugin);
  86.  
  87. })();

QingJ © 2025

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