MooMoo.io Item counter

display, how many items you have placed

  1. // ==UserScript==
  2. // @name MooMoo.io Item counter
  3. // @version 1.21
  4. // @description display, how many items you have placed
  5. // @author Nuro
  6. // @match *://*.moomoo.io/*
  7. // @require https://greasyfork.org/scripts/456235-moomoo-js/code/MooMoojs.js?version=1159501
  8. // @run-at document-start
  9. // @namespace -
  10. // ==/UserScript==
  11.  
  12. const MooMoo = (function MooMooJS_beta() {})[69]
  13.  
  14. const styles = {
  15. position: "absolute",
  16. top: "0",
  17. paddingLeft: "5px",
  18. fontSize: "2em",
  19. color: "#fff"
  20. };
  21.  
  22. MooMoo.onGameLoad = () => {
  23. initializeActionBar()
  24. }
  25.  
  26. function initializeActionBar() {
  27. 'use strict';
  28. const actionBarItems = document.getElementsByClassName("actionBarItem");
  29.  
  30. for (let i = 0; i < actionBarItems.length; i++) {
  31. if (i >= 19 && i <= 38) {
  32. const divElement = createActionBarItem(i);
  33. appendActionBarItem(divElement, i);
  34. }
  35. }
  36.  
  37. function createActionBarItem(index) {
  38. const divElement = document.createElement("div");
  39. divElement.setAttribute("id", `actionBarItemnum${index}`);
  40. applyStyles(divElement, styles);
  41. divElement.innerHTML = "0";
  42. return divElement;
  43. }
  44.  
  45. function applyStyles(element, styles) {
  46. for (const style in styles) {
  47. element.style[style] = styles[style];
  48. }
  49. }
  50.  
  51. function appendActionBarItem(divElement, index) {
  52. const parentElement = document.getElementById(`actionBarItem${index}`);
  53. parentElement.appendChild(divElement);
  54. }
  55.  
  56. function getElementById(id) {
  57. return document.getElementById(id);
  58. }
  59.  
  60. MooMoo.addEventListener("14", function (event) {
  61. const value = event[1];
  62. const indicesByEventType = {
  63. 1: [19, 20, 21],
  64. 2: [22, 23, 24, 25],
  65. 3: [26, 27, 28],
  66. 4: [29],
  67. 5: [31],
  68. 6: [32],
  69. 7: [33],
  70. 8: [34],
  71. 9: [35],
  72. 10: [36],
  73. 11: [30],
  74. 12: [37],
  75. 13: [38]
  76. };
  77. const updateActionBarItem = index => {
  78. document.getElementById(`actionBarItemnum${index}`).innerHTML = value;
  79. };
  80. const indices = indicesByEventType[event[0]];
  81. indices.forEach(updateActionBarItem);
  82. });
  83. }