Diep.io Custom Points Upgrader. Beta

NEW! custom upgrade builds update! Your upgrade builds will save now! This is still in beta!

当前为 2025-03-10 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Diep.io Custom Points Upgrader. Beta
  3. // @namespace http://tampermonkey.net/
  4. // @version 10.05
  5. // @homepage https://greasyfork.org/scripts/416440
  6. // @description NEW! custom upgrade builds update! Your upgrade builds will save now! This is still in beta!
  7. // @author -{Abyss⌬}-ora
  8. // @match https://diep.io/*
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function () {
  14. "use strict";
  15.  
  16. function getScriptVersion() {
  17. const metadataBlock = `
  18. // ==UserScript==
  19. // @name Diep.io Custom Points Upgrader. Beta
  20. // @namespace http://tampermonkey.net/
  21. // @version 10.05
  22. // @homepage https://greasyfork.org/scripts/416440
  23. // @description NEW! custom upgrade builds update! Your upgrade builds will save now! This is still in beta!
  24. // @author -{Abyss⌬}-ora
  25. // @match https://diep.io/*
  26. // @grant none
  27. // @license MIT
  28. // @downloadURL https://update.greasyfork.org/scripts/416440/Diepio%20Custom%20Points%20Upgrader%20Beta.user.js
  29. // @updateURL https://update.greasyfork.org/scripts/416440/Diepio%20Custom%20Points%20Upgrader%20Beta.meta.js
  30. // ==/UserScript==`;
  31.  
  32. const versionMatch = metadataBlock.match(/@version\s+([\d.]+)/);
  33. return versionMatch ? versionMatch[1] : null;
  34. }
  35.  
  36. function saveDataBeforeUpdate() {
  37. const dataToSave = {
  38. quickSpawnUsername: localStorage.getItem("quickSpawnUsername"),
  39. savedNames: localStorage.getItem("savedNames"),
  40. savedButtons: localStorage.getItem("savedButtons"),
  41. removedDefaults: localStorage.getItem("removedDefaults")
  42. };
  43. localStorage.setItem("backupData", JSON.stringify(dataToSave));
  44. }
  45.  
  46. function retrieveDataAfterUpdate() {
  47. const backupData = JSON.parse(localStorage.getItem("backupData"));
  48. if (backupData) {
  49. localStorage.setItem("quickSpawnUsername", backupData.quickSpawnUsername);
  50. localStorage.setItem("savedNames", backupData.savedNames);
  51. localStorage.setItem("savedButtons", backupData.savedButtons);
  52. localStorage.setItem("removedDefaults", backupData.removedDefaults);
  53. }
  54. }
  55.  
  56. function checkAndUpdateVersion() {
  57. const currentVersion = getScriptVersion();
  58. const savedVersion = localStorage.getItem("scriptVersion");
  59.  
  60. if (!savedVersion || savedVersion < currentVersion) {
  61. retrieveDataAfterUpdate();
  62. localStorage.setItem("scriptVersion", currentVersion);
  63. }
  64. }
  65.  
  66. saveDataBeforeUpdate();
  67.  
  68. checkAndUpdateVersion();
  69.  
  70. const hoverMenu = document.createElement("div");
  71. hoverMenu.id = "myhover";
  72. hoverMenu.className = "hover";
  73.  
  74. const modMenu = document.createElement("a");
  75. modMenu.id = "modtab";
  76.  
  77. const menuHeader = document.createElement("h1");
  78. const versionText = document.createElement("small");
  79. const smallerVersionText = document.createElement("small");
  80. smallerVersionText.textContent = `Version: ${getScriptVersion()}`;
  81. versionText.appendChild(smallerVersionText);
  82. menuHeader.appendChild(versionText);
  83. menuHeader.appendChild(document.createElement("br"));
  84. menuHeader.appendChild(document.createTextNode("-{Abyss⌬}-ora's Mod Menu beta"));
  85. modMenu.appendChild(menuHeader);
  86.  
  87. const topRightButton = document.createElement("button");
  88. topRightButton.id = "topRightButton";
  89. topRightButton.textContent = "↻";
  90.  
  91. const style = document.createElement("style");
  92. style.type = "text/css";
  93. style.textContent = `
  94. #myhover a {
  95. z-index: 999;
  96. position: absolute;
  97. top: 300px;
  98. right: -260px;
  99. transition: 0.3s;
  100. width: 250px;
  101. padding: 15px;
  102. background-image: url("https://media.tenor.com/images/f3f5354b7c304bc61882dbb1183885e7/tenor.gif");
  103. background-color: #555;
  104. text-decoration: none;
  105. font-size: 10px;
  106. font-family: 'Monoton', cursive;
  107. text-shadow: 1px 1px #000, 2px 2px #555;
  108. color: white;
  109. border: double thick white;
  110. border-radius: 20px;
  111. }
  112. #myhover a:hover {
  113. right: 0;
  114. }
  115. .button {
  116. display: block;
  117. margin: 5px auto;
  118. width: 90%;
  119. text-align: center;
  120. font-size: 18px;
  121. font-family: 'Jersey 10', sans-serif;
  122. color: black;
  123. background-color: white;
  124. border-radius: 5px;
  125. transition: 0.4s;
  126. cursor: pointer;
  127. }
  128. .button:hover {
  129. transform: translateX(-10px);
  130. }
  131. #userInput {
  132. margin: 5px auto;
  133. width: 90%;
  134. padding: 8px;
  135. font-family: 'Monoton', cursive;
  136. text-align: center;
  137. }
  138. #specialButton {
  139. display: block;
  140. margin: 5px auto;
  141. width: 90%;
  142. text-align: center;
  143. font-size: 18px;
  144. font-family: 'Jersey 10', sans-serif;
  145. color: white;
  146. background-color: black;
  147. border-radius: 5px;
  148. border-color: white;
  149. transition: 0.4s;
  150. cursor: pointer;
  151. opacity: 0.8;
  152. }
  153. #specialButton:hover {
  154. color: black;
  155. background-color: darkgray;
  156. transform: translateX(-10px);
  157. }
  158. .popup {
  159. position: fixed;
  160. top: 50%;
  161. left: 50%;
  162. transform: translate(-50%, -50%);
  163. width: 300px;
  164. background-image: url("https://media.tenor.com/images/f3f5354b7c304bc61882dbb1183885e7/tenor.gif");
  165. background-color: white;
  166. border: double thick white;
  167. border-radius: 10px;
  168. padding: 20px;
  169. z-index: 1000;
  170. text-shadow: 1px 1px #000, 2px 2px #555;
  171. }
  172. .attribute {
  173. display: flex;
  174. align-items: center;
  175. margin-bottom: 10px;
  176. }
  177. .attribute div {
  178. width: 30px;
  179. height: 30px;
  180. border: 1px solid #000;
  181. margin: 0;
  182. }
  183. .attribute button {
  184. background-color: gray;
  185. border: none;
  186. color: black;
  187. font-size: 20px;
  188. cursor: pointer;
  189. width: 30px;
  190. height: 30px;
  191. margin: 0;
  192. }
  193. #pointsCounter {
  194. text-align: center;
  195. font-size: 16px;
  196. margin-bottom: 10px;
  197. }
  198. #createBuildButton {
  199. display: block;
  200. margin: 20px auto 0 auto;
  201. width: 80%;
  202. text-align: center;
  203. font-size: 18px;
  204. font-family: 'Jersey 10', sans-serif;
  205. color: black;
  206. background-color: white;
  207. border-radius: 5px;
  208. border: 2px solid black;
  209. cursor: pointer;
  210. padding: 10px;
  211. }
  212. #createBuildButton:hover {
  213. background-color: gray;
  214. color: white;
  215. }
  216. #codeString {
  217. text-align: center;
  218. font-size: 18px;
  219. margin: 10px 0;
  220. }
  221. .remove-button {
  222. background-color: gray;
  223. border: none;
  224. color: white;
  225. font-size: 18px;
  226. cursor: pointer;
  227. width: 30px;
  228. height: 30px;
  229. margin-right: 5px;
  230. transition: background-color 0.3s;
  231. }
  232. .remove-button:hover {
  233. background-color: red;
  234. }
  235. .edit-button {
  236. background-color: gray;
  237. border: none;
  238. color: white;
  239. font-size: 18px;
  240. cursor: pointer;
  241. width: 30px;
  242. height: 30px;
  243. margin-right: 5px;
  244. transition: background-color 0.3s;
  245. }
  246. .edit-button:hover {
  247. background-color: lightgray;
  248. }
  249. .close-btn {
  250. display: flex;
  251. justify-content: center;
  252. align-items: center;
  253. position: absolute;
  254. top: 1px;
  255. z-index: 10;
  256. right: 0px;
  257. width: 40px;
  258. height: 35px;
  259. color: white;
  260. cursor: pointer;
  261. font-size: 18px;
  262. line-height: 30px;
  263. text-align: center;
  264. transition: background-color 0.3s;
  265. text-shadow: 1px 1px #000, 2px 2px #555;
  266. border-radius: 10px;
  267. background-color: rgba(0, 0, 0, 0.8);
  268. }
  269. .close-btn:hover {
  270. background-color: red;
  271. }
  272. #topRightButton {
  273. position: absolute;
  274. top: 10px;
  275. right: 10px;
  276. width: 30px;
  277. height: 30px;
  278. background-color: black;
  279. color: white;
  280. border: none;
  281. border-radius: 10%;
  282. cursor: pointer;
  283. font-size: 18px;
  284. display: flex;
  285. justify-content: center;
  286. align-items: center;
  287. transition: background-color 0.3s;
  288. z-index: 1001;
  289. opacity: 0.8;
  290. }
  291. #topRightButton:hover {
  292. color: red;
  293. }
  294. #buildButtonsContainer {
  295. max-height: 400px;
  296. overflow-y: scroll;
  297. margin-left: 5px;
  298. }
  299. #buildButtonsContainer {
  300. -ms-overflow-style: none;
  301. scrollbar-width: none;
  302. }
  303. ::-webkit-scrollbar {
  304. width: 10px;
  305. }
  306. ::-webkit-scrollbar-track {
  307. background: #f1f1f1;
  308. border-radius: 10px;
  309. }
  310. ::-webkit-scrollbar-thumb {
  311. background: #888;
  312. border-radius: 10px;
  313. }
  314. ::-webkit-scrollbar-thumb:hover {
  315. background: #555;
  316. }
  317. .popup {
  318. position: fixed;
  319. z-index: 9;
  320. background-color: #f1f1f1;
  321. border: 1px solid #d3d3d3;
  322. text-align: center;
  323. padding-top: 40px;
  324. }
  325. .popup-header {
  326. display: flex;
  327. justify-content: center;
  328. align-items: center;
  329. position: absolute;
  330. top: 1px;
  331. left: 0px;
  332. right: 35px;
  333. height: 30px;
  334. cursor: grabbing;
  335. z-index: 10;
  336. background-color: rgba(5, 5,5, 0.8);
  337. color: #fff;
  338. font-size: 10px;
  339. font-family: 'Monoton', cursive;
  340. text-shadow: 1px 1px #000, 2px 2px #555;
  341. border-color: white;
  342. border-radius: 10px;
  343. }
  344. `;
  345. document.head.appendChild(style);
  346.  
  347. const inputContainer = document.createElement("div");
  348. inputContainer.style.position = "relative";
  349. inputContainer.style.width = "90%";
  350. inputContainer.style.margin = "5px auto";
  351.  
  352. const heartIcon = document.createElement("span");
  353. heartIcon.textContent = "♥";
  354. heartIcon.style.position = "absolute";
  355. heartIcon.style.left = "10px";
  356. heartIcon.style.top = "50%";
  357. heartIcon.style.transform = "translateY(-50%)";
  358. heartIcon.style.cursor = "pointer";
  359. heartIcon.style.fontSize = "18px";
  360. heartIcon.style.color = "black";
  361.  
  362. const userInput = document.createElement("input");
  363. userInput.id = "userInput";
  364. userInput.type = "text";
  365. userInput.placeholder = "Enter Username";
  366. userInput.value = localStorage.getItem("quickSpawnUsername") || "";
  367. userInput.style.width = "100%";
  368. userInput.style.padding = "8px 30px 8px 30px";
  369. userInput.style.border = "2px solid black";
  370. userInput.style.borderRadius = "5px";
  371. userInput.style.boxSizing = "border-box";
  372. userInput.style.fontFamily = "'Monoton', cursive";
  373. userInput.style.textAlign = "center";
  374.  
  375. const dropdownArrow = document.createElement("span");
  376. dropdownArrow.textContent = "▼";
  377. dropdownArrow.style.position = "absolute";
  378. dropdownArrow.style.right = "10px";
  379. dropdownArrow.style.top = "50%";
  380. dropdownArrow.style.transform = "translateY(-50%)";
  381. dropdownArrow.style.cursor = "pointer";
  382. dropdownArrow.style.fontSize = "14px";
  383. dropdownArrow.style.color = "black";
  384.  
  385. const dropdown = document.createElement("div");
  386. dropdown.id = "dropdownMenu";
  387. dropdown.style.position = "absolute";
  388. dropdown.style.width = "100%";
  389. dropdown.style.top = "100%";
  390. dropdown.style.left = "0";
  391. dropdown.style.backgroundImage = "url('https://media.tenor.com/images/f3f5354b7c304bc61882dbb1183885e7/tenor.gif')";
  392. dropdown.style.border = "4px double white";
  393. dropdown.style.borderTop = "none";
  394. dropdown.style.display = "none";
  395. dropdown.style.zIndex = "100";
  396. dropdown.style.maxHeight = "150px";
  397. dropdown.style.overflowY = "auto";
  398.  
  399. dropdownArrow.addEventListener("click", () => {
  400. dropdown.style.display = dropdown.style.display === "block" ? "none" : "block";
  401. });
  402.  
  403. document.addEventListener("click", (event) => {
  404. if (!inputContainer.contains(event.target)) {
  405. dropdown.style.display = "none";
  406. }
  407. });
  408.  
  409. userInput.addEventListener("input", (event) => {
  410. localStorage.setItem("quickSpawnUsername", event.target.value);
  411. updateHeartIcon();
  412. });
  413.  
  414. heartIcon.addEventListener("click", () => {
  415. const name = userInput.value.trim();
  416. if (name) {
  417. const savedNames = JSON.parse(localStorage.getItem("savedNames")) || [];
  418. const nameIndex = savedNames.indexOf(name);
  419.  
  420. if (nameIndex === -1) {
  421. savedNames.push(name);
  422. heartIcon.style.color = "red";
  423. } else {
  424. savedNames.splice(nameIndex, 1);
  425. heartIcon.style.color = "black";
  426. }
  427.  
  428. localStorage.setItem("savedNames", JSON.stringify(savedNames));
  429. updateDropdown(savedNames);
  430. }
  431. });
  432.  
  433. function updateDropdown(names) {
  434. dropdown.innerHTML = "";
  435. names.forEach(name => {
  436. const optionContainer = document.createElement("div");
  437. optionContainer.style.display = "flex";
  438. optionContainer.style.alignItems = "center";
  439. optionContainer.style.justifyContent = "space-between";
  440. optionContainer.style.padding = "8px";
  441. optionContainer.style.cursor = "pointer";
  442. optionContainer.style.fontFamily = "'Monoton', cursive";
  443. optionContainer.style.textAlign = "center";
  444. optionContainer.style.fontSize = "18px";
  445. optionContainer.style.backgroundImage = "url('https://media.tenor.com/images/f3f5354b7c304bc61882dbb1183885e7/tenor.gif')";
  446. optionContainer.style.transition = "background 0.3s";
  447.  
  448. const option = document.createElement("div");
  449. option.textContent = name;
  450. option.style.flexGrow = "1";
  451. option.style.textAlign = "left";
  452.  
  453. option.addEventListener("mouseover", () => {
  454. optionContainer.style.backgroundColor = "rgba(169, 169, 169, 0.8)";
  455. });
  456.  
  457. option.addEventListener("mouseout", () => {
  458. optionContainer.style.backgroundColor = "transparent";
  459. });
  460.  
  461. option.addEventListener("click", () => {
  462. userInput.value = name;
  463. dropdown.style.display = "none";
  464. localStorage.setItem("quickSpawnUsername", name);
  465. updateHeartIcon();
  466. });
  467.  
  468. optionContainer.appendChild(option);
  469. dropdown.appendChild(optionContainer);
  470. });
  471. }
  472.  
  473. function updateHeartIcon() {
  474. const name = userInput.value.trim();
  475. const savedNames = JSON.parse(localStorage.getItem("savedNames")) || [];
  476. if (savedNames.includes(name)) {
  477. heartIcon.style.color = "red";
  478. } else {
  479. heartIcon.style.color = "black";
  480. }
  481. }
  482.  
  483. const savedNames = JSON.parse(localStorage.getItem("savedNames")) || [];
  484. updateDropdown(savedNames);
  485. updateHeartIcon();
  486.  
  487. inputContainer.appendChild(heartIcon);
  488. inputContainer.appendChild(userInput);
  489. inputContainer.appendChild(dropdownArrow);
  490. inputContainer.appendChild(dropdown);
  491. modMenu.appendChild(inputContainer);
  492.  
  493. const buttons = [];
  494.  
  495. buttons.forEach((buttonData) => {
  496. const buttonContainer = document.createElement("div");
  497. buttonContainer.style.display = "flex";
  498. buttonContainer.style.alignItems = "center";
  499. buttonContainer.style.justifyContent = "center";
  500.  
  501. const removeButton = document.createElement("button");
  502. removeButton.className = "remove-button";
  503. removeButton.textContent = "🖉";
  504. removeButton.onclick = () => {
  505. createRemovePopup(buttonContainer, buttonData);
  506. };
  507.  
  508. buttonContainer.appendChild(removeButton);
  509.  
  510. const button = document.createElement("button");
  511. button.className = "button";
  512. button.textContent = buttonData.name;
  513. button.style.backgroundColor = buttonData.color;
  514. button.onclick = () => {
  515. const spawnName = userInput.value.trim();
  516. window.input.execute(`game_spawn ${spawnName}`);
  517. window.input.execute(`game_stats_build ${buttonData.cmd}`);
  518. const hoverMenu = document.getElementById("myhover");
  519. if (hoverMenu) {
  520. hoverMenu.style.display = hoverMenu.style.display === "none" ? "block" : "none";
  521. }
  522. };
  523. buttonContainer.appendChild(button);
  524.  
  525. modMenu.appendChild(buttonContainer);
  526. });
  527.  
  528. const specialButton = document.createElement("button");
  529. specialButton.id = "specialButton";
  530. specialButton.textContent = "[+]";
  531.  
  532. specialButton.onclick = () => {
  533. const popup = document.createElement("div");
  534. popup.className = "popup";
  535. popup.id = "resetPopup";
  536. popup.innerHTML = `<div class="popup-header" id="resetPopupHeader">Drag me</div> `;
  537. document.body.appendChild(popup);
  538.  
  539. const closeButton = document.createElement("button");
  540. closeButton.className = "close-btn";
  541. closeButton.textContent = "X";
  542. closeButton.onclick = () => {
  543. document.body.removeChild(popup);
  544. };
  545. popup.appendChild(closeButton);
  546.  
  547. const buildNameInput = document.createElement("input");
  548. buildNameInput.type = "text";
  549. buildNameInput.placeholder = "Build Name";
  550. buildNameInput.style.display = "block";
  551. buildNameInput.style.width = "80%";
  552. buildNameInput.style.margin = "0 auto 10px auto";
  553. popup.appendChild(buildNameInput);
  554.  
  555. const pointsCounter = document.createElement("div");
  556. pointsCounter.id = "pointsCounter";
  557. pointsCounter.textContent = "Points: 33";
  558. popup.appendChild(pointsCounter);
  559.  
  560. const codeString = document.createElement("div");
  561. codeString.id = "codeString";
  562. codeString.textContent = "Code: 0";
  563. popup.appendChild(codeString);
  564.  
  565. let totalPoints = 33;
  566. let code = "";
  567.  
  568. const attributes = [
  569. { name: "Health Regen", color: "rgb(232, 188, 157)" },
  570. { name: "Max Health", color: "rgb(230, 128, 234)" },
  571. { name: "Body Damage", color: "rgb(165, 128, 234)" },
  572. { name: "Bullet Speed", color: "rgb(128, 162, 234)" },
  573. { name: "Bullet Penetration", color: "rgb(234, 215, 128)" },
  574. { name: "Bullet Damage", color: "rgb(234, 128, 128)" },
  575. { name: "Reload", color: "rgb(164, 234, 128)" },
  576. { name: "Movement Speed", color: "rgb(128, 234, 230)" },
  577. ];
  578.  
  579. attributes.forEach((attribute, index) => {
  580. const attributeRow = document.createElement("div");
  581. attributeRow.className = "attribute";
  582. attributeRow.style.position = "relative";
  583.  
  584. const minusButton = document.createElement("button");
  585. minusButton.style.padding = "0 5px";
  586. minusButton.style.border = "1px solid black";
  587. minusButton.style.borderTopLeftRadius = "50px";
  588. minusButton.style.borderBottomLeftRadius = "50px";
  589. minusButton.style.borderTopRightRadius = "0";
  590. minusButton.style.borderBottomRightRadius = "0";
  591. minusButton.style.width = "32px";
  592. minusButton.style.height = "32px";
  593. minusButton.textContent = "-";
  594. minusButton.onclick = () => {
  595. const coloredSquares = Array.from(attributeRow.children).filter(child => child !== plusButton && child.style.backgroundColor === attribute.color);
  596. if (coloredSquares.length > 0 && totalPoints < 33) {
  597. const square = coloredSquares[coloredSquares.length - 1];
  598. square.style.backgroundColor = "gray";
  599. square.style.border = "0";
  600. totalPoints++;
  601. pointsCounter.textContent = `Points: ${totalPoints}`;
  602. code = code.slice(0, -1);
  603. codeString.textContent = `Code: ${code}`;
  604. }
  605. };
  606. attributeRow.appendChild(minusButton);
  607.  
  608. for (let i = 0; i < 7; i++) {
  609. const colorDiv = document.createElement("div");
  610. colorDiv.style.border = "0";
  611. colorDiv.style.backgroundColor = "gray";
  612. colorDiv.style.width = "30px";
  613. colorDiv.style.height = "30px";
  614. colorDiv.style.display = "inline-block";
  615. colorDiv.style.position = "relative";
  616. colorDiv.style.padding = "0 5px";
  617.  
  618. if (i === 3) {
  619. const textSpan = document.createElement("span");
  620. textSpan.textContent = attribute.name;
  621. textSpan.style.position = "absolute";
  622. textSpan.style.top = "50%";
  623. textSpan.style.left = "50%";
  624. textSpan.style.transform = "translate(-50%, -50%)";
  625. textSpan.style.color = "white";
  626. textSpan.style.pointerEvents = "none";
  627. textSpan.style.whiteSpace = "nowrap";
  628. textSpan.style.zIndex = "1";
  629. textSpan.style.display = "inline-block";
  630. textSpan.style.textShadow =
  631. "1px 1px 1px black, -1px -1px 1px black, -1px 1px 1px black, 1px -1px 1px black";
  632.  
  633. colorDiv.appendChild(textSpan);
  634. }
  635.  
  636. attributeRow.appendChild(colorDiv);
  637. }
  638.  
  639. const plusButton = document.createElement("button");
  640. plusButton.style.padding = "0 5px";
  641. plusButton.style.border = "1px solid black";
  642. plusButton.style.borderTopLeftRadius = "0";
  643. plusButton.style.borderBottomLeftRadius = "0";
  644. plusButton.style.borderTopRightRadius = "50px";
  645. plusButton.style.borderBottomRightRadius = "50px";
  646. plusButton.style.width = "32px";
  647. plusButton.style.height = "32px";
  648. plusButton.style.color = "Black";
  649. plusButton.style.fontWeight = "bold";
  650. plusButton.textContent = "+";
  651. plusButton.style.backgroundColor = attribute.color;
  652.  
  653. plusButton.onclick = () => {
  654. const graySquares = Array.from(attributeRow.children).filter(child => child.style.backgroundColor === "gray" && child !== plusButton);
  655. if (graySquares.length > 0 && totalPoints > 0) {
  656. const square = graySquares[0];
  657. square.style.backgroundColor = attribute.color;
  658. square.style.border = "1px solid black";
  659. totalPoints--;
  660. pointsCounter.textContent = `Points: ${totalPoints}`;
  661. code += (index + 1).toString();
  662. codeString.textContent = `Code: ${code}`;
  663. }
  664. };
  665. attributeRow.appendChild(plusButton);
  666.  
  667. popup.appendChild(attributeRow);
  668. });
  669.  
  670. const createBuildButton = document.createElement("button");
  671. createBuildButton.id = "createBuildButton";
  672. createBuildButton.textContent = "Create Build";
  673. createBuildButton.onclick = () => {
  674. const buildName = buildNameInput.value.trim();
  675. if (buildName === "") {
  676. alert("Please enter a build name.");
  677. return;
  678. }
  679.  
  680. let savedButtons = JSON.parse(localStorage.getItem("savedButtons")) || [];
  681. savedButtons.push({ name: buildName, color: "#C0C0C0", cmd: codeString.textContent });
  682. localStorage.setItem("savedButtons", JSON.stringify(savedButtons));
  683.  
  684. const buttonContainer = document.createElement("div");
  685. buttonContainer.style.display = "flex";
  686. buttonContainer.style.alignItems = "center";
  687. buttonContainer.style.justifyContent = "center";
  688.  
  689. const removeButton = document.createElement("button");
  690. removeButton.className = "remove-button";
  691. removeButton.textContent = "🖉";
  692. removeButton.onclick = () => {
  693. buttonContainer.remove();
  694. const updatedButtons = JSON.parse(localStorage.getItem("savedButtons")) || [];
  695. const newSavedButtons = updatedButtons.filter(b => b.name !== buildName);
  696. localStorage.setItem("savedButtons", JSON.stringify(newSavedButtons));
  697. };
  698. buttonContainer.appendChild(removeButton);
  699.  
  700. const newButton = document.createElement("button");
  701. newButton.className = "button";
  702. newButton.textContent = buildName;
  703. newButton.style.backgroundColor = "#C0C0C0";
  704. newButton.onclick = () => {
  705. const spawnName = userInput.value.trim();
  706. window.input.execute(`game_spawn ${spawnName}`);
  707. window.input.execute(`game_stats_build ${codeString.textContent}`);
  708. const hoverMenu = document.getElementById("myhover");
  709. if (hoverMenu) {
  710. hoverMenu.style.display = hoverMenu.style.display === "none" ? "block" : "none";
  711. }
  712. };
  713. buttonContainer.appendChild(newButton);
  714.  
  715. buildButtonsContainer.appendChild(buttonContainer);
  716.  
  717. document.body.removeChild(popup);
  718. };
  719. popup.appendChild(createBuildButton);
  720.  
  721. document.body.appendChild(popup);
  722. dragElement(document.getElementById("resetPopup"));
  723. };
  724.  
  725. modMenu.appendChild(specialButton);
  726. modMenu.appendChild(topRightButton);
  727. hoverMenu.appendChild(modMenu);
  728. document.body.appendChild(hoverMenu);
  729.  
  730. document.addEventListener("keydown", (event) => {
  731. if ((event.key === "r" || event.key === "R") && !["INPUT", "TEXTAREA"].includes(event.target.tagName)) {
  732. const hoverMenu = document.getElementById("myhover");
  733. if (hoverMenu) {
  734. hoverMenu.style.display = hoverMenu.style.display === "none" ? "block" : "none";
  735. }
  736. }
  737. });
  738.  
  739. window.onload = () => {
  740. const userInput = document.getElementById("userInput");
  741. const specialButton = document.getElementById("specialButton");
  742. const modMenu = document.getElementById("modtab");
  743. const topRightButton = document.getElementById("topRightButton");
  744.  
  745. const savedButtons = JSON.parse(localStorage.getItem("savedButtons")) || [];
  746.  
  747. const buildButtonsContainer = document.createElement("div");
  748. buildButtonsContainer.id = "buildButtonsContainer";
  749. buildButtonsContainer.style.maxHeight = "400px";
  750. buildButtonsContainer.style.overflowY = "scroll";
  751. buildButtonsContainer.style.color = "black";
  752. modMenu.insertBefore(buildButtonsContainer, specialButton);
  753.  
  754. function createButton(buttonData) {
  755. const buttonContainer = document.createElement("div");
  756. buttonContainer.style.display = "flex";
  757. buttonContainer.style.alignItems = "center";
  758. buttonContainer.style.justifyContent = "center";
  759.  
  760. const removeButton = document.createElement("button");
  761. removeButton.className = "remove-button";
  762. removeButton.textContent = "🖉";
  763. removeButton.onclick = () => {
  764. createRemovePopup(buttonContainer, buttonData);
  765. };
  766. buttonContainer.appendChild(removeButton);
  767.  
  768. const button = document.createElement("button");
  769. button.className = "button";
  770. button.textContent = buttonData.name;
  771. button.style.backgroundColor = buttonData.color;
  772. button.onclick = () => {
  773. const spawnName = userInput.value.trim();
  774. window.input.execute(`game_spawn ${spawnName}`);
  775. window.input.execute(`game_stats_build ${buttonData.cmd}`);
  776. const hoverMenu = document.getElementById("myhover");
  777. if (hoverMenu) {
  778. hoverMenu.style.display = hoverMenu.style.display === "none" ? "block" : "none";
  779. }
  780. };
  781. buttonContainer.appendChild(button);
  782.  
  783. buildButtonsContainer.appendChild(buttonContainer);
  784. }
  785.  
  786. savedButtons.forEach(buttonData => createButton(buttonData));
  787.  
  788. const createBuildButton = document.getElementById("createBuildButton");
  789. createBuildButton.onclick = () => {
  790. const buildNameInput = document.getElementById("buildNameInput");
  791. const buildName = buildNameInput.value.trim();
  792. if (buildName === "") {
  793. alert("Please enter a build name.");
  794. return;
  795. }
  796.  
  797. const code = "some_code_here";
  798.  
  799. let savedButtons = JSON.parse(localStorage.getItem("savedButtons")) || [];
  800. savedButtons.push({ name: buildName, color: "#C0C0C0", cmd: code });
  801. localStorage.setItem("savedButtons", JSON.stringify(savedButtons));
  802.  
  803. createButton({ name: buildName, color: "#C0C0C0", cmd: code });
  804.  
  805. const popup = document.getElementById("popup");
  806. document.body.removeChild(popup);
  807. };
  808. };
  809.  
  810. document.getElementById("userInput").addEventListener("input", (event) => {
  811. localStorage.setItem("quickSpawnUsername", event.target.value);
  812. });
  813.  
  814. topRightButton.addEventListener("click", () => {
  815. const resetPopup = document.createElement("div");
  816. resetPopup.className = "popup";
  817.  
  818. const closeButton = document.createElement("button");
  819. closeButton.className = "close-btn";
  820. closeButton.textContent = "X";
  821. closeButton.onclick = () => {
  822. document.body.removeChild(resetPopup);
  823. };
  824. resetPopup.appendChild(closeButton);
  825.  
  826. const confirmationMessage = document.createElement("div");
  827. confirmationMessage.textContent = "Do you really want to reset to default builds?";
  828. confirmationMessage.style.textAlign = "center";
  829. confirmationMessage.style.marginBottom = "20px";
  830. resetPopup.appendChild(confirmationMessage);
  831.  
  832. const buttonsContainer = document.createElement("div");
  833. buttonsContainer.style.display = "flex";
  834. buttonsContainer.style.justifyContent = "space-between";
  835.  
  836. const noButton = document.createElement("button");
  837. noButton.className = "button";
  838. noButton.textContent = "NO";
  839. noButton.onclick = () => {
  840. document.body.removeChild(resetPopup);
  841. };
  842. buttonsContainer.appendChild(noButton);
  843.  
  844. const yesButton = document.createElement("button");
  845. yesButton.className = "button";
  846. yesButton.textContent = "YES";
  847. yesButton.onclick = () => {
  848. localStorage.removeItem("savedButtons");
  849. localStorage.removeItem("removedDefaults");
  850. location.reload();
  851. };
  852. buttonsContainer.appendChild(yesButton);
  853.  
  854. resetPopup.appendChild(buttonsContainer);
  855. document.body.appendChild(resetPopup);
  856. dragElement(document.getElementById("resetPopup"));
  857. dragElementVertical(document.getElementById("mainMenu"));
  858. });
  859.  
  860. function dragElement(elmnt) {
  861. var pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0;
  862. if (document.getElementById(elmnt.id + "Header")) {
  863. document.getElementById(elmnt.id + "Header").onmousedown = dragMouseDown;
  864. } else {
  865. elmnt.onmousedown = dragMouseDown;
  866. }
  867.  
  868. function dragMouseDown(e) {
  869. e = e || window.event;
  870. e.preventDefault();
  871. pos3 = e.clientX;
  872. pos4 = e.clientY;
  873. document.onmouseup = closeDragElement;
  874. document.onmousemove = elementDrag;
  875. }
  876.  
  877. function elementDrag(e) {
  878. e = e || window.event;
  879. e.preventDefault();
  880. pos1 = pos3 - e.clientX;
  881. pos2 = pos4 - e.clientY;
  882. pos3 = e.clientX;
  883. pos4 = e.clientY;
  884. elmnt.style.top = (elmnt.offsetTop - pos2) + "px";
  885. elmnt.style.left = (elmnt.offsetLeft - pos1) + "px";
  886. }
  887.  
  888. function closeDragElement() {
  889. document.onmouseup = null;
  890. document.onmousemove = null;
  891. }
  892. }
  893.  
  894. function dragElementVertical(elmnt) {
  895. var pos2 = 0, pos4 = 0;
  896. if (document.getElementById(elmnt.id + "Header")) {
  897. document.getElementById(elmnt.id + "Header").onmousedown = dragMouseDown;
  898. } else {
  899. elmnt.onmousedown = dragMouseDown;
  900. }
  901.  
  902. function dragMouseDown(e) {
  903. e = e || window.event;
  904. e.preventDefault();
  905. pos4 = e.clientY;
  906. document.onmouseup = closeDragElement;
  907. document.onmousemove = elementDrag;
  908. }
  909.  
  910. function elementDrag(e) {
  911. e = e || window.event;
  912. e.preventDefault();
  913. pos2 = pos4 - e.clientY;
  914. pos4 = e.clientY;
  915. elmnt.style.top = (elmnt.offsetTop - pos2) + "px";
  916. }
  917.  
  918. function closeDragElement() {
  919. document.onmouseup = null;
  920. document.onmousemove = null;
  921. }
  922. }
  923.  
  924. function createRemovePopup(buttonContainer, buttonData) {
  925. const popup = document.createElement("div");
  926. popup.className = "popup";
  927. popup.id = "removePopup";
  928. popup.innerHTML = `<div class="popup-header" id="removePopupHeader">Drag me</div> `;
  929. document.body.appendChild(popup);
  930.  
  931. const closeButton = document.createElement("button");
  932. closeButton.className = "close-btn";
  933. closeButton.textContent = "X";
  934. closeButton.onclick = () => {
  935. document.body.removeChild(popup);
  936. };
  937. popup.appendChild(closeButton);
  938.  
  939. const buildNameInput = document.createElement("input");
  940. buildNameInput.type = "text";
  941. buildNameInput.placeholder = "Build Name";
  942. buildNameInput.style.display = "block";
  943. buildNameInput.style.width = "80%";
  944. buildNameInput.style.margin = "0 auto 10px auto";
  945. buildNameInput.value = buttonData.name;
  946. popup.appendChild(buildNameInput);
  947.  
  948. const pointsCounter = document.createElement("div");
  949. pointsCounter.id = "pointsCounter";
  950. pointsCounter.textContent = "Points: 33";
  951. popup.appendChild(pointsCounter);
  952.  
  953. const codeString = document.createElement("input");
  954. codeString.id = "codeString";
  955. codeString.type = "text";
  956. codeString.value = buttonData.cmd;
  957. codeString.style.display = "block";
  958. codeString.style.width = "80%";
  959. codeString.style.margin = "0 auto 10px auto";
  960. popup.appendChild(codeString);
  961.  
  962. let totalPoints = 33;
  963. let code = buttonData.cmd;
  964.  
  965. const attributes = [
  966. { name: "Health Regen", color: "rgb(232, 188, 157)" },
  967. { name: "Max Health", color: "rgb(230, 128, 234)" },
  968. { name: "Body Damage", color: "rgb(165, 128, 234)" },
  969. { name: "Bullet Speed", color: "rgb(128, 162, 234)" },
  970. { name: "Bullet Penetration", color: "rgb(234, 215, 128)" },
  971. { name: "Bullet Damage", color: "rgb(234, 128, 128)" },
  972. { name: "Reload", color: "rgb(164, 234, 128)" },
  973. { name: "Movement Speed", color: "rgb(128, 234, 230)" },
  974. ];
  975.  
  976. function updateAttributes() {
  977. totalPoints = 33;
  978. attributes.forEach((attribute, index) => {
  979. const attributeRow = document.getElementById(`attributeRow-${index}`);
  980. const attributeCount = Math.min((code.match(new RegExp(index + 1, "g")) || []).length, 7);
  981. for (let i = 0; i < 7; i++) {
  982. const graySquare = attributeRow.children[i + 1];
  983. if (i < attributeCount) {
  984. graySquare.style.backgroundColor = attribute.color;
  985. graySquare.style.border = "1px solid black";
  986. totalPoints--;
  987. } else {
  988. graySquare.style.backgroundColor = "gray";
  989. graySquare.style.border = "0";
  990. }
  991. }
  992. });
  993. pointsCounter.textContent = `Points: ${totalPoints}`;
  994. }
  995.  
  996. attributes.forEach((attribute, index) => {
  997. const attributeRow = document.createElement("div");
  998. attributeRow.className = "attribute";
  999. attributeRow.id = `attributeRow-${index}`;
  1000. attributeRow.style.position = "relative";
  1001.  
  1002. const minusButton = document.createElement("button");
  1003. minusButton.style.padding = "0 5px";
  1004. minusButton.style.border = "1px solid black";
  1005. minusButton.style.borderTopLeftRadius = "50px";
  1006. minusButton.style.borderBottomLeftRadius = "50px";
  1007. minusButton.style.borderTopRightRadius = "0";
  1008. minusButton.style.borderBottomRightRadius = "0";
  1009. minusButton.style.width = "32px";
  1010. minusButton.style.height = "32px";
  1011. minusButton.textContent = "-";
  1012. minusButton.onclick = () => {
  1013. const coloredSquares = Array.from(attributeRow.children).filter(child => child !== plusButton && child.style.backgroundColor === attribute.color);
  1014. if (coloredSquares.length > 0 && totalPoints < 33) {
  1015. const square = coloredSquares[coloredSquares.length - 1];
  1016. square.style.backgroundColor = "gray";
  1017. square.style.border = "0";
  1018. totalPoints++;
  1019. pointsCounter.textContent = `Points: ${totalPoints}`;
  1020. code = code.slice(0, -1);
  1021. codeString.value = code;
  1022. updateAttributes();
  1023. }
  1024. };
  1025. attributeRow.appendChild(minusButton);
  1026.  
  1027. for (let i = 0; i < 7; i++) {
  1028. const colorDiv = document.createElement("div");
  1029. colorDiv.style.border = "0";
  1030. colorDiv.style.backgroundColor = "gray";
  1031. colorDiv.style.width = "30px";
  1032. colorDiv.style.height = "30px";
  1033. colorDiv.style.display = "inline-block";
  1034. colorDiv.style.position = "relative";
  1035. colorDiv.style.padding = "0 5px";
  1036.  
  1037. if (i === 3) {
  1038. const textSpan = document.createElement("span");
  1039. textSpan.textContent = attribute.name;
  1040. textSpan.style.position = "absolute";
  1041. textSpan.style.top = "50%";
  1042. textSpan.style.left = "50%";
  1043. textSpan.style.transform = "translate(-50%, -50%)";
  1044. textSpan.style.color = "white";
  1045. textSpan.style.pointerEvents = "none";
  1046. textSpan.style.whiteSpace = "nowrap";
  1047. textSpan.style.zIndex = "1";
  1048. textSpan.style.display = "inline-block";
  1049. textSpan.style.textShadow =
  1050. "1px 1px 1px black, -1px -1px 1px black, -1px 1px 1px black, 1px -1px 1px black";
  1051. textSpan.className = "attribute-text";
  1052.  
  1053. colorDiv.appendChild(textSpan);
  1054. }
  1055.  
  1056. attributeRow.appendChild(colorDiv);
  1057. }
  1058.  
  1059. const plusButton = document.createElement("button");
  1060. plusButton.style.padding = "0 5px";
  1061. plusButton.style.border = "1px solid black";
  1062. plusButton.style.borderTopLeftRadius = "0";
  1063. plusButton.style.borderBottomLeftRadius = "0";
  1064. plusButton.style.borderTopRightRadius = "50px";
  1065. plusButton.style.borderBottomRightRadius = "50px";
  1066. plusButton.style.width = "32px";
  1067. plusButton.style.height = "32px";
  1068. plusButton.style.color = "Black";
  1069. plusButton.style.fontWeight = "bold";
  1070. plusButton.textContent = "+";
  1071. plusButton.style.backgroundColor = attribute.color;
  1072.  
  1073. plusButton.onclick = () => {
  1074. const graySquares = Array.from(attributeRow.children).filter(child => child.style.backgroundColor === "gray" && child !== plusButton);
  1075. if (graySquares.length > 0 && totalPoints > 0) {
  1076. const square = graySquares[0];
  1077. square.style.backgroundColor = attribute.color;
  1078. square.style.border = "1px solid black";
  1079. totalPoints--;
  1080. pointsCounter.textContent = `Points: ${totalPoints}`;
  1081. code += (index + 1).toString();
  1082. codeString.value = code;
  1083. updateAttributes();
  1084. }
  1085. };
  1086. attributeRow.appendChild(plusButton);
  1087.  
  1088. popup.appendChild(attributeRow);
  1089. });
  1090.  
  1091. codeString.addEventListener("input", (event) => {
  1092. code = event.target.value;
  1093. updateAttributes();
  1094. adjustFontSize(codeString);
  1095. });
  1096.  
  1097. updateAttributes();
  1098. adjustFontSize(codeString);
  1099.  
  1100. const deleteButton = document.createElement("button");
  1101. deleteButton.id = "deleteButton";
  1102. deleteButton.textContent = "Delete Build";
  1103. deleteButton.style.display = "block";
  1104. deleteButton.style.margin = "10px auto";
  1105. deleteButton.style.width = "80%";
  1106. deleteButton.style.textAlign = "center";
  1107. deleteButton.style.fontSize = "14px";
  1108. deleteButton.style.color = "black";
  1109. deleteButton.style.backgroundColor = "white";
  1110. deleteButton.style.border = "2px solid black";
  1111. deleteButton.style.borderRadius = "5px";
  1112. deleteButton.style.cursor = "pointer";
  1113. deleteButton.onclick = () => {
  1114. const confirmationPopup = document.createElement("div");
  1115. confirmationPopup.className = "popup";
  1116. confirmationPopup.id = "confirmationPopup";
  1117. confirmationPopup.innerHTML = `<div class="popup-header" id="confirmationPopupHeader">Drag Me</div> `;
  1118. document.body.appendChild(confirmationPopup);
  1119.  
  1120. const confirmationMessage = document.createElement("div");
  1121. confirmationMessage.textContent = "Are you sure you want to delete this build?";
  1122. confirmationMessage.style.textAlign = "center";
  1123. confirmationMessage.style.marginBottom = "20px";
  1124. confirmationPopup.appendChild(confirmationMessage);
  1125.  
  1126. const buttonsContainer = document.createElement("div");
  1127. buttonsContainer.style.display = "flex";
  1128. buttonsContainer.style.justifyContent = "space-between";
  1129.  
  1130. const noButton = document.createElement("button");
  1131. noButton.className = "button";
  1132. noButton.textContent = "NO";
  1133. noButton.onclick = () => {
  1134. document.body.removeChild(confirmationPopup);
  1135. };
  1136. buttonsContainer.appendChild(noButton);
  1137.  
  1138. const yesButton = document.createElement("button");
  1139. yesButton.className = "button";
  1140. yesButton.textContent = "YES";
  1141. yesButton.onclick = () => {
  1142. buttonContainer.remove();
  1143. const updatedButtons = JSON.parse(localStorage.getItem("savedButtons")) || [];
  1144. const newSavedButtons = updatedButtons.filter(b => b.name !== buttonData.name);
  1145. localStorage.setItem("savedButtons", JSON.stringify(newSavedButtons));
  1146. document.body.removeChild(confirmationPopup);
  1147. document.body.removeChild(popup);
  1148. };
  1149. buttonsContainer.appendChild(yesButton);
  1150.  
  1151. confirmationPopup.appendChild(buttonsContainer);
  1152. document.body.appendChild(confirmationPopup);
  1153. dragElement(document.getElementById("confirmationPopup"));
  1154. };
  1155. popup.appendChild(deleteButton);
  1156.  
  1157. const saveChangesButton = document.createElement("button");
  1158. saveChangesButton.id = "saveChangesButton";
  1159. saveChangesButton.textContent = "Save Changes";
  1160. saveChangesButton.style.display = "block";
  1161. saveChangesButton.style.margin = "10px auto";
  1162. saveChangesButton.style.width = "80%";
  1163. saveChangesButton.style.textAlign = "center";
  1164. saveChangesButton.style.fontSize = "14px";
  1165. saveChangesButton.style.color = "black";
  1166. saveChangesButton.style.backgroundColor = "white";
  1167. saveChangesButton.style.border = "2px solid black";
  1168. saveChangesButton.style.borderRadius = "5px";
  1169. saveChangesButton.style.cursor = "pointer";
  1170. saveChangesButton.onclick = () => {
  1171. const buildName = buildNameInput.value.trim();
  1172. if (buildName === "") {
  1173. alert("Please enter a build name.");
  1174. return;
  1175. }
  1176.  
  1177. buttonData.name = buildName;
  1178. buttonData.cmd = codeString.value;
  1179. buttonContainer.querySelector(".button").textContent = buildName;
  1180.  
  1181. const savedButtons = JSON.parse(localStorage.getItem("savedButtons")) || [];
  1182. const updatedButtons = savedButtons.map(b => b.name === buttonData.name ? buttonData : b);
  1183. localStorage.setItem("savedButtons", JSON.stringify(updatedButtons));
  1184.  
  1185. document.body.removeChild(popup);
  1186. };
  1187. popup.appendChild(saveChangesButton);
  1188.  
  1189. document.body.appendChild(popup);
  1190. dragElement(document.getElementById("removePopup"));
  1191. }
  1192.  
  1193. function adjustFontSize(element) {
  1194. let fontSize = 16;
  1195. element.style.fontSize = fontSize + "px";
  1196. while (element.scrollWidth > element.clientWidth && fontSize > 6) {
  1197. fontSize--;
  1198. element.style.fontSize = fontSize + "px";
  1199. }
  1200. }
  1201. })();