Diep.io Custom Points Upgrader. Beta

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

  1. // ==UserScript==
  2. // @name Diep.io Custom Points Upgrader. Beta
  3. // @namespace http://tampermonkey.net/
  4. // @version 10.07
  5. // @homepage https://gf.qytechs.cn/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.07
  22. // @homepage https://gf.qytechs.cn/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.gf.qytechs.cn/scripts/416440/Diepio%20Custom%20Points%20Upgrader%20Beta.user.js
  29. // @updateURL https://update.gf.qytechs.cn/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 button = document.createElement("button");
  502. button.className = "button";
  503. button.textContent = buttonData.name;
  504. button.style.backgroundColor = buttonData.color;
  505. button.onclick = () => {
  506. const spawnName = userInput.value.trim();
  507. window.input.execute(`game_spawn ${spawnName}`);
  508. window.input.execute(`game_stats_build ${buttonData.cmd}`);
  509. const hoverMenu = document.getElementById("myhover");
  510. if (hoverMenu) {
  511. hoverMenu.style.display = hoverMenu.style.display === "none" ? "block" : "none";
  512. }
  513. };
  514. buttonContainer.appendChild(button);
  515.  
  516. modMenu.appendChild(buttonContainer);
  517. });
  518.  
  519. const specialButton = document.createElement("button");
  520. specialButton.id = "specialButton";
  521. specialButton.textContent = "[+]";
  522.  
  523. specialButton.onclick = () => {
  524. const popup = document.createElement("div");
  525. popup.className = "popup";
  526. popup.id = "resetPopup";
  527. popup.innerHTML = `<div class="popup-header" id="resetPopupHeader">Drag me</div> `;
  528. document.body.appendChild(popup);
  529.  
  530. const closeButton = document.createElement("button");
  531. closeButton.className = "close-btn";
  532. closeButton.textContent = "X";
  533. closeButton.onclick = () => {
  534. document.body.removeChild(popup);
  535. };
  536. popup.appendChild(closeButton);
  537.  
  538. const buildNameInput = document.createElement("input");
  539. buildNameInput.type = "text";
  540. buildNameInput.placeholder = "Build Name";
  541. buildNameInput.style.display = "block";
  542. buildNameInput.style.width = "80%";
  543. buildNameInput.style.margin = "0 auto 10px auto";
  544. popup.appendChild(buildNameInput);
  545.  
  546. const pointsCounter = document.createElement("div");
  547. pointsCounter.id = "pointsCounter";
  548. pointsCounter.textContent = "Points: 33";
  549. popup.appendChild(pointsCounter);
  550.  
  551. const codeString = document.createElement("input");
  552. codeString.id = "codeString";
  553. codeString.type = "text";
  554. codeString.value = "";
  555. codeString.style.display = "block";
  556. codeString.style.width = "80%";
  557. codeString.style.margin = "0 auto 10px auto";
  558. popup.appendChild(codeString);
  559.  
  560. let totalPoints = 33;
  561. let code = "";
  562.  
  563. const attributes = [
  564. { name: "Health Regen", color: "rgb(232, 188, 157)" },
  565. { name: "Max Health", color: "rgb(230, 128, 234)" },
  566. { name: "Body Damage", color: "rgb(165, 128, 234)" },
  567. { name: "Bullet Speed", color: "rgb(128, 162, 234)" },
  568. { name: "Bullet Penetration", color: "rgb(234, 215, 128)" },
  569. { name: "Bullet Damage", color: "rgb(234, 128, 128)" },
  570. { name: "Reload", color: "rgb(164, 234, 128)" },
  571. { name: "Movement Speed", color: "rgb(128, 234, 230)" },
  572. ];
  573.  
  574. function updateAttributes() {
  575. totalPoints = 33;
  576. attributes.forEach((attribute, index) => {
  577. const attributeRow = document.getElementById(`attributeRow-${index}`);
  578. const attributeCount = Math.min((code.match(new RegExp(index + 1, "g")) || []).length, 7);
  579. for (let i = 0; i < 7; i++) {
  580. const graySquare = attributeRow.children[i + 1];
  581. if (i < attributeCount) {
  582. graySquare.style.backgroundColor = attribute.color;
  583. graySquare.style.border = "1px solid black";
  584. totalPoints--;
  585. } else {
  586. graySquare.style.backgroundColor = "gray";
  587. graySquare.style.border = "0";
  588. }
  589. }
  590. });
  591. pointsCounter.textContent = `Points: ${totalPoints}`;
  592. }
  593.  
  594. attributes.forEach((attribute, index) => {
  595. const attributeRow = document.createElement("div");
  596. attributeRow.className = "attribute";
  597. attributeRow.id = `attributeRow-${index}`;
  598. attributeRow.style.position = "relative";
  599.  
  600. const minusButton = document.createElement("button");
  601. minusButton.style.padding = "0 5px";
  602. minusButton.style.border = "1px solid black";
  603. minusButton.style.borderTopLeftRadius = "50px";
  604. minusButton.style.borderBottomLeftRadius = "50px";
  605. minusButton.style.borderTopRightRadius = "0";
  606. minusButton.style.borderBottomRightRadius = "0";
  607. minusButton.style.width = "32px";
  608. minusButton.style.height = "32px";
  609. minusButton.textContent = "-";
  610. minusButton.onclick = () => {
  611. const coloredSquares = Array.from(attributeRow.children).filter(child => child !== plusButton && child.style.backgroundColor === attribute.color);
  612. if (coloredSquares.length > 0) {
  613. const square = coloredSquares[coloredSquares.length - 1];
  614. square.style.backgroundColor = "gray";
  615. square.style.border = "0";
  616. totalPoints++;
  617. pointsCounter.textContent = `Points: ${totalPoints}`;
  618. code = code.slice(0, -1);
  619. codeString.value = code;
  620. updateAttributes();
  621. }
  622. };
  623. attributeRow.appendChild(minusButton);
  624.  
  625. for (let i = 0; i < 7; i++) {
  626. const colorDiv = document.createElement("div");
  627. colorDiv.style.border = "0";
  628. colorDiv.style.backgroundColor = "gray";
  629. colorDiv.style.width = "30px";
  630. colorDiv.style.height = "30px";
  631. colorDiv.style.display = "inline-block";
  632. colorDiv.style.position = "relative";
  633. colorDiv.style.padding = "0 5px";
  634.  
  635. if (i === 3) {
  636. const textSpan = document.createElement("span");
  637. textSpan.textContent = attribute.name;
  638. textSpan.style.position = "absolute";
  639. textSpan.style.top = "50%";
  640. textSpan.style.left = "50%";
  641. textSpan.style.transform = "translate(-50%, -50%)";
  642. textSpan.style.color = "white";
  643. textSpan.style.pointerEvents = "none";
  644. textSpan.style.whiteSpace = "nowrap";
  645. textSpan.style.zIndex = "1";
  646. textSpan.style.display = "inline-block";
  647. textSpan.style.textShadow =
  648. "1px 1px 1px black, -1px -1px 1px black, -1px 1px 1px black, 1px -1px 1px black";
  649.  
  650. colorDiv.appendChild(textSpan);
  651. }
  652.  
  653. attributeRow.appendChild(colorDiv);
  654. }
  655.  
  656. const plusButton = document.createElement("button");
  657. plusButton.style.padding = "0 5px";
  658. plusButton.style.border = "1px solid black";
  659. plusButton.style.borderTopLeftRadius = "0";
  660. plusButton.style.borderBottomLeftRadius = "0";
  661. plusButton.style.borderTopRightRadius = "50px";
  662. plusButton.style.borderBottomRightRadius = "50px";
  663. plusButton.style.width = "32px";
  664. plusButton.style.height = "32px";
  665. plusButton.style.color = "Black";
  666. plusButton.style.fontWeight = "bold";
  667. plusButton.textContent = "+";
  668. plusButton.style.backgroundColor = attribute.color;
  669.  
  670. plusButton.onclick = () => {
  671. const graySquares = Array.from(attributeRow.children).filter(child => child.style.backgroundColor === "gray" && child !== plusButton);
  672. if (graySquares.length > 0) {
  673. const square = graySquares[0];
  674. square.style.backgroundColor = attribute.color;
  675. square.style.border = "1px solid black";
  676. totalPoints--;
  677. pointsCounter.textContent = `Points: ${totalPoints}`;
  678. code += (index + 1).toString();
  679. codeString.value = code;
  680. updateAttributes();
  681. }
  682. };
  683. attributeRow.appendChild(plusButton);
  684.  
  685. popup.appendChild(attributeRow);
  686. });
  687.  
  688. codeString.addEventListener("input", (event) => {
  689. code = event.target.value;
  690. updateAttributes();
  691. });
  692.  
  693. const createBuildButton = document.createElement("button");
  694. createBuildButton.id = "createBuildButton";
  695. createBuildButton.textContent = "Create Build";
  696. createBuildButton.onclick = () => {
  697. const buildName = buildNameInput.value.trim();
  698. if (buildName === "") {
  699. alert("Please enter a build name.");
  700. return;
  701. }
  702.  
  703. let savedButtons = JSON.parse(localStorage.getItem("savedButtons")) || [];
  704. const newButtonData = { name: buildName, color: "#C0C0C0", cmd: code };
  705. savedButtons.push(newButtonData);
  706. localStorage.setItem("savedButtons", JSON.stringify(savedButtons));
  707.  
  708. const buttonContainer = document.createElement("div");
  709. buttonContainer.style.display = "flex";
  710. buttonContainer.style.alignItems = "center";
  711. buttonContainer.style.justifyContent = "center";
  712.  
  713. const editButton = document.createElement("button");
  714. editButton.className = "edit-button";
  715. editButton.textContent = "🖉";
  716. editButton.style.width = "30px";
  717. editButton.style.height = "30px";
  718. editButton.onclick = () => {
  719. createEditPopup(buttonContainer, newButtonData);
  720. };
  721. buttonContainer.appendChild(editButton);
  722.  
  723. const newButton = document.createElement("button");
  724. newButton.className = "button";
  725. newButton.textContent = buildName;
  726. newButton.style.backgroundColor = "#C0C0C0";
  727. newButton.style.width = "100px";
  728. newButton.style.height = "30px";
  729. newButton.onclick = () => {
  730. const spawnName = userInput.value.trim();
  731. window.input.execute(`game_spawn ${spawnName}`);
  732. window.input.execute(`game_stats_build ${code}`);
  733. const hoverMenu = document.getElementById("myhover");
  734. if (hoverMenu) {
  735. hoverMenu.style.display = hoverMenu.style.display === "none" ? "block" : "none";
  736. }
  737. };
  738. buttonContainer.appendChild(newButton);
  739.  
  740. buildButtonsContainer.appendChild(buttonContainer);
  741.  
  742. document.body.removeChild(popup);
  743. };
  744. popup.appendChild(createBuildButton);
  745.  
  746. document.body.appendChild(popup);
  747. dragElement(document.getElementById("resetPopup"));
  748. };
  749.  
  750. modMenu.appendChild(specialButton);
  751. modMenu.appendChild(topRightButton);
  752. hoverMenu.appendChild(modMenu);
  753. document.body.appendChild(hoverMenu);
  754.  
  755. document.addEventListener("keydown", (event) => {
  756. if ((event.key === "r" || event.key === "R") && !["INPUT", "TEXTAREA"].includes(event.target.tagName)) {
  757. const hoverMenu = document.getElementById("myhover");
  758. if (hoverMenu) {
  759. hoverMenu.style.display = hoverMenu.style.display === "none" ? "block" : "none";
  760. }
  761. }
  762. });
  763.  
  764. window.onload = () => {
  765. const userInput = document.getElementById("userInput");
  766. const specialButton = document.getElementById("specialButton");
  767. const modMenu = document.getElementById("modtab");
  768. const topRightButton = document.getElementById("topRightButton");
  769.  
  770. const savedButtons = JSON.parse(localStorage.getItem("savedButtons")) || [];
  771.  
  772. const buildButtonsContainer = document.createElement("div");
  773. buildButtonsContainer.id = "buildButtonsContainer";
  774. buildButtonsContainer.style.maxHeight = "400px";
  775. buildButtonsContainer.style.overflowY = "scroll";
  776. buildButtonsContainer.style.color = "black";
  777. modMenu.insertBefore(buildButtonsContainer, specialButton);
  778.  
  779. function createButton(buttonData) {
  780. const buttonContainer = document.createElement("div");
  781. buttonContainer.style.display = "flex";
  782. buttonContainer.style.alignItems = "center";
  783. buttonContainer.style.justifyContent = "center";
  784.  
  785. const editButton = document.createElement("button");
  786. editButton.className = "edit-button";
  787. editButton.textContent = "🖉";
  788. editButton.onclick = () => {
  789. createEditPopup(buttonContainer, buttonData);
  790. };
  791. buttonContainer.appendChild(editButton);
  792.  
  793. const button = document.createElement("button");
  794. button.className = "button";
  795. button.textContent = buttonData.name;
  796. button.style.backgroundColor = buttonData.color;
  797. button.onclick = () => {
  798. const spawnName = userInput.value.trim();
  799. window.input.execute(`game_spawn ${spawnName}`);
  800. window.input.execute(`game_stats_build ${buttonData.cmd}`);
  801. const hoverMenu = document.getElementById("myhover");
  802. if (hoverMenu) {
  803. hoverMenu.style.display = hoverMenu.style.display === "none" ? "block" : "none";
  804. }
  805. };
  806. buttonContainer.appendChild(button);
  807.  
  808. buildButtonsContainer.appendChild(buttonContainer);
  809. }
  810.  
  811. savedButtons.forEach(buttonData => createButton(buttonData));
  812.  
  813. const createBuildButton = document.getElementById("createBuildButton");
  814. createBuildButton.onclick = () => {
  815. const buildNameInput = document.getElementById("buildNameInput");
  816. const buildName = buildNameInput.value.trim();
  817. if (buildName === "") {
  818. alert("Please enter a build name.");
  819. return;
  820. }
  821.  
  822. const code = "some_code_here";
  823.  
  824. let savedButtons = JSON.parse(localStorage.getItem("savedButtons")) || [];
  825. savedButtons.push({ name: buildName, color: "#C0C0C0", cmd: code });
  826. localStorage.setItem("savedButtons", JSON.stringify(savedButtons));
  827.  
  828. const buttonContainer = document.createElement("div");
  829. buttonContainer.style.display = "flex";
  830. buttonContainer.style.alignItems = "center";
  831. buttonContainer.style.justifyContent = "center";
  832.  
  833. const editButton = document.createElement("button");
  834. editButton.className = "edit-button";
  835. editButton.textContent = "🖉";
  836. editButton.onclick = () => {
  837. createEditPopup(buttonContainer, { name: buildName, color: "#C0C0C0", cmd: code });
  838. };
  839. buttonContainer.appendChild(editButton);
  840.  
  841. const newButton = document.createElement("button");
  842. newButton.className = "button";
  843. newButton.textContent = buildName;
  844. newButton.style.backgroundColor = "#C0C0C0";
  845. newButton.onclick = () => {
  846. const spawnName = userInput.value.trim();
  847. window.input.execute(`game_spawn ${spawnName}`);
  848. window.input.execute(`game_stats_build ${code}`);
  849. const hoverMenu = document.getElementById("myhover");
  850. if (hoverMenu) {
  851. hoverMenu.style.display = hoverMenu.style.display === "none" ? "block" : "none";
  852. }
  853. };
  854. buttonContainer.appendChild(newButton);
  855.  
  856. buildButtonsContainer.appendChild(buttonContainer);
  857.  
  858. document.body.removeChild(popup);
  859. };
  860. };
  861.  
  862. document.getElementById("userInput").addEventListener("input", (event) => {
  863. localStorage.setItem("quickSpawnUsername", event.target.value);
  864. });
  865.  
  866. topRightButton.addEventListener("click", () => {
  867. const resetPopup = document.createElement("div");
  868. resetPopup.className = "popup";
  869.  
  870. const closeButton = document.createElement("button");
  871. closeButton.className = "close-btn";
  872. closeButton.textContent = "X";
  873. closeButton.onclick = () => {
  874. document.body.removeChild(resetPopup);
  875. };
  876. resetPopup.appendChild(closeButton);
  877.  
  878. const confirmationMessage = document.createElement("div");
  879. confirmationMessage.textContent = "Do you really want to reset to default builds?";
  880. confirmationMessage.style.textAlign = "center";
  881. confirmationMessage.style.marginBottom = "20px";
  882. resetPopup.appendChild(confirmationMessage);
  883.  
  884. const buttonsContainer = document.createElement("div");
  885. buttonsContainer.style.display = "flex";
  886. buttonsContainer.style.justifyContent = "space-between";
  887.  
  888. const noButton = document.createElement("button");
  889. noButton.className = "button";
  890. noButton.textContent = "NO";
  891. noButton.onclick = () => {
  892. document.body.removeChild(resetPopup);
  893. };
  894. buttonsContainer.appendChild(noButton);
  895.  
  896. const yesButton = document.createElement("button");
  897. yesButton.className = "button";
  898. yesButton.textContent = "YES";
  899. yesButton.onclick = () => {
  900. localStorage.removeItem("savedButtons");
  901. localStorage.removeItem("removedDefaults");
  902. location.reload();
  903. };
  904. buttonsContainer.appendChild(yesButton);
  905.  
  906. resetPopup.appendChild(buttonsContainer);
  907. document.body.appendChild(resetPopup);
  908. dragElement(document.getElementById("resetPopup"));
  909. dragElementVertical(document.getElementById("mainMenu"));
  910. });
  911.  
  912. function dragElement(elmnt) {
  913. var pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0;
  914. if (document.getElementById(elmnt.id + "Header")) {
  915. document.getElementById(elmnt.id + "Header").onmousedown = dragMouseDown;
  916. } else {
  917. elmnt.onmousedown = dragMouseDown;
  918. }
  919.  
  920. function dragMouseDown(e) {
  921. e = e || window.event;
  922. e.preventDefault();
  923. pos3 = e.clientX;
  924. pos4 = e.clientY;
  925. document.onmouseup = closeDragElement;
  926. document.onmousemove = elementDrag;
  927. }
  928.  
  929. function elementDrag(e) {
  930. e = e || window.event;
  931. e.preventDefault();
  932. pos1 = pos3 - e.clientX;
  933. pos2 = pos4 - e.clientY;
  934. pos3 = e.clientX;
  935. pos4 = e.clientY;
  936. elmnt.style.top = (elmnt.offsetTop - pos2) + "px";
  937. elmnt.style.left = (elmnt.offsetLeft - pos1) + "px";
  938. }
  939.  
  940. function closeDragElement() {
  941. document.onmouseup = null;
  942. document.onmousemove = null;
  943. }
  944. }
  945.  
  946. function dragElementVertical(elmnt) {
  947. var pos2 = 0, pos4 = 0;
  948. if (document.getElementById(elmnt.id + "Header")) {
  949. document.getElementById(elmnt.id + "Header").onmousedown = dragMouseDown;
  950. } else {
  951. elmnt.onmousedown = dragMouseDown;
  952. }
  953.  
  954. function dragMouseDown(e) {
  955. e = e || window.event;
  956. e.preventDefault();
  957. pos4 = e.clientY;
  958. document.onmouseup = closeDragElement;
  959. document.onmousemove = elementDrag;
  960. }
  961.  
  962. function elementDrag(e) {
  963. e = e || window.event;
  964. e.preventDefault();
  965. pos2 = pos4 - e.clientY;
  966. pos4 = e.clientY;
  967. elmnt.style.top = (elmnt.offsetTop - pos2) + "px";
  968. }
  969.  
  970. function closeDragElement() {
  971. document.onmouseup = null;
  972. document.onmousemove = null;
  973. }
  974. }
  975.  
  976. function createRemovePopup(buttonContainer, buttonData) {
  977. const popup = document.createElement("div");
  978. popup.className = "popup";
  979. popup.id = "removePopup";
  980. popup.innerHTML = `<div class="popup-header" id="removePopupHeader">Drag me</div> `;
  981. document.body.appendChild(popup);
  982.  
  983. const closeButton = document.createElement("button");
  984. closeButton.className = "close-btn";
  985. closeButton.textContent = "X";
  986. closeButton.onclick = () => {
  987. document.body.removeChild(popup);
  988. };
  989. popup.appendChild(closeButton);
  990.  
  991. const buildNameInput = document.createElement("input");
  992. buildNameInput.type = "text";
  993. buildNameInput.placeholder = "Build Name";
  994. buildNameInput.style.display = "block";
  995. buildNameInput.style.width = "80%";
  996. buildNameInput.style.margin = "0 auto 10px auto";
  997. buildNameInput.value = buttonData.name;
  998. popup.appendChild(buildNameInput);
  999.  
  1000. const pointsCounter = document.createElement("div");
  1001. pointsCounter.id = "pointsCounter";
  1002. pointsCounter.textContent = "Points: 33";
  1003. popup.appendChild(pointsCounter);
  1004.  
  1005. const codeString = document.createElement("input");
  1006. codeString.id = "codeString";
  1007. codeString.type = "text";
  1008. codeString.value = buttonData.cmd;
  1009. codeString.style.display = "block";
  1010. codeString.style.width = "80%";
  1011. codeString.style.margin = "0 auto 10px auto";
  1012. popup.appendChild(codeString);
  1013.  
  1014. let totalPoints = 33;
  1015. let code = buttonData.cmd;
  1016.  
  1017. const attributes = [
  1018. { name: "Health Regen", color: "rgb(232, 188, 157)" },
  1019. { name: "Max Health", color: "rgb(230, 128, 234)" },
  1020. { name: "Body Damage", color: "rgb(165, 128, 234)" },
  1021. { name: "Bullet Speed", color: "rgb(128, 162, 234)" },
  1022. { name: "Bullet Penetration", color: "rgb(234, 215, 128)" },
  1023. { name: "Bullet Damage", color: "rgb(234, 128, 128)" },
  1024. { name: "Reload", color: "rgb(164, 234, 128)" },
  1025. { name: "Movement Speed", color: "rgb(128, 234, 230)" },
  1026. ];
  1027.  
  1028. function updateAttributes() {
  1029. totalPoints = 33;
  1030. attributes.forEach((attribute, index) => {
  1031. const attributeRow = document.getElementById(`attributeRow-${index}`);
  1032. const attributeCount = Math.min((code.match(new RegExp(index + 1, "g")) || []).length, 7);
  1033. for (let i = 0; i < 7; i++) {
  1034. const graySquare = attributeRow.children[i + 1];
  1035. if (i < attributeCount) {
  1036. graySquare.style.backgroundColor = attribute.color;
  1037. graySquare.style.border = "1px solid black";
  1038. totalPoints--;
  1039. } else {
  1040. graySquare.style.backgroundColor = "gray";
  1041. graySquare.style.border = "0";
  1042. }
  1043. }
  1044. });
  1045. pointsCounter.textContent = `Points: ${totalPoints}`;
  1046. }
  1047.  
  1048. attributes.forEach((attribute, index) => {
  1049. const attributeRow = document.createElement("div");
  1050. attributeRow.className = "attribute";
  1051. attributeRow.id = `attributeRow-${index}`;
  1052. attributeRow.style.position = "relative";
  1053.  
  1054. const minusButton = document.createElement("button");
  1055. minusButton.style.padding = "0 5px";
  1056. minusButton.style.border = "1px solid black";
  1057. minusButton.style.borderTopLeftRadius = "50px";
  1058. minusButton.style.borderBottomLeftRadius = "50px";
  1059. minusButton.style.borderTopRightRadius = "0";
  1060. minusButton.style.borderBottomRightRadius = "0";
  1061. minusButton.style.width = "32px";
  1062. minusButton.style.height = "32px";
  1063. minusButton.textContent = "-";
  1064. minusButton.onclick = () => {
  1065. const coloredSquares = Array.from(attributeRow.children).filter(child => child !== plusButton && child.style.backgroundColor === attribute.color);
  1066. if (coloredSquares.length > 0 && totalPoints < 33) {
  1067. const square = coloredSquares[coloredSquares.length - 1];
  1068. square.style.backgroundColor = "gray";
  1069. square.style.border = "0";
  1070. totalPoints++;
  1071. pointsCounter.textContent = `Points: ${totalPoints}`;
  1072. code = code.slice(0, -1);
  1073. codeString.value = code;
  1074. updateAttributes();
  1075. }
  1076. };
  1077. attributeRow.appendChild(minusButton);
  1078.  
  1079. for (let i = 0; i < 7; i++) {
  1080. const colorDiv = document.createElement("div");
  1081. colorDiv.style.border = "0";
  1082. colorDiv.style.backgroundColor = "gray";
  1083. colorDiv.style.width = "30px";
  1084. colorDiv.style.height = "30px";
  1085. colorDiv.style.display = "inline-block";
  1086. colorDiv.style.position = "relative";
  1087. colorDiv.style.padding = "0 5px";
  1088.  
  1089. if (i === 3) {
  1090. const textSpan = document.createElement("span");
  1091. textSpan.textContent = attribute.name;
  1092. textSpan.style.position = "absolute";
  1093. textSpan.style.top = "50%";
  1094. textSpan.style.left = "50%";
  1095. textSpan.style.transform = "translate(-50%, -50%)";
  1096. textSpan.style.color = "white";
  1097. textSpan.style.pointerEvents = "none";
  1098. textSpan.style.whiteSpace = "nowrap";
  1099. textSpan.style.zIndex = "1";
  1100. textSpan.style.display = "inline-block";
  1101. textSpan.style.textShadow =
  1102. "1px 1px 1px black, -1px -1px 1px black, -1px 1px 1px black, 1px -1px 1px black";
  1103. textSpan.className = "attribute-text";
  1104.  
  1105. colorDiv.appendChild(textSpan);
  1106. }
  1107.  
  1108. attributeRow.appendChild(colorDiv);
  1109. }
  1110.  
  1111. const plusButton = document.createElement("button");
  1112. plusButton.style.padding = "0 5px";
  1113. plusButton.style.border = "1px solid black";
  1114. plusButton.style.borderTopLeftRadius = "0";
  1115. plusButton.style.borderBottomLeftRadius = "0";
  1116. plusButton.style.borderTopRightRadius = "50px";
  1117. plusButton.style.borderBottomRightRadius = "50px";
  1118. plusButton.style.width = "32px";
  1119. plusButton.style.height = "32px";
  1120. plusButton.style.color = "Black";
  1121. plusButton.style.fontWeight = "bold";
  1122. plusButton.textContent = "+";
  1123. plusButton.style.backgroundColor = attribute.color;
  1124.  
  1125. plusButton.onclick = () => {
  1126. const graySquares = Array.from(attributeRow.children).filter(child => child.style.backgroundColor === "gray" && child !== plusButton);
  1127. if (graySquares.length > 0 && totalPoints > 0) {
  1128. const square = graySquares[0];
  1129. square.style.backgroundColor = attribute.color;
  1130. square.style.border = "1px solid black";
  1131. totalPoints--;
  1132. pointsCounter.textContent = `Points: ${totalPoints}`;
  1133. code += (index + 1).toString();
  1134. codeString.value = code;
  1135. updateAttributes();
  1136. }
  1137. };
  1138. attributeRow.appendChild(plusButton);
  1139.  
  1140. popup.appendChild(attributeRow);
  1141. });
  1142.  
  1143. codeString.addEventListener("input", (event) => {
  1144. code = event.target.value;
  1145. updateAttributes();
  1146. adjustFontSize(codeString);
  1147. });
  1148.  
  1149. updateAttributes();
  1150. adjustFontSize(codeString);
  1151.  
  1152. const deleteButton = document.createElement("button");
  1153. deleteButton.id = "deleteButton";
  1154. deleteButton.textContent = "Delete Build";
  1155. deleteButton.style.display = "block";
  1156. deleteButton.style.margin = "10px auto";
  1157. deleteButton.style.width = "80%";
  1158. deleteButton.style.textAlign = "center";
  1159. deleteButton.style.fontSize = "14px";
  1160. deleteButton.style.color = "black";
  1161. deleteButton.style.backgroundColor = "white";
  1162. deleteButton.style.border = "2px solid black";
  1163. deleteButton.style.borderRadius = "5px";
  1164. deleteButton.style.cursor = "pointer";
  1165. deleteButton.onclick = () => {
  1166. const confirmationPopup = document.createElement("div");
  1167. confirmationPopup.className = "popup";
  1168. confirmationPopup.id = "confirmationPopup";
  1169. confirmationPopup.innerHTML = `<div class="popup-header" id="confirmationPopupHeader">Drag Me</div> `;
  1170. document.body.appendChild(confirmationPopup);
  1171.  
  1172. const confirmationMessage = document.createElement("div");
  1173. confirmationMessage.textContent = "Are you sure you want to delete this build?";
  1174. confirmationMessage.style.textAlign = "center";
  1175. confirmationMessage.style.marginBottom = "20px";
  1176. confirmationPopup.appendChild(confirmationMessage);
  1177.  
  1178. const buttonsContainer = document.createElement("div");
  1179. buttonsContainer.style.display = "flex";
  1180. buttonsContainer.style.justifyContent = "space-between";
  1181.  
  1182. const noButton = document.createElement("button");
  1183. noButton.className = "button";
  1184. noButton.textContent = "NO";
  1185. noButton.onclick = () => {
  1186. document.body.removeChild(confirmationPopup);
  1187. };
  1188. buttonsContainer.appendChild(noButton);
  1189.  
  1190. const yesButton = document.createElement("button");
  1191. yesButton.className = "button";
  1192. yesButton.textContent = "YES";
  1193. yesButton.onclick = () => {
  1194. buttonContainer.remove();
  1195. const updatedButtons = JSON.parse(localStorage.getItem("savedButtons")) || [];
  1196. const newSavedButtons = updatedButtons.filter(b => b.name !== buttonData.name);
  1197. localStorage.setItem("savedButtons", JSON.stringify(newSavedButtons));
  1198. document.body.removeChild(confirmationPopup);
  1199. document.body.removeChild(popup);
  1200. };
  1201. buttonsContainer.appendChild(yesButton);
  1202.  
  1203. confirmationPopup.appendChild(buttonsContainer);
  1204. document.body.appendChild(confirmationPopup);
  1205. dragElement(document.getElementById("confirmationPopup"));
  1206. };
  1207. popup.appendChild(deleteButton);
  1208.  
  1209. const saveChangesButton = document.createElement("button");
  1210. saveChangesButton.id = "saveChangesButton";
  1211. saveChangesButton.textContent = "Save Changes";
  1212. saveChangesButton.style.display = "block";
  1213. saveChangesButton.style.margin = "10px auto";
  1214. saveChangesButton.style.width = "80%";
  1215. saveChangesButton.style.textAlign = "center";
  1216. saveChangesButton.style.fontSize = "14px";
  1217. saveChangesButton.style.color = "black";
  1218. saveChangesButton.style.backgroundColor = "white";
  1219. saveChangesButton.style.border = "2px solid black";
  1220. saveChangesButton.style.borderRadius = "5px";
  1221. saveChangesButton.style.cursor = "pointer";
  1222. saveChangesButton.onclick = () => {
  1223. const buildName = buildNameInput.value.trim();
  1224. if (buildName === "") {
  1225. alert("Please enter a build name.");
  1226. return;
  1227. }
  1228.  
  1229. buttonData.name = buildName;
  1230. buttonData.cmd = codeString.value;
  1231.  
  1232. const button = buttonContainer.querySelector(".button");
  1233. button.textContent = buildName;
  1234.  
  1235. const savedButtons = JSON.parse(localStorage.getItem("savedButtons")) || [];
  1236. const updatedButtons = savedButtons.map(b => b.name === buttonData.name ? buttonData : b);
  1237. localStorage.setItem("savedButtons", JSON.stringify(updatedButtons));
  1238.  
  1239. document.body.removeChild(popup);
  1240. };
  1241. popup.appendChild(saveChangesButton);
  1242.  
  1243. document.body.appendChild(popup);
  1244. dragElement(document.getElementById("removePopup"));
  1245. }
  1246.  
  1247. function adjustFontSize(element) {
  1248. let fontSize = 16;
  1249. element.style.fontSize = fontSize + "px";
  1250. while (element.scrollWidth > element.clientWidth && fontSize > 6) {
  1251. fontSize--;
  1252. element.style.fontSize = fontSize + "px";
  1253. }
  1254. }
  1255.  
  1256. function createEditPopup(buttonContainer, buttonData) {
  1257. const popupId = `editPopup-${Date.now()}`;
  1258. const popup = document.createElement("div");
  1259. popup.className = "popup";
  1260. popup.id = popupId;
  1261. popup.innerHTML = `<div class="popup-header" id="${popupId}Header">Drag me</div> `;
  1262. document.body.appendChild(popup);
  1263.  
  1264. const closeButton = document.createElement("button");
  1265. closeButton.className = "close-btn";
  1266. closeButton.textContent = "X";
  1267. closeButton.onclick = () => {
  1268. document.body.removeChild(popup);
  1269. };
  1270. popup.appendChild(closeButton);
  1271.  
  1272. const buildNameInput = document.createElement("input");
  1273. buildNameInput.type = "text";
  1274. buildNameInput.placeholder = "Build Name";
  1275. buildNameInput.style.display = "block";
  1276. buildNameInput.style.width = "80%";
  1277. buildNameInput.style.margin = "0 auto 10px auto";
  1278. buildNameInput.value = buttonData.name;
  1279. popup.appendChild(buildNameInput);
  1280.  
  1281. const pointsCounter = document.createElement("div");
  1282. pointsCounter.id = `pointsCounter-${popupId}`;
  1283. pointsCounter.textContent = "Points: 33";
  1284. popup.appendChild(pointsCounter);
  1285.  
  1286. const codeString = document.createElement("input");
  1287. codeString.id = `codeString-${popupId}`;
  1288. codeString.type = "text";
  1289. codeString.value = buttonData.cmd;
  1290. codeString.style.display = "block";
  1291. codeString.style.width = "80%";
  1292. codeString.style.margin = "0 auto 10px auto";
  1293. popup.appendChild(codeString);
  1294.  
  1295. let totalPoints = 33;
  1296. let code = buttonData.cmd;
  1297.  
  1298. const attributes = [
  1299. { name: "Health Regen", color: "rgb(232, 188, 157)" },
  1300. { name: "Max Health", color: "rgb(230, 128, 234)" },
  1301. { name: "Body Damage", color: "rgb(165, 128, 234)" },
  1302. { name: "Bullet Speed", color: "rgb(128, 162, 234)" },
  1303. { name: "Bullet Penetration", color: "rgb(234, 215, 128)" },
  1304. { name: "Bullet Damage", color: "rgb(234, 128, 128)" },
  1305. { name: "Reload", color: "rgb(164, 234, 128)" },
  1306. { name: "Movement Speed", color: "rgb(128, 234, 230)" },
  1307. ];
  1308.  
  1309. function updateAttributes() {
  1310. totalPoints = 33;
  1311. attributes.forEach((attribute, index) => {
  1312. const attributeRow = document.getElementById(`attributeRow-${popupId}-${index}`);
  1313. const attributeCount = Math.min((code.match(new RegExp(index + 1, "g")) || []).length, 7);
  1314. for (let i = 0; i < 7; i++) {
  1315. const graySquare = attributeRow.children[i + 1];
  1316. if (i < attributeCount) {
  1317. graySquare.style.backgroundColor = attribute.color;
  1318. graySquare.style.border = "1px solid black";
  1319. totalPoints--;
  1320. } else {
  1321. graySquare.style.backgroundColor = "gray";
  1322. graySquare.style.border = "0";
  1323. }
  1324. }
  1325. });
  1326. pointsCounter.textContent = `Points: ${totalPoints}`;
  1327. }
  1328.  
  1329. attributes.forEach((attribute, index) => {
  1330. const attributeRow = document.createElement("div");
  1331. attributeRow.className = "attribute";
  1332. attributeRow.id = `attributeRow-${popupId}-${index}`;
  1333. attributeRow.style.position = "relative";
  1334.  
  1335. const minusButton = document.createElement("button");
  1336. minusButton.style.padding = "0 5px";
  1337. minusButton.style.border = "1px solid black";
  1338. minusButton.style.borderTopLeftRadius = "50px";
  1339. minusButton.style.borderBottomLeftRadius = "50px";
  1340. minusButton.style.borderTopRightRadius = "0";
  1341. minusButton.style.borderBottomRightRadius = "0";
  1342. minusButton.style.width = "32px";
  1343. minusButton.style.height = "32px";
  1344. minusButton.textContent = "-";
  1345. minusButton.onclick = () => {
  1346. const coloredSquares = Array.from(attributeRow.children).filter(child => child !== plusButton && child.style.backgroundColor === attribute.color);
  1347. if (coloredSquares.length > 0) {
  1348. const square = coloredSquares[coloredSquares.length - 1];
  1349. square.style.backgroundColor = "gray";
  1350. square.style.border = "0";
  1351. totalPoints++;
  1352. pointsCounter.textContent = `Points: ${totalPoints}`;
  1353. code = code.slice(0, -1);
  1354. codeString.value = code;
  1355. updateAttributes();
  1356. }
  1357. };
  1358. attributeRow.appendChild(minusButton);
  1359.  
  1360. for (let i = 0; i < 7; i++) {
  1361. const colorDiv = document.createElement("div");
  1362. colorDiv.style.border = "0";
  1363. colorDiv.style.backgroundColor = "gray";
  1364. colorDiv.style.width = "30px";
  1365. colorDiv.style.height = "30px";
  1366. colorDiv.style.display = "inline-block";
  1367. colorDiv.style.position = "relative";
  1368. colorDiv.style.padding = "0 5px";
  1369.  
  1370. if (i === 3) {
  1371. const textSpan = document.createElement("span");
  1372. textSpan.textContent = attribute.name;
  1373. textSpan.style.position = "absolute";
  1374. textSpan.style.top = "50%";
  1375. textSpan.style.left = "50%";
  1376. textSpan.style.transform = "translate(-50%, -50%)";
  1377. textSpan.style.color = "white";
  1378. textSpan.style.pointerEvents = "none";
  1379. textSpan.style.whiteSpace = "nowrap";
  1380. textSpan.style.zIndex = "1";
  1381. textSpan.style.display = "inline-block";
  1382. textSpan.style.textShadow =
  1383. "1px 1px 1px black, -1px -1px 1px black, -1px 1px 1px black, 1px -1px 1px black";
  1384.  
  1385. colorDiv.appendChild(textSpan);
  1386. }
  1387.  
  1388. attributeRow.appendChild(colorDiv);
  1389. }
  1390.  
  1391. const plusButton = document.createElement("button");
  1392. plusButton.style.padding = "0 5px";
  1393. plusButton.style.border = "1px solid black";
  1394. plusButton.style.borderTopLeftRadius = "0";
  1395. plusButton.style.borderBottomLeftRadius = "0";
  1396. plusButton.style.borderTopRightRadius = "50px";
  1397. plusButton.style.borderBottomRightRadius = "50px";
  1398. plusButton.style.width = "32px";
  1399. plusButton.style.height = "32px";
  1400. plusButton.style.color = "Black";
  1401. plusButton.style.fontWeight = "bold";
  1402. plusButton.textContent = "+";
  1403. plusButton.style.backgroundColor = attribute.color;
  1404.  
  1405. plusButton.onclick = () => {
  1406. const graySquares = Array.from(attributeRow.children).filter(child => child.style.backgroundColor === "gray" && child !== plusButton);
  1407. if (graySquares.length > 0) {
  1408. const square = graySquares[0];
  1409. square.style.backgroundColor = attribute.color;
  1410. square.style.border = "1px solid black";
  1411. totalPoints--;
  1412. pointsCounter.textContent = `Points: ${totalPoints}`;
  1413. code += (index + 1).toString();
  1414. codeString.value = code;
  1415. updateAttributes();
  1416. }
  1417. };
  1418. attributeRow.appendChild(plusButton);
  1419.  
  1420. popup.appendChild(attributeRow);
  1421. });
  1422.  
  1423. codeString.addEventListener("input", (event) => {
  1424. code = event.target.value;
  1425. updateAttributes();
  1426. });
  1427.  
  1428. updateAttributes();
  1429.  
  1430. const saveChangesButton = document.createElement("button");
  1431. saveChangesButton.id = `saveChangesButton-${popupId}`;
  1432. saveChangesButton.textContent = "Save Changes";
  1433. saveChangesButton.style.display = "block";
  1434. saveChangesButton.style.margin = "10px auto";
  1435. saveChangesButton.style.width = "80%";
  1436. saveChangesButton.style.textAlign = "center";
  1437. saveChangesButton.style.fontSize = "14px";
  1438. saveChangesButton.style.color = "black";
  1439. saveChangesButton.style.backgroundColor = "white";
  1440. saveChangesButton.style.border = "2px solid black";
  1441. saveChangesButton.style.borderRadius = "5px";
  1442. saveChangesButton.style.cursor = "pointer";
  1443. saveChangesButton.onclick = () => {
  1444. const buildName = buildNameInput.value.trim();
  1445. if (buildName === "") {
  1446. alert("Please enter a build name.");
  1447. return;
  1448. }
  1449.  
  1450. buttonData.name = buildName;
  1451. buttonData.cmd = codeString.value;
  1452.  
  1453. const button = buttonContainer.querySelector(".button");
  1454. button.textContent = buildName;
  1455.  
  1456. const savedButtons = JSON.parse(localStorage.getItem("savedButtons")) || [];
  1457. const updatedButtons = savedButtons.map(b => b.name === buttonData.name ? buttonData : b);
  1458. localStorage.setItem("savedButtons", JSON.stringify(updatedButtons));
  1459.  
  1460. document.body.removeChild(popup);
  1461. };
  1462. popup.appendChild(saveChangesButton);
  1463.  
  1464. const deleteButton = document.createElement("button");
  1465. deleteButton.id = `deleteButton-${popupId}`;
  1466. deleteButton.textContent = "Delete Build";
  1467. deleteButton.style.display = "block";
  1468. deleteButton.style.margin = "10px auto";
  1469. deleteButton.style.width = "80%";
  1470. deleteButton.style.textAlign = "center";
  1471. deleteButton.style.fontSize = "14px";
  1472. deleteButton.style.color = "black";
  1473. deleteButton.style.backgroundColor = "white";
  1474. deleteButton.style.border = "2px solid black";
  1475. deleteButton.style.borderRadius = "5px";
  1476. deleteButton.style.cursor = "pointer";
  1477. deleteButton.onclick = () => {
  1478. const confirmationPopup = document.createElement("div");
  1479. confirmationPopup.className = "popup";
  1480. confirmationPopup.id = `confirmationPopup-${popupId}`;
  1481. confirmationPopup.innerHTML = `<div class="popup-header" id="confirmationPopupHeader-${popupId}">Drag Me</div> `;
  1482. document.body.appendChild(confirmationPopup);
  1483.  
  1484. const confirmationMessage = document.createElement("div");
  1485. confirmationMessage.textContent = "Are you sure you want to delete this build?";
  1486. confirmationMessage.style.textAlign = "center";
  1487. confirmationMessage.style.marginBottom = "20px";
  1488. confirmationPopup.appendChild(confirmationMessage);
  1489.  
  1490. const buttonsContainer = document.createElement("div");
  1491. buttonsContainer.style.display = "flex";
  1492. buttonsContainer.style.justifyContent = "space-between";
  1493.  
  1494. const noButton = document.createElement("button");
  1495. noButton.className = "button";
  1496. noButton.textContent = "NO";
  1497. noButton.onclick = () => {
  1498. document.body.removeChild(confirmationPopup);
  1499. };
  1500. buttonsContainer.appendChild(noButton);
  1501.  
  1502. const yesButton = document.createElement("button");
  1503. yesButton.className = "button";
  1504. yesButton.textContent = "YES";
  1505. yesButton.onclick = () => {
  1506. buttonContainer.remove();
  1507. const updatedButtons = JSON.parse(localStorage.getItem("savedButtons")) || [];
  1508. const newSavedButtons = updatedButtons.filter(b => b.name !== buttonData.name);
  1509. localStorage.setItem("savedButtons", JSON.stringify(newSavedButtons));
  1510. document.body.removeChild(confirmationPopup);
  1511. document.body.removeChild(popup);
  1512. };
  1513. buttonsContainer.appendChild(yesButton);
  1514.  
  1515. confirmationPopup.appendChild(buttonsContainer);
  1516. document.body.appendChild(confirmationPopup);
  1517. dragElement(document.getElementById(`confirmationPopup-${popupId}`));
  1518. };
  1519. popup.appendChild(deleteButton);
  1520.  
  1521. document.body.appendChild(popup);
  1522. dragElement(document.getElementById(popupId));
  1523. }
  1524.  
  1525. function createButton(buttonData) {
  1526. const buttonContainer = document.createElement("div");
  1527. buttonContainer.style.display = "flex";
  1528. buttonContainer.style.alignItems = "center";
  1529. buttonContainer.style.justifyContent = "center";
  1530.  
  1531. const editButton = document.createElement("button");
  1532. editButton.className = "edit-button";
  1533. editButton.textContent = "🖉";
  1534. editButton.onclick = () => {
  1535. createEditPopup(buttonContainer, buttonData);
  1536. };
  1537. buttonContainer.appendChild(editButton);
  1538.  
  1539. const button = document.createElement("button");
  1540. button.className = "button";
  1541. button.textContent = buttonData.name;
  1542. button.style.backgroundColor = buttonData.color;
  1543. button.onclick = () => {
  1544. const spawnName = userInput.value.trim();
  1545. window.input.execute(`game_spawn ${spawnName}`);
  1546. window.input.execute(`game_stats_build ${buttonData.cmd}`);
  1547. const hoverMenu = document.getElementById("myhover");
  1548. if (hoverMenu) {
  1549. hoverMenu.style.display = hoverMenu.style.display === "none" ? "block" : "none";
  1550. }
  1551. };
  1552. buttonContainer.appendChild(button);
  1553.  
  1554. buildButtonsContainer.appendChild(buttonContainer);
  1555. }
  1556. })();

QingJ © 2025

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