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.03
  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.03
  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 = "2px solid black";
  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: code });
  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. let newSavedButtons = updatedButtons.filter(b => b.name !== buildName);
  696. localStorage.setItem("savedButtons", JSON.stringify(newSavedButtons));
  697.  
  698. let updatedRemovedDefaults = JSON.parse(localStorage.getItem("removedDefaults")) || [];
  699. updatedRemovedDefaults = updatedRemovedDefaults.filter(b => b !== buildName);
  700. localStorage.setItem("removedDefaults", JSON.stringify(updatedRemovedDefaults));
  701. };
  702. buttonContainer.appendChild(removeButton);
  703.  
  704. const newButton = document.createElement("button");
  705. newButton.className = "button";
  706. newButton.textContent = buildName;
  707. newButton.style.backgroundColor = "#C0C0C0";
  708. newButton.onclick = () => {
  709. const spawnName = userInput.value.trim();
  710. window.input.execute(`game_spawn ${spawnName}`);
  711. window.input.execute(`game_stats_build ${code}`);
  712. const hoverMenu = document.getElementById("myhover");
  713. if (hoverMenu) {
  714. hoverMenu.style.display = hoverMenu.style.display === "none" ? "block" : "none";
  715. }
  716. };
  717. buttonContainer.appendChild(newButton);
  718.  
  719. buildButtonsContainer.appendChild(buttonContainer);
  720.  
  721. document.body.removeChild(popup);
  722. };
  723. popup.appendChild(createBuildButton);
  724.  
  725. document.body.appendChild(popup);
  726. dragElement(document.getElementById("resetPopup"));
  727. };
  728.  
  729. modMenu.appendChild(specialButton);
  730. modMenu.appendChild(topRightButton);
  731. hoverMenu.appendChild(modMenu);
  732. document.body.appendChild(hoverMenu);
  733.  
  734. document.addEventListener("keydown", (event) => {
  735. if ((event.key === "r" || event.key === "R") && !["INPUT", "TEXTAREA"].includes(event.target.tagName)) {
  736. const hoverMenu = document.getElementById("myhover");
  737. if (hoverMenu) {
  738. hoverMenu.style.display = hoverMenu.style.display === "none" ? "block" : "none";
  739. }
  740. }
  741. });
  742.  
  743. window.onload = () => {
  744. const userInput = document.getElementById("userInput");
  745. const specialButton = document.getElementById("specialButton");
  746. const modMenu = document.getElementById("modtab");
  747. const topRightButton = document.getElementById("topRightButton");
  748.  
  749. const savedButtons = JSON.parse(localStorage.getItem("savedButtons")) || [];
  750. const removedDefaults = JSON.parse(localStorage.getItem("removedDefaults")) || [];
  751.  
  752. const defaultButtons = [
  753. { "name": "L3mon឵", "color": "#FFFFFF", "cmd": "656565656565654848748487484874877" },
  754. { "name": "Factory឵", "color": "#FFFFFF", "cmd": "567456745678567456745678567488888" },
  755. { "name": "OverLord2.0឵", "color": "#FFFFFF", "cmd": "456745674567456745674567456788888" },
  756. { "name": "OverLord឵", "color": "#FFFFFF", "cmd": "555666555566664444444888888822111" },
  757. { "name": "Juggernaut឵", "color": "#FFFFFF", "cmd": "213121312138238238883288327777777" },
  758. { "name": "SmasherPacifist឵", "color": "#FFFFFF", "cmd": "7654765476547654765476547654128128128312812812812831281281283" },
  759. { "name": "SmasherAttacker឵", "color": "#FFFFFF", "cmd": "7654765476547654765476547654111823823823823823823823823823823" },
  760. { "name": "SturdyDestroyer឵", "color": "#FFFFFF", "cmd": "456456456456456456456123123123123" },
  761. { "name": "Aggressor឵", "color": "#FFFFFF", "cmd": "456745674567456745674567456722111" },
  762. { "name": "SturdyAggressor឵", "color": "#FFFFFF", "cmd": "567856785678567856785678567822111" },
  763. { "name": "SturdyTriangle឵", "color": "#FFFFFF", "cmd": "567567567567567567567123123123123" },
  764. { "name": "Sniper឵", "color": "#FFFFFF", "cmd": "564456445644564815681568156818188" },
  765. { "name": "Trapper឵", "color": "#FFFFFF", "cmd": "567567485675674856756748567484848" },
  766. { "name": "Semi/Ram/Booster឵", "color": "#FFFFFF", "cmd": "567823567823148148567823567882314" },
  767. { "name": "anti-ram", "color឵": "#FFFFFF", "cmd": "234234562345623456234562345623456" },
  768. { "name": "pentrat/anti-ram឵", "color": "#FFFFFF", "cmd": "345345263452634526345263452634526" },
  769. { "name": "Anni/hybrid឵", "color": "#FFFFFF", "cmd": "456845684568456845678456782345678" },
  770. { "name": "OL/overseer឵", "color": "#FFFFFF", "cmd": "456845684568456845683456782345678" }
  771. ];
  772.  
  773. const allButtons = [...defaultButtons, ...savedButtons.filter(saved => !defaultButtons.some(defaultButton => defaultButton.name === saved.name))];
  774. const finalButtons = allButtons.filter(buttonData => !removedDefaults.includes(buttonData.name));
  775.  
  776. const buildButtonsContainer = document.createElement("div");
  777. buildButtonsContainer.id = "buildButtonsContainer";
  778. buildButtonsContainer.style.maxHeight = "400px";
  779. buildButtonsContainer.style.overflowY = "scroll";
  780. buildButtonsContainer.style.color = "black";
  781. modMenu.insertBefore(buildButtonsContainer, specialButton);
  782.  
  783. function createButton(buttonData) {
  784. const buttonContainer = document.createElement("div");
  785. buttonContainer.style.display = "flex";
  786. buttonContainer.style.alignItems = "center";
  787. buttonContainer.style.justifyContent = "center";
  788.  
  789. const removeButton = document.createElement("button");
  790. removeButton.className = "remove-button";
  791. removeButton.textContent = "🖉";
  792. removeButton.onclick = () => {
  793. createRemovePopup(buttonContainer, buttonData);
  794. };
  795. buttonContainer.appendChild(removeButton);
  796.  
  797. const button = document.createElement("button");
  798. button.className = "button";
  799. button.textContent = buttonData.name;
  800. button.style.backgroundColor = buttonData.color;
  801. button.onclick = () => {
  802. const spawnName = userInput.value.trim();
  803. window.input.execute(`game_spawn ${spawnName}`);
  804. window.input.execute(`game_stats_build ${buttonData.cmd}`);
  805. const hoverMenu = document.getElementById("myhover");
  806. if (hoverMenu) {
  807. hoverMenu.style.display = hoverMenu.style.display === "none" ? "block" : "none";
  808. }
  809. };
  810. buttonContainer.appendChild(button);
  811.  
  812. buildButtonsContainer.appendChild(buttonContainer);
  813. }
  814.  
  815. finalButtons.forEach(buttonData => createButton(buttonData));
  816.  
  817. const createBuildButton = document.getElementById("createBuildButton");
  818. createBuildButton.onclick = () => {
  819. const buildNameInput = document.getElementById("buildNameInput");
  820. const buildName = buildNameInput.value.trim();
  821. if (buildName === "") {
  822. alert("Please enter a build name.");
  823. return;
  824. }
  825.  
  826. const code = "some_code_here";
  827.  
  828. let savedButtons = JSON.parse(localStorage.getItem("savedButtons")) || [];
  829. savedButtons.push({ name: buildName, color: "#C0C0C0", cmd: code });
  830. localStorage.setItem("savedButtons", JSON.stringify(savedButtons));
  831.  
  832. createButton({ name: buildName, color: "#C0C0C0", cmd: code });
  833.  
  834. const popup = document.getElementById("popup");
  835. document.body.removeChild(popup);
  836. };
  837. };
  838.  
  839. document.getElementById("userInput").addEventListener("input", (event) => {
  840. localStorage.setItem("quickSpawnUsername", event.target.value);
  841. });
  842.  
  843. topRightButton.addEventListener("click", () => {
  844. const resetPopup = document.createElement("div");
  845. resetPopup.className = "popup";
  846.  
  847. const closeButton = document.createElement("button");
  848. closeButton.className = "close-btn";
  849. closeButton.textContent = "X";
  850. closeButton.onclick = () => {
  851. document.body.removeChild(resetPopup);
  852. };
  853. resetPopup.appendChild(closeButton);
  854.  
  855. const confirmationMessage = document.createElement("div");
  856. confirmationMessage.textContent = "Do you really want to reset to default builds?";
  857. confirmationMessage.style.textAlign = "center";
  858. confirmationMessage.style.marginBottom = "20px";
  859. resetPopup.appendChild(confirmationMessage);
  860.  
  861. const buttonsContainer = document.createElement("div");
  862. buttonsContainer.style.display = "flex";
  863. buttonsContainer.style.justifyContent = "space-between";
  864.  
  865. const noButton = document.createElement("button");
  866. noButton.className = "button";
  867. noButton.textContent = "NO";
  868. noButton.onclick = () => {
  869. document.body.removeChild(resetPopup);
  870. };
  871. buttonsContainer.appendChild(noButton);
  872.  
  873. const yesButton = document.createElement("button");
  874. yesButton.className = "button";
  875. yesButton.textContent = "YES";
  876. yesButton.onclick = () => {
  877. localStorage.removeItem("savedButtons");
  878. localStorage.removeItem("removedDefaults");
  879. location.reload();
  880. };
  881. buttonsContainer.appendChild(yesButton);
  882.  
  883. resetPopup.appendChild(buttonsContainer);
  884. document.body.appendChild(resetPopup);
  885. dragElement(document.getElementById("resetPopup"));
  886. dragElementVertical(document.getElementById("mainMenu"));
  887. });
  888.  
  889. function dragElement(elmnt) {
  890. var pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0;
  891. if (document.getElementById(elmnt.id + "Header")) {
  892. document.getElementById(elmnt.id + "Header").onmousedown = dragMouseDown;
  893. } else {
  894. elmnt.onmousedown = dragMouseDown;
  895. }
  896.  
  897. function dragMouseDown(e) {
  898. e = e || window.event;
  899. e.preventDefault();
  900. pos3 = e.clientX;
  901. pos4 = e.clientY;
  902. document.onmouseup = closeDragElement;
  903. document.onmousemove = elementDrag;
  904. }
  905.  
  906. function elementDrag(e) {
  907. e = e || window.event;
  908. e.preventDefault();
  909. pos1 = pos3 - e.clientX;
  910. pos2 = pos4 - e.clientY;
  911. pos3 = e.clientX;
  912. pos4 = e.clientY;
  913. elmnt.style.top = (elmnt.offsetTop - pos2) + "px";
  914. elmnt.style.left = (elmnt.offsetLeft - pos1) + "px";
  915. }
  916.  
  917. function closeDragElement() {
  918. document.onmouseup = null;
  919. document.onmousemove = null;
  920. }
  921. }
  922.  
  923. function dragElementVertical(elmnt) {
  924. var pos2 = 0, pos4 = 0;
  925. if (document.getElementById(elmnt.id + "Header")) {
  926. document.getElementById(elmnt.id + "Header").onmousedown = dragMouseDown;
  927. } else {
  928. elmnt.onmousedown = dragMouseDown;
  929. }
  930.  
  931. function dragMouseDown(e) {
  932. e = e || window.event;
  933. e.preventDefault();
  934. pos4 = e.clientY;
  935. document.onmouseup = closeDragElement;
  936. document.onmousemove = elementDrag;
  937. }
  938.  
  939. function elementDrag(e) {
  940. e = e || window.event;
  941. e.preventDefault();
  942. pos2 = pos4 - e.clientY;
  943. pos4 = e.clientY;
  944. elmnt.style.top = (elmnt.offsetTop - pos2) + "px";
  945. }
  946.  
  947. function closeDragElement() {
  948. document.onmouseup = null;
  949. document.onmousemove = null;
  950. }
  951. }
  952.  
  953. function createRemovePopup(buttonContainer, buttonData) {
  954. const popup = document.createElement("div");
  955. popup.className = "popup";
  956. popup.id = "removePopup";
  957. popup.innerHTML = `<div class="popup-header" id="removePopupHeader">Drag me</div> `;
  958. document.body.appendChild(popup);
  959.  
  960. const closeButton = document.createElement("button");
  961. closeButton.className = "close-btn";
  962. closeButton.textContent = "X";
  963. closeButton.onclick = () => {
  964. document.body.removeChild(popup);
  965. };
  966. popup.appendChild(closeButton);
  967.  
  968. const buildNameInput = document.createElement("input");
  969. buildNameInput.type = "text";
  970. buildNameInput.placeholder = "Build Name";
  971. buildNameInput.style.display = "block";
  972. buildNameInput.style.width = "80%";
  973. buildNameInput.style.margin = "0 auto 10px auto";
  974. buildNameInput.value = buttonData.name;
  975. popup.appendChild(buildNameInput);
  976.  
  977. const pointsCounter = document.createElement("div");
  978. pointsCounter.id = "pointsCounter";
  979. pointsCounter.textContent = "Points: 33";
  980. popup.appendChild(pointsCounter);
  981.  
  982. const codeString = document.createElement("input");
  983. codeString.id = "codeString";
  984. codeString.type = "text";
  985. codeString.value = buttonData.cmd;
  986. codeString.style.display = "block";
  987. codeString.style.width = "80%";
  988. codeString.style.margin = "0 auto 10px auto";
  989. popup.appendChild(codeString);
  990.  
  991. let totalPoints = 33;
  992. let code = buttonData.cmd;
  993.  
  994. const attributes = [
  995. { name: "Health Regen", color: "rgb(232, 188, 157)" },
  996. { name: "Max Health", color: "rgb(230, 128, 234)" },
  997. { name: "Body Damage", color: "rgb(165, 128, 234)" },
  998. { name: "Bullet Speed", color: "rgb(128, 162, 234)" },
  999. { name: "Bullet Penetration", color: "rgb(234, 215, 128)" },
  1000. { name: "Bullet Damage", color: "rgb(234, 128, 128)" },
  1001. { name: "Reload", color: "rgb(164, 234, 128)" },
  1002. { name: "Movement Speed", color: "rgb(128, 234, 230)" },
  1003. ];
  1004.  
  1005. function updateAttributes() {
  1006. totalPoints = 33;
  1007. attributes.forEach((attribute, index) => {
  1008. const attributeRow = document.getElementById(`attributeRow-${index}`);
  1009. const attributeCount = Math.min((code.match(new RegExp(index + 1, "g")) || []).length, 7);
  1010. for (let i = 0; i < 7; i++) {
  1011. const graySquare = attributeRow.children[i + 1];
  1012. if (i < attributeCount) {
  1013. graySquare.style.backgroundColor = attribute.color;
  1014. graySquare.style.border = "1px solid black";
  1015. totalPoints--;
  1016. } else {
  1017. graySquare.style.backgroundColor = "gray";
  1018. graySquare.style.border = "0";
  1019. }
  1020. }
  1021. });
  1022. pointsCounter.textContent = `Points: ${totalPoints}`;
  1023. }
  1024.  
  1025. attributes.forEach((attribute, index) => {
  1026. const attributeRow = document.createElement("div");
  1027. attributeRow.className = "attribute";
  1028. attributeRow.id = `attributeRow-${index}`;
  1029. attributeRow.style.position = "relative";
  1030.  
  1031. const minusButton = document.createElement("button");
  1032. minusButton.style.padding = "0 5px";
  1033. minusButton.style.border = "1px solid black";
  1034. minusButton.style.borderTopLeftRadius = "50px";
  1035. minusButton.style.borderBottomLeftRadius = "50px";
  1036. minusButton.style.borderTopRightRadius = "0";
  1037. minusButton.style.borderBottomRightRadius = "0";
  1038. minusButton.style.width = "32px";
  1039. minusButton.style.height = "32px";
  1040. minusButton.textContent = "-";
  1041. minusButton.onclick = () => {
  1042. const coloredSquares = Array.from(attributeRow.children).filter(child => child !== plusButton && child.style.backgroundColor === attribute.color);
  1043. if (coloredSquares.length > 0 && totalPoints < 33) {
  1044. const square = coloredSquares[coloredSquares.length - 1];
  1045. square.style.backgroundColor = "gray";
  1046. square.style.border = "0";
  1047. totalPoints++;
  1048. pointsCounter.textContent = `Points: ${totalPoints}`;
  1049. code = code.slice(0, -1);
  1050. codeString.value = code;
  1051. updateAttributes();
  1052. }
  1053. };
  1054. attributeRow.appendChild(minusButton);
  1055.  
  1056. for (let i = 0; i < 7; i++) {
  1057. const colorDiv = document.createElement("div");
  1058. colorDiv.style.border = "0";
  1059. colorDiv.style.backgroundColor = "gray";
  1060. colorDiv.style.width = "30px";
  1061. colorDiv.style.height = "30px";
  1062. colorDiv.style.display = "inline-block";
  1063. colorDiv.style.position = "relative";
  1064. colorDiv.style.padding = "0 5px";
  1065.  
  1066. if (i === 3) {
  1067. const textSpan = document.createElement("span");
  1068. textSpan.textContent = attribute.name;
  1069. textSpan.style.position = "absolute";
  1070. textSpan.style.top = "50%";
  1071. textSpan.style.left = "50%";
  1072. textSpan.style.transform = "translate(-50%, -50%)";
  1073. textSpan.style.color = "white";
  1074. textSpan.style.pointerEvents = "none";
  1075. textSpan.style.whiteSpace = "nowrap";
  1076. textSpan.style.zIndex = "1";
  1077. textSpan.style.display = "inline-block";
  1078. textSpan.style.textShadow =
  1079. "1px 1px 1px black, -1px -1px 1px black, -1px 1px 1px black, 1px -1px 1px black";
  1080. textSpan.className = "attribute-text";
  1081.  
  1082. colorDiv.appendChild(textSpan);
  1083. }
  1084.  
  1085. attributeRow.appendChild(colorDiv);
  1086. }
  1087.  
  1088. const plusButton = document.createElement("button");
  1089. plusButton.style.padding = "0 5px";
  1090. plusButton.style.border = "1px solid black";
  1091. plusButton.style.borderTopLeftRadius = "0";
  1092. plusButton.style.borderBottomLeftRadius = "0";
  1093. plusButton.style.borderTopRightRadius = "50px";
  1094. plusButton.style.borderBottomRightRadius = "50px";
  1095. plusButton.style.width = "32px";
  1096. plusButton.style.height = "32px";
  1097. plusButton.style.color = "Black";
  1098. plusButton.style.fontWeight = "bold";
  1099. plusButton.textContent = "+";
  1100. plusButton.style.backgroundColor = attribute.color;
  1101.  
  1102. plusButton.onclick = () => {
  1103. const graySquares = Array.from(attributeRow.children).filter(child => child.style.backgroundColor === "gray" && child !== plusButton);
  1104. if (graySquares.length > 0 && totalPoints > 0) {
  1105. const square = graySquares[0];
  1106. square.style.backgroundColor = attribute.color;
  1107. square.style.border = "1px solid black";
  1108. totalPoints--;
  1109. pointsCounter.textContent = `Points: ${totalPoints}`;
  1110. code += (index + 1).toString();
  1111. codeString.value = code;
  1112. updateAttributes();
  1113. }
  1114. };
  1115. attributeRow.appendChild(plusButton);
  1116.  
  1117. popup.appendChild(attributeRow);
  1118. });
  1119.  
  1120. codeString.addEventListener("input", (event) => {
  1121. code = event.target.value;
  1122. updateAttributes();
  1123. adjustFontSize(codeString);
  1124. });
  1125.  
  1126. updateAttributes();
  1127. adjustFontSize(codeString);
  1128.  
  1129. const deleteButton = document.createElement("button");
  1130. deleteButton.id = "deleteButton";
  1131. deleteButton.textContent = "Delete Build";
  1132. deleteButton.style.display = "block";
  1133. deleteButton.style.margin = "10px auto";
  1134. deleteButton.style.width = "80%";
  1135. deleteButton.style.textAlign = "center";
  1136. deleteButton.style.fontSize = "14px";
  1137. deleteButton.style.color = "black";
  1138. deleteButton.style.backgroundColor = "white";
  1139. deleteButton.style.border = "2px solid black";
  1140. deleteButton.style.borderRadius = "5px";
  1141. deleteButton.style.cursor = "pointer";
  1142. deleteButton.onclick = () => {
  1143. const confirmationPopup = document.createElement("div");
  1144. confirmationPopup.className = "popup";
  1145. confirmationPopup.id = "confirmationPopup";
  1146. confirmationPopup.innerHTML = `<div class="popup-header" id="confirmationPopupHeader">Drag Me</div> `;
  1147. document.body.appendChild(confirmationPopup);
  1148.  
  1149. const confirmationMessage = document.createElement("div");
  1150. confirmationMessage.textContent = "Are you sure you want to delete this build?";
  1151. confirmationMessage.style.textAlign = "center";
  1152. confirmationMessage.style.marginBottom = "20px";
  1153. confirmationPopup.appendChild(confirmationMessage);
  1154.  
  1155. const buttonsContainer = document.createElement("div");
  1156. buttonsContainer.style.display = "flex";
  1157. buttonsContainer.style.justifyContent = "space-between";
  1158.  
  1159. const noButton = document.createElement("button");
  1160. noButton.className = "button";
  1161. noButton.textContent = "NO";
  1162. noButton.onclick = () => {
  1163. document.body.removeChild(confirmationPopup);
  1164. };
  1165. buttonsContainer.appendChild(noButton);
  1166.  
  1167. const yesButton = document.createElement("button");
  1168. yesButton.className = "button";
  1169. yesButton.textContent = "YES";
  1170. yesButton.onclick = () => {
  1171. buttonContainer.remove();
  1172. const updatedButtons = JSON.parse(localStorage.getItem("savedButtons")) || [];
  1173. const newSavedButtons = updatedButtons.filter(b => b.name !== buttonData.name);
  1174. localStorage.setItem("savedButtons", JSON.stringify(newSavedButtons));
  1175. document.body.removeChild(confirmationPopup);
  1176. document.body.removeChild(popup);
  1177. };
  1178. buttonsContainer.appendChild(yesButton);
  1179.  
  1180. confirmationPopup.appendChild(buttonsContainer);
  1181. document.body.appendChild(confirmationPopup);
  1182. dragElement(document.getElementById("confirmationPopup"));
  1183. };
  1184. popup.appendChild(deleteButton);
  1185.  
  1186. const createBuildButton = document.createElement("button");
  1187. createBuildButton.id = "createBuildButton";
  1188. createBuildButton.textContent = "Save Changes";
  1189. createBuildButton.style.display = "block";
  1190. createBuildButton.style.margin = "10px auto";
  1191. createBuildButton.style.width = "80%";
  1192. createBuildButton.style.textAlign = "center";
  1193. createBuildButton.style.fontSize = "14px";
  1194. createBuildButton.style.color = "black";
  1195. createBuildButton.style.backgroundColor = "white";
  1196. createBuildButton.style.border = "2px solid black";
  1197. createBuildButton.style.borderRadius = "5px";
  1198. createBuildButton.style.cursor = "pointer";
  1199. createBuildButton.onclick = () => {
  1200. const buildName = buildNameInput.value.trim();
  1201. if (buildName === "") {
  1202. alert("Please enter a build name.");
  1203. return;
  1204. }
  1205.  
  1206. buttonData.name = buildName;
  1207. buttonData.cmd = codeString.value;
  1208. buttonContainer.querySelector(".button").textContent = buildName;
  1209.  
  1210. document.body.removeChild(popup);
  1211. };
  1212. popup.appendChild(createBuildButton);
  1213.  
  1214. document.body.appendChild(popup);
  1215. dragElement(document.getElementById("removePopup"));
  1216. }
  1217.  
  1218. function adjustFontSize(element) {
  1219. let fontSize = 16;
  1220. element.style.fontSize = fontSize + "px";
  1221. while (element.scrollWidth > element.clientWidth && fontSize > 6) {
  1222. fontSize--;
  1223. element.style.fontSize = fontSize + "px";
  1224. }
  1225. }
  1226. })();