Item Exporter

Adds an option to export the sprites of items you right-click on.

  1. // ==UserScript==
  2. // @name Item Exporter
  3. // @namespace http://tampermonkey.net/
  4. // @version 1
  5. // @description Adds an option to export the sprites of items you right-click on.
  6. // @author Zoltar
  7. // @match http://manyland.com/*
  8. // @icon https://cdn.discordapp.com/icons/852442189283983380/a_70793eeb1f509f9c4aa1021e5691fab4.webp
  9. // ==/UserScript==
  10.  
  11. (function () {
  12. 'use strict';
  13.  
  14. // took this part from Eternity's mod
  15. function loadObf() {
  16. if (typeof Deobfuscator === 'undefined')
  17. return $.getScript("https://cdn.jsdelivr.net/gh/parseml/many-deobf@latest/deobf.js")
  18. }
  19.  
  20. async function main() {
  21. ig.game.itemContextMenu.old_draw = ig.game.itemContextMenu.draw;
  22.  
  23.  
  24. let image = new Image();
  25. image.src = 'https://cdn.discordapp.com/attachments/614637022614782000/867213341953097769/arrow.png'
  26. image.onclick = () => consoleref.log('test')
  27.  
  28. // Thank you Stackoverflow!
  29. function toDataURL(url) {
  30. return fetch(url).then((response) => {
  31. return response.blob();
  32. }).then(blob => {
  33. return URL.createObjectURL(blob);
  34. });
  35. }
  36.  
  37. async function exportSprite(item) {
  38. ig.game.sounds.click.play();
  39. const a = document.createElement("a");
  40. a.href = await toDataURL(`${item.imageURL}.png`);
  41. a.download = `${item.name}.png`;
  42. document.body.appendChild(a);
  43. window.removeEventListener('click', clickArrow)
  44. a.click();
  45. document.body.removeChild(a);
  46. window.addEventListener('click', clickArrow)
  47. }
  48.  
  49. function clickArrow(event) {
  50. if (ig.game.itemContextMenu.isOpen) {
  51. let selected = Deobfuscator.object(ig.game.itemContextMenu, 'thing');
  52. let spot = {
  53. x1: (ig.game.itemContextMenu.pos.x + 102) * ig.system.scale,
  54. y1: (ig.game.itemContextMenu.pos.y + 14) * ig.system.scale,
  55. x2: ((ig.game.itemContextMenu.pos.x + 102) * ig.system.scale) + (11 * ig.system.scale),
  56. y2: ((ig.game.itemContextMenu.pos.y + 14) * ig.system.scale) + (9 * ig.system.scale),
  57. call: () => { exportSprite(selected.thing); }
  58. }
  59.  
  60. let clickPos = { x: ig.input.mouse.x * ig.system.scale, y: ig.input.mouse.y * ig.system.scale }
  61.  
  62. if (clickPos.x > spot.x1 && clickPos.x < spot.x2 && clickPos.y > spot.y1 && clickPos.y < spot.y2) {
  63. spot.call();
  64. }
  65. }
  66.  
  67. }
  68.  
  69. window.addEventListener('click', clickArrow)
  70.  
  71. ig.game.itemContextMenu.draw = () => {
  72. ig.game.itemContextMenu.old_draw();
  73. if (ig.game.itemContextMenu.isOpen) {
  74. ig.system.context.globalAlpha = 0.4;
  75. ig.system.context.drawImage(image, (ig.game.itemContextMenu.pos.x + 102) * ig.system.scale, (ig.game.itemContextMenu.pos.y + 14) * ig.system.scale, (11 * ig.system.scale), (9 * ig.system.scale));
  76. ig.system.context.globalAlpha = 1;
  77. }
  78.  
  79. }
  80.  
  81. }
  82.  
  83. // Parses smooth loader
  84. !async function loader() {
  85. let loading = setInterval(async function () {
  86. if (typeof ig === "undefined") return
  87. else if (typeof ig.game === "undefined") return
  88. else if (typeof ig.game.screen === "undefined") return
  89. else if (ig.game.screen.x == 0) return
  90. else if (typeof Settings !== "function") return
  91.  
  92. clearInterval(loading);
  93. await loadObf();
  94. main();
  95. }, 250)
  96. }()
  97. })();