IdlePixel Armour Uncrafter

Uses needle to uncraft all armour pieces.

  1. // ==UserScript==
  2. // @name IdlePixel Armour Uncrafter
  3. // @namespace lbtechnology.info
  4. // @version 1.0.1
  5. // @description Uses needle to uncraft all armour pieces.
  6. // @author Lux-Ferre
  7. // @license MIT
  8. // @match *://idle-pixel.com/login/play*
  9. // @grant none
  10. // @require https://greatest.deepsurf.us/scripts/441206-idlepixel/code/IdlePixel+.js?anticache=20220905
  11. // ==/UserScript==
  12. (function() {
  13. 'use strict';
  14. class UncrafterPlugin extends IdlePixelPlusPlugin {
  15. constructor() {
  16. super("uncrafter", {
  17. about: {
  18. name: GM_info.script.name,
  19. version: GM_info.script.version,
  20. author: GM_info.script.author,
  21. description: GM_info.script.description
  22. },config: [
  23. {
  24. id: "keepBat",
  25. label: "Keep one set of bat armour?",
  26. type: "boolean",
  27. default: true
  28. },
  29. {
  30. id: "keepLizard",
  31. label: "Keep one set of lizard armour?",
  32. type: "boolean",
  33. default: true
  34. },
  35. {
  36. id: "keepBear",
  37. label: "Keep one set of bear armour?",
  38. type: "boolean",
  39. default: true
  40. },
  41. {
  42. id: "keepReaper",
  43. label: "Keep one set of reaper armour?",
  44. type: "boolean",
  45. default: true
  46. },
  47. {
  48. id: "keepCroc",
  49. label: "Keep one set of croc armour?",
  50. type: "boolean",
  51. default: true
  52. }
  53. ]
  54. });
  55. this.previous = "";
  56. }
  57.  
  58. onLogin(){
  59. const needles = ["needle", "sapphire_needle", "emerald_needle", "ruby_needle", "diamond_needle"]
  60.  
  61. needles.forEach((needle)=>{
  62. if (window["var_"+needle] != "undefined"){
  63. if (window["var_"+needle] > 0){
  64. const needleLoc = $(`itembox[data-item="${needle}"]`);
  65. needleLoc.attr("oncontextmenu", "event.preventDefault(); IdlePixelPlus.plugins.uncrafter.uncraftAll()")
  66. }
  67. }
  68. })
  69. }
  70.  
  71. uncraftAll(){
  72. const armourMats = ["bat", "lizard", "bear", "reaper", "crocodile"];
  73. const armourSlots = ["body", "boots", "gloves", "mask", "legs", "hood", "skirt"]
  74. const keepObj = {
  75. keepbat: this.getConfig("keepBat"),
  76. keeplizard: this.getConfig("keepLizard"),
  77. keepbear: this.getConfig("keepBear"),
  78. keepreaper: this.getConfig("keepReaper"),
  79. keepcrocodile: this.getConfig("keepCroc")
  80. }
  81.  
  82.  
  83. armourMats.forEach((mat)=>{
  84. const keepSub = keepObj["keep"+mat]? 1 : 0;
  85. armourSlots.forEach((slot)=>{
  86. const armourString = `${mat}_${slot}`
  87. const armourCount = window["var_" + armourString]
  88. if (typeof armourCount != "undefined"){
  89. const uncraftAmount = armourCount - keepSub
  90. if (uncraftAmount > 0){
  91. IdlePixelPlus.sendMessage(`USE_NEEDLE=${armourString}~${uncraftAmount}`)
  92. }
  93. }
  94. })
  95. })
  96. }
  97. }
  98. const plugin = new UncrafterPlugin();
  99. IdlePixelPlus.registerPlugin(plugin);
  100. })();