MooMoo.io Weapon Variant Progress

View your evolving weapon progress

当前为 2023-09-21 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name MooMoo.io Weapon Variant Progress
  3. // @description View your evolving weapon progress
  4. // @author Kooky Warrior
  5. // @match *://*.moomoo.io/*
  6. // @icon https://moomoo.io/img/favicon.png?v=1
  7. // @require https://cdnjs.cloudflare.com/ajax/libs/msgpack-lite/0.1.26/msgpack.min.js
  8. // @run-at document-start
  9. // @grant unsafeWindow
  10. // @license MIT
  11. // @version 0.1
  12. // @namespace https://gf.qytechs.cn/users/999838
  13. // ==/UserScript==
  14.  
  15. ;(async () => {
  16. unsafeWindow.weaponVariantProgress = true
  17.  
  18. document.addEventListener("DOMContentLoaded", () => {
  19. const style = document.createElement("style")
  20. style.innerText = `
  21. .weaponVariantBar {
  22. margin-top: 63px;
  23. height: 3px;
  24. border-radius: 4px;
  25. }
  26.  
  27. @media only screen and (max-width: 896px) {
  28. .weaponVariantBar {
  29. margin-top: 41px;
  30. }
  31. }
  32. `
  33.  
  34. document.head.appendChild(style)
  35. })
  36.  
  37. let init = false,
  38. playerSID,
  39. weaponXP = {},
  40. weaponIndex,
  41. resources = {}
  42. await new Promise(async (resolve) => {
  43. let { send } = WebSocket.prototype
  44.  
  45. WebSocket.prototype.send = function (...x) {
  46. send.apply(this, x)
  47. this.send = send
  48. this.iosend = function (...datas) {
  49. const [packet, ...data] = datas
  50. this.send(new Uint8Array(Array.from(msgpack.encode([packet, data]))))
  51. }
  52. if (!init) {
  53. init = true
  54. this.addEventListener("message", (e) => {
  55. if (!e.origin.includes("moomoo.io") && unsafeWindow.privateServer) return
  56. const [packet, data] = msgpack.decode(new Uint8Array(e.data))
  57. switch (packet) {
  58. case "1":
  59. playerSID = data[0]
  60. weaponXP = {}
  61. weaponVariant = {}
  62. const moofoll = localStorage.getItem("moofoll")
  63. resources = {
  64. food: moofoll ? 100 : 0,
  65. stone: moofoll ? 100 : 0,
  66. wood: moofoll ? 100 : 0,
  67. points: moofoll ? 100 : 0
  68. }
  69. for (let i = 0; i < 16; i++) {
  70. waitForElm("#variantBar" + i).then((element) => {
  71. element.style.width = null
  72. })
  73. }
  74. break
  75. case "33":
  76. for (let i = 0; i < data[0].length; i += 13) {
  77. if (data[0][i] === playerSID) {
  78. weaponIndex = data[0][i + 5]
  79. if (weaponXP[weaponIndex] < unsafeWindow.config.weaponVariants[data[0][i + 6]].xp) {
  80. weaponXP[weaponIndex] = unsafeWindow.config.weaponVariants[data[0][i + 6]].xp
  81. }
  82. break
  83. }
  84. }
  85. break
  86. case "9":
  87. if (data[0] === "kills") break
  88. const tmpIndex = weaponIndex
  89. if (weaponXP[tmpIndex] == null) weaponXP[tmpIndex] = 0
  90. if (data[1] - resources[data[0]] > 0) weaponXP[tmpIndex] += data[1] - resources[data[0]]
  91. resources[data[0]] = data[1]
  92.  
  93. let tmpStyle
  94. let tmpWidth
  95. if (weaponXP[tmpIndex] >= 12000) {
  96. tmpStyle = "none"
  97. tmpWidth = 0
  98. } else if (weaponXP[tmpIndex] >= 7000) {
  99. tmpStyle = "rgb(255, 113, 111)"
  100. tmpWidth = ((weaponXP[tmpIndex] - 7000) / 5000) * 100
  101. } else if (weaponXP[tmpIndex] >= 3000) {
  102. tmpStyle = "rgb(134, 181, 255)"
  103. tmpWidth = ((weaponXP[tmpIndex] - 3000) / 4000) * 100
  104. } else if (weaponXP[tmpIndex] >= 0) {
  105. tmpStyle = "rgb(247, 207, 69)"
  106. tmpWidth = (weaponXP[tmpIndex] / 3000) * 100
  107. }
  108. document.getElementById("variantBar" + tmpIndex).style.width = tmpWidth + "%"
  109. document.getElementById("variantBar" + tmpIndex).style.backgroundColor = tmpStyle
  110. break
  111. }
  112. })
  113. }
  114.  
  115. resolve(this)
  116. }
  117. })
  118.  
  119. function waitForElm(selector) {
  120. return new Promise((resolve) => {
  121. if (document.querySelector(selector)) {
  122. return resolve(document.querySelector(selector))
  123. }
  124.  
  125. const observer = new MutationObserver((mutations) => {
  126. if (document.querySelector(selector)) {
  127. resolve(document.querySelector(selector))
  128. observer.disconnect()
  129. }
  130. })
  131.  
  132. observer.observe(document.body, {
  133. childList: true,
  134. subtree: true
  135. })
  136. })
  137. }
  138.  
  139. for (let i = 0; i < 16; i++) {
  140. waitForElm("#actionBarItem" + i).then((parent) => {
  141. const element = document.createElement("div")
  142. element.id = "variantBar" + i
  143. element.className = "weaponVariantBar"
  144. parent.appendChild(element)
  145. })
  146. }
  147. })()

QingJ © 2025

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