🏠 Home 

Menu template for your script

I just did it because I'm bored... How you will use this menu depends on you! I did it for the developers of cheats on Moo Moo.io, but it can be used on any game.

  1. // ==UserScript==
  2. // @name Menu template for your script
  3. // @namespace none
  4. // @version 1
  5. // @description I just did it because I'm bored... How you will use this menu depends on you! I did it for the developers of cheats on Moo Moo.io, but it can be used on any game.
  6. // @author 00100110#6361
  7. // @match *://moomoo.io/*
  8. // @match *://*.moomoo.io/*
  9. // @grant none
  10. // ==/UserScript==
  11. /* Stting menu */
  12. let menu = {
  13. opacity: 1,
  14. position: {
  15. relative: `relative`,
  16. absolute: `absolute`,
  17. top: `${70}px`,
  18. left: `${20}px`,
  19. bottom: `${0}px`,
  20. right: `${0}px`,
  21. },
  22. size: {
  23. width: `${330}px`,
  24. height: `${400}px`,
  25. height_title_block: `${30}px`,
  26. border_body_block: `${5}px`,
  27. border_radius_body_block: `${7}px`,
  28. font_size_title_block: `${21}px`,
  29. font_size_inner_block: `${18}px`
  30. },
  31. colors: {
  32. background_title_block: `rgba(66, 66, 66, 0.61)`,
  33. background_body_block: `rgba(0, 0, 0, 0.25)`,
  34. background_inner_block: `rgba(0, 0, 0, 0.25)`,
  35. border_body_block: `rgba(38, 38, 38, 0.72)`,
  36. title_text: `#fff`,
  37. inner_block: `#fff`,
  38. },
  39. display: {
  40. block: `block`,
  41. flex: `flex`,
  42. none: `none`
  43. },
  44. align: {
  45. left: `left`,
  46. center: `center`,
  47. right: `right`,
  48. bottom: `bottom`
  49. }
  50. }
  51. menu = new Proxy(menu, {
  52. set(target, prop, val) {
  53. if (prop in target) {
  54. return true
  55. if (typeof val != 'string') {
  56. target[prop] = val.toString()
  57. } else {
  58. return target[prop]
  59. }
  60. } else {
  61. return prop
  62. return false
  63. throw new Error(`Prop: ${prop} not defined in ${target}`)
  64. }
  65. }
  66. });
  67. /* Create menu HTML code */
  68. const html = `
  69. <!--
  70. <main></main> & <passive></passive> - are not embedded tags in HTML.
  71. I use this to denote the significance of the blocks.
  72. class="" & id="" - I use to denote blocks, id for everything else
  73. -->
  74. <!-- Add holder -->
  75. <main class="menu--holder">
  76. <main class="menu--body">
  77. <passive id="menu--title">
  78. Menu
  79. </passive>
  80. <main class="menu--inner-gui">
  81. <passive class="menu--inner-gui-block">
  82. <passive id="menu--inner-gui-block-text">
  83. Your text <input type="checkbox" id="Your id">
  84. </passive>
  85. </passive>
  86. </main>
  87. </main>
  88. </main>
  89. `
  90. /* Create menu CSS code */
  91. let css = `
  92. <style>
  93. /*
  94. . - use for class
  95. # - use for id
  96. */
  97. /* Style for holder menu. */
  98. main.menu--holder {
  99. position: ${menu.position.absolute};
  100. top: ${menu.position.top};
  101. left: ${menu.position.left};
  102. width: ${menu.size.width};
  103. height: ${menu.size.height};
  104. display: ${menu.display.none};
  105. }
  106. /* Style for body menu. */
  107. main.menu--body {
  108. width: 100% !important;
  109. height: 100% !important;
  110. background: ${menu.colors.background_body_block};
  111. border-radius: ${menu.size.border_radius_body_block};
  112. border: ${menu.size.border_body_block} solid ${menu.colors.border_body_block};
  113. opacity: ${menu.opacity};
  114. }
  115. /* Style for title menu */
  116. passive#menu--title {
  117. cursor: move;
  118. position: ${menu.position.relative};
  119. display: ${menu.display.flex};
  120. width: 92.6% !important;
  121. background: ${menu.colors.background_title_block};
  122. color: ${menu.colors.title_text};
  123. align-content: ${menu.align.center};
  124. justify-content: ${menu.align.center};
  125. font-size: ${menu.size.font_size_title_block};
  126. text-align: ${menu.align.center};
  127. height: ${menu.size.height_title_block};
  128. box-shadow: 0px 0px 4px #1a1a1a;
  129. flex-wrap: wrap;
  130. margin-left: 12px;
  131. margin-top: 5px;
  132. }
  133. /* Style for inner menu gui */
  134. main.menu--inner-gui {
  135. margin: 0px 2px;
  136. display: ${menu.display.flex};
  137. }
  138. /* Style for inner menu gui block */
  139. passive.menu--inner-gui-block {
  140. width: 290px;
  141. vertical-align: top;
  142. height: 330px;
  143. margin: 0px 10px 10px 10px;
  144. background: rgba(66, 66, 66, 0.61);
  145. box-shadow: 0px 0px 4px #1a1a1a;
  146. border-radius: 3px;
  147. overflow-x: hidden;
  148. overflow-y: auto;
  149. color: #fff;
  150. padding: 10px;
  151. margin-top: 10px;
  152. }
  153. /* Style for text in inner menu */
  154. passive#menu--inner-gui-block-text {
  155. color: ${menu.colors.inner_block};
  156. font-size: ${menu.size.font_size_inner_block};
  157. display: ${menu.display.block};
  158. }
  159. input[type="checkbox"] {
  160. vertical-align: middle;
  161. user-select: none;
  162. box-sizing: border-box;
  163. cursor: pointer;
  164. }
  165. </style>
  166. `
  167. /* Create menu JS code */
  168. let js = `
  169. <script>
  170. // If you click outside of the menu location
  171. $(document).mouseup(function (e) {
  172. let container = $(".menu--holder")
  173. if (container.has(e.target).length === 0 && container.css('display') == 'block'){
  174. container.css('opacity', '0.35')
  175. } else {
  176. container.css('opacity', '1')
  177. }
  178. })
  179. // Drag element
  180. dragElement(document.querySelector((".menu--holder")))
  181. function dragElement(elmnt) {
  182. let pos1 = 0,
  183. pos2 = 0,
  184. pos3 = 0,
  185. pos4 = 0
  186. if (document.getElementById("menu--title")) {
  187. /* if present, the header is where you move the DIV from:*/
  188. document.getElementById("menu--title").onmousedown = dragMouseDown
  189. } else {
  190. /* otherwise, move the DIV from anywhere inside the DIV:*/
  191. elmnt.onmousedown = dragMouseDown
  192. }
  193. function dragMouseDown(e) {
  194. e = e || window.event
  195. // get the mouse cursor position at startup:
  196. pos3 = e.clientX
  197. pos4 = e.clientY
  198. document.onmouseup = closeDragElement
  199. // call a function whenever the cursor moves:
  200. document.onmousemove = elementDrag
  201. }
  202. function elementDrag(e) {
  203. e = e || window.event
  204. // calculate the new cursor position:
  205. pos1 = pos3 - e.clientX
  206. pos2 = pos4 - e.clientY
  207. pos3 = e.clientX
  208. pos4 = e.clientY
  209. // set the element's new position:
  210. elmnt.style.top = (elmnt.offsetTop - pos2) + "px"
  211. elmnt.style.left = (elmnt.offsetLeft - pos1) + "px"
  212. }
  213. function closeDragElement() {
  214. /* stop moving when mouse button is released:*/
  215. document.onmouseup = null
  216. document.onmousemove = null
  217. }
  218. }
  219. </script>
  220. `
  221. /* Add menu in body */
  222. $('body').append(html, css, js)
  223. /* Add toggler for menu */
  224. let openMenu = true
  225. document.addEventListener("keydown", function(event) {
  226. if (event.code == "Escape") {
  227. if (openMenu) {
  228. openMenu = false
  229. $('.menu--holder').css('display', menu.display.block)
  230. } else {
  231. openMenu = true
  232. $('.menu--holder').css('display', menu.display.none)
  233. }
  234. }
  235. })