Themes for Diep.io (POTD)

It's a great pack of tools to edit diep.io.

目前為 2021-11-18 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Themes for Diep.io (POTD)
  3. // @version 1.0.1
  4. // @description It's a great pack of tools to edit diep.io.
  5. // @author ICE⁷⁷⁷#5838
  6. // @namespace *://diep.io/
  7. // @match *://diep.io/
  8. // @grant GM_addStyle
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. GM_addStyle(`
  13. #dashboard {
  14. right: 10px;
  15. width: 444px;
  16. padding: 0px 5px 0px 5px;
  17. border-radius: 6px;
  18. position: absolute;
  19. border: 2px #00ffff solid;
  20. box-shadow: 8px 7px 17px 1px black;
  21. background: #25282be0;
  22. color: white;
  23. font-size: 20px;
  24. }
  25. #dashboard * {
  26. font-family: "Montserrat", sans-serif;
  27. font-weight: 600;
  28. }
  29. #dashboard input {
  30. outline: none;
  31. border: none;
  32. margin: 0;
  33. padding: 0;
  34. cursor: pointer;
  35. }
  36. #dashboard input[type="color"],
  37. #dashboard input[type="checkbox"] {
  38. background: rgba(0, 0, 0, 0);
  39. }
  40. #dashboard ::-webkit-color-swatch {
  41. border-radius: 50%;
  42. }
  43. #dashboard input[type="checkbox"] {
  44. margin-top: 3px;
  45. }
  46. #dashboard input[type="number"] {
  47. text-align: center;
  48. width: 75px;
  49. height: 10px;
  50. border: rgba(0, 0, 0, 0) 2px solid;
  51. color: white;
  52. background: black;
  53. padding: 3px 0px 3px 10px;
  54. border-radius: 25px;
  55. transition: border-color 0.3s;
  56. }
  57. #dashboard input[type="number"]:hover,
  58. #dashboard input[type="number"]:focus {
  59. border: #00ffffbf 2px solid;
  60. }
  61. #dashboard input::-webkit-color-swatch-wrapper {
  62. margin-top: 2px;
  63. outline: none;
  64. padding: 0;
  65. }
  66. #dashboard__header {
  67. padding: 10px 0px 20px 0px;
  68. cursor: move;
  69. display: flex;
  70. justify-content: space-around;
  71. }
  72. #dashboard__body {
  73. max-height: 500px;
  74. overflow-y: auto;
  75. overflow-x: hidden;
  76. }
  77. #dashboard__body::-webkit-scrollbar {
  78. width: 7.5px;
  79. }
  80. #dashboard__body::-webkit-scrollbar-track {
  81. background: #00ffff;
  82. border-radius: 25px;
  83. }
  84. #dashboard__body::-webkit-scrollbar-thumb {
  85. background: #070707;
  86. border-radius: 25px;
  87. }
  88. #dashboard__body::-webkit-scrollbar-thumb:hover,
  89. #dashboard::-webkit-scrollbar-thumb:active {
  90. background: #101010;
  91. transition: background 0.25s;
  92. }
  93. .section {
  94. margin: 5px 5px 10px 5px;
  95. }
  96. .section__options {
  97. margin-left: 20px;
  98. font-size: 75%;
  99. }
  100. .section__header {
  101. cursor: pointer;
  102. user-select: none;
  103. font-size: 110%;
  104. display: inline-block;
  105. margin-bottom: 5px;
  106. font-weight: bold;
  107. }
  108. .section__header::before {
  109. content: "- ";
  110. }
  111. .section__header.hidden::before {
  112. content: "+ ";
  113. }
  114. .section__option {
  115. height: 25px;
  116. width: 300px;
  117. padding: 5px 300px 0px 15px;
  118. border-left: 3px #255cd8 solid;
  119. transition: 0.2s;
  120. }
  121. .section__option span {
  122. margin-right: 5px;
  123. }
  124. .section__option input[type="color"] {
  125. width: 15px;
  126. height: 15px;
  127. border: none;
  128. padding: 0;
  129. }
  130. .section__option:hover {
  131. background: #ffffff12;
  132. }
  133. .section__option:focus-within {
  134. background: #ffffff26;
  135. border-left: 3px orange solid;
  136. }
  137. .option__value {
  138. float: right;
  139. display: inline-block;
  140. }
  141. .option__label {
  142. user-select: none;
  143. display: inline-block;
  144. }
  145. #dashboard__close {
  146. user-select: none;
  147. top: 12.5px;
  148. right: 12.5px;
  149. position: absolute;
  150. padding: 7.5px;
  151. width: 10px;
  152. height: 10px;
  153. display: flex;
  154. flex-direction: row;
  155. flex-wrap: wrap;
  156. text-decoration: none;
  157. align-content: space-around;
  158. justify-content: space-around;
  159. border: 2px grey solid;
  160. background: #25282bb8;
  161. border-radius: 50%;
  162. cursor: pointer;
  163. color: white;
  164. font-size: 70%;
  165. transition-property: background, color, border-color, transform;
  166. transition-duration: 0.5s, 0.5s, 0.5s, 0.05s;
  167. }
  168. #dashboard__close:hover {
  169. background: #00ffff;
  170. border-color: black;
  171. color: black;
  172. }
  173. #dashboard__close:active {
  174. transform: translateY(3px);
  175. }
  176. .header__btn {
  177. outline: none;
  178. border: none;
  179. padding: 10px 20px;
  180. cursor: pointer;
  181. color: white;
  182. font-weight: bold;
  183. transition-property: background-color;
  184. transition-duration: 0.3s;
  185. }
  186. .header__btn:hover {
  187. background-color: rgba(0, 0, 0, 0.33) !important;
  188. }
  189. #themes:hover {
  190. opacity: 1;
  191. transition: opacity 1s;
  192. }
  193. #themes {
  194. transition: opacity 1s 3s;
  195. opacity: 0.2;
  196. }
  197. #db_switcher::after,
  198. #db_switcher::before {
  199. content: " - ";
  200. }
  201. #db_switcher.hidden::after,
  202. #db_switcher.hidden::before {
  203. content: " + ";
  204. }
  205. #themes {
  206. position: absolute;
  207. width: 200px;
  208. }
  209. #themes button {
  210. outline: none;
  211. border: none;
  212. cursor: pointer;
  213. width: 75%;
  214. word-break: break-word;
  215. font-family: "Ubuntu";
  216. color: white;
  217. text-shadow: -0.1em -0.1em 0 #000000, 0 -0.1em 0 #000000,
  218. 0.1em -0.1em 0 #000000, 0.1em 0 0 #000000, 0.1em 0.1em 0 #000000,
  219. 0 0.1em 0 #000000, -0.1em 0.1em 0 #000000, -0.1em 0 0 #000000;
  220. opacity: 0.8;
  221. border: none;
  222. padding: 0.3em 0.5em;
  223. transition: filter 0.15s;
  224. transition: transform 0.3s;
  225. }
  226. #themes button:active:not([disabled]) {
  227. filter: brightness(0.75);
  228. }
  229. #themes button:hover:not([disabled]):not(:active) {
  230. filter: brightness(1.25);
  231. }
  232. #themes .themes__theme:hover {
  233. transform: translateX(15px);
  234. }
  235. #themes .themes__switcher {
  236. width: 100%;
  237. }
  238. `);
  239. (() => {
  240. const USERS_BUTTONS = [];
  241.  
  242. class Input {
  243. constructor(default_, cmd, isLast = false) {
  244. this.default = default_;
  245. this.cmd = cmd;
  246. this.el = document.createElement("input");
  247. this.isLast = isLast;
  248. }
  249. }
  250.  
  251. class ColorInput extends Input {
  252. constructor(default_, cmd, isLast) {
  253. super(default_, cmd, isLast);
  254. this.el.type = "color";
  255. this.el.value = this.default;
  256.  
  257. this.el.oninput = () => {
  258. input.execute(`${this.cmd}${this.el.value.slice(1)}`);
  259. };
  260. this.el.getValue = () => {
  261. return `${this.cmd}${this.el.value.slice(1)}`;
  262. };
  263. this.el.setValue = (values) => {
  264. let found = false;
  265. for (let value of values) {
  266. if (value.includes(this.cmd)) {
  267. found = true;
  268. const RE = new RegExp(this.cmd);
  269. const value_ = value.replace(RE, "");
  270. this.el.value = "#" + value_;
  271. break;
  272. }
  273. }
  274. if (!found) this.el.value = this.default;
  275. this.el.oninput();
  276. };
  277. }
  278. }
  279.  
  280. class CheckBoxInput extends Input {
  281. constructor(default_, cmd, isLast) {
  282. super(default_, cmd, isLast);
  283. this.el.type = "checkbox";
  284. this.el.checked = this.default;
  285.  
  286. this.el.oninput = () => {
  287. input.execute(`${this.cmd}${this.el.checked}`);
  288. };
  289. this.el.getValue = () => {
  290. return `${this.cmd}${this.el.checked}`;
  291. };
  292. this.el.setValue = (values) => {
  293. let found = false;
  294. for (let value of values) {
  295. if (value.includes(this.cmd)) {
  296. found = true;
  297. const RE = new RegExp(this.cmd);
  298. const value_ = value.replace(RE, "");
  299. if (value_ === "true") {
  300. this.el.checked = true;
  301. } else {
  302. this.el.checked = false;
  303. }
  304. break;
  305. }
  306. }
  307. if (!found) this.el.checked = this.default;
  308. this.el.oninput();
  309. };
  310. }
  311. }
  312.  
  313. class NumberInput extends Input {
  314. constructor(default_, cmd, step, min, max, isLast) {
  315. super(default_, cmd, isLast);
  316. this.el.type = "number";
  317. this.el.value = this.default;
  318. this.el.step = step;
  319. this.el.min = min;
  320. this.el.max = max;
  321.  
  322. this.el.oninput = () => {
  323. input.execute(`${this.cmd}${this.el.value}`);
  324. };
  325. this.el.getValue = () => {
  326. return `${this.cmd}${this.el.value}`;
  327. };
  328. this.el.setValue = (values) => {
  329. let found = false;
  330. for (let value of values) {
  331. if (value.includes(this.cmd)) {
  332. found = true;
  333. const RE = new RegExp(this.cmd);
  334. this.el.value = value.replace(RE, "");
  335. break;
  336. }
  337. }
  338. if (!found) this.el.value = this.default;
  339. this.el.oninput();
  340. };
  341. }
  342. }
  343.  
  344. function hideEl(el) {
  345. if (el.style.display != "none") {
  346. el.style.display = "none";
  347. } else {
  348. el.style.display = "";
  349. }
  350. }
  351.  
  352. function setDrag(el, el_child) {
  353. var newPosX = 0,
  354. newPosY = 0,
  355. MousePosX = 0,
  356. MousePosY = 0;
  357. if (el_child) {
  358. el_child.addEventListener("mousedown", MouseDown);
  359. } else el.addEventListener("mousedown", MouseDown);
  360.  
  361. function MouseDown(mouseDown) {
  362. MousePosX = mouseDown.pageX;
  363. MousePosY = mouseDown.pageY;
  364.  
  365. el.classList.add("dragableging");
  366. document.addEventListener("mousemove", elementMove);
  367. document.addEventListener("mouseup", stopElementMove);
  368. }
  369.  
  370. function elementMove(mouseMove) {
  371. newPosX = MousePosX - mouseMove.pageX;
  372. newPosY = MousePosY - mouseMove.pageY;
  373. MousePosX = mouseMove.pageX;
  374. MousePosY = mouseMove.pageY;
  375.  
  376. el.style.top = el.offsetTop - newPosY + "px";
  377. el.style.left = el.offsetLeft - newPosX + "px";
  378. }
  379.  
  380. function stopElementMove() {
  381. el.classList.remove("dragableging");
  382. document.removeEventListener("mousemove", elementMove);
  383. document.removeEventListener("mouseup", stopElementMove);
  384. }
  385. }
  386.  
  387. const OPTS_LIB = {
  388. "Global colors": {
  389. "Map background": new ColorInput("#cdcdcd", "ren_background_color 0x"),
  390. "Map border": new ColorInput("#000000", "ren_border_color 0x"),
  391. "Map border alpha": new NumberInput(
  392. 0.1,
  393. "ren_border_color_alpha ",
  394. 0.01,
  395. 0,
  396. 1
  397. ),
  398. "Map grid": new ColorInput("#000000", "ren_grid_color 0x"),
  399. "Map grid alpha": new NumberInput(
  400. 0.1,
  401. "ren_grid_base_alpha ",
  402. 0.01,
  403. 0,
  404. 1,
  405. true
  406. ),
  407. "Minimap background": new ColorInput(
  408. "#cdcdcd",
  409. "ren_minimap_background_color 0x"
  410. ),
  411. "Minimap border": new ColorInput(
  412. "#555555",
  413. "ren_minimap_border_color 0x",
  414. true
  415. ),
  416. "Soft colors": new CheckBoxInput(true, "ren_stroke_soft_color "),
  417. "Soft stroke intensity": new NumberInput(
  418. 0.25,
  419. "ren_stroke_soft_color_intensity ",
  420. 0.05,
  421. null,
  422. 1,
  423. true
  424. ),
  425.  
  426. Squares: new ColorInput("#ffe869", "net_replace_color 8 0x"),
  427. Triangles: new ColorInput("#fc7677", "net_replace_color 9 0x"),
  428. Pentagons: new ColorInput("#768dfc", "net_replace_color 10 0x"),
  429. "Shiny poligons": new ColorInput(
  430. "#89ff69",
  431. "net_replace_color 7 0x",
  432. true
  433. ),
  434. Crashers: new ColorInput("#ff77dc", "net_replace_color 11 0x"),
  435. "Neutral team": new ColorInput("#ffe869", "net_replace_color 12 0x"),
  436. "Fallen Bosses": new ColorInput(
  437. "#c0c0c0",
  438. "net_replace_color 17 0x",
  439. true
  440. ),
  441. "Health bar": new ColorInput("#85e37d", "ren_health_fill_color 0x"),
  442. "Health bar background": new ColorInput(
  443. "#555555",
  444. "ren_health_background_color 0x"
  445. ),
  446. "EXP bar": new ColorInput("#ffde43", "ren_xp_bar_fill_color 0x"),
  447. "Score bar": new ColorInput("#43ff91", "ren_score_bar_fill_color 0x"),
  448. "EXP/Score/Scoreboard backgrounds": new ColorInput(
  449. "#000000",
  450. "ren_bar_background_color 0x",
  451. true
  452. ),
  453. "Barrels & etc": new ColorInput("#999999", "net_replace_color 1 0x"),
  454. "Smasher & dominator bases": new ColorInput(
  455. "#555555",
  456. "net_replace_color 0 0x"
  457. ),
  458. },
  459. "TDM colors": {
  460. "Blue team": new ColorInput("#00b1de", "net_replace_color 3 0x"),
  461. "Red Team": new ColorInput("#f14e54", "net_replace_color 4 0x"),
  462. "Purple team": new ColorInput("#be7ff5", "net_replace_color 5 0x"),
  463. "Green team": new ColorInput("#00f46c", "net_replace_color 6 0x"),
  464. },
  465. "FFA colors": {
  466. "Your body": new ColorInput("#00b1de", "net_replace_color 2 0x"),
  467. "Enemies' bodies": new ColorInput("#f14e56", "net_replace_color 15 0x"),
  468. "Summoned squares": new ColorInput("#fbc477", "net_replace_color 16 0x"),
  469. "Maze walls": new ColorInput("#bbbbbb", "net_replace_color 14 0x"),
  470. "Scoreboard bar": new ColorInput("#44ffa0", "net_replace_color 13 0x"),
  471. },
  472. Other: {
  473. FPS: new CheckBoxInput(false, "ren_fps "),
  474. "Players' names": new CheckBoxInput(true, "ren_names "),
  475. "Health bar": new CheckBoxInput(true, "ren_health_bars "),
  476. "Show health bar values": new CheckBoxInput(
  477. false,
  478. "ren_raw_health_values "
  479. ),
  480. "Scoreboar names": new CheckBoxInput(true, "ren_scoreboard_names "),
  481. Scoreboard: new CheckBoxInput(true, "ren_scoreboard "),
  482. "Minimap viewport": new CheckBoxInput(false, "ren_minimap_viewport "),
  483. UI: new CheckBoxInput(true, "ren_ui "),
  484. "UI scale": new NumberInput(1, "ren_ui_scale ", 0.01, 0, null, true),
  485.  
  486. "Pattern grid": new CheckBoxInput(true, "ren_pattern_grid "),
  487. "Debug collisions": new CheckBoxInput(false, "ren_debug_collisions "),
  488. },
  489. };
  490.  
  491. const CONTAINER = document.createElement("div");
  492. CONTAINER.id = "themes";
  493. CONTAINER.innerHTML = `
  494. <button class="themes__switcher" style="background: #00ffff">Themes Menu</button>
  495. <div id="main-content" style="display: none;">
  496. <div id="global-themes"></div>
  497. <button class="themes__switcher" style="background: rgb(255, 212, 0);" >My
  498. themes</button>
  499. <div id="users-themes"></div>
  500. </div>
  501. `;
  502. document.body.append(CONTAINER);
  503.  
  504. const DASHBOARD = document.createElement("div");
  505. DASHBOARD.id = "dashboard";
  506. DASHBOARD.style.display = "none";
  507. DASHBOARD.innerHTML = `<div id="dashboard__header"></div><div id="dashboard__body"></div>`;
  508. document.body.append(DASHBOARD);
  509.  
  510. // const CLOSE = document.createElement("a");
  511. // CLOSE.id = "dashboard__close";
  512. // CLOSE.innerText = "☓";
  513. // CLOSE.onclick = () => {
  514. // DASHBOARD.style.display = "none";
  515. // };
  516. // document.querySelector("#dashboard__header").append(CLOSE);
  517.  
  518. function init() {
  519. const USERS_THEMES = JSON.parse(localStorage.getItem("users_themes"));
  520. const SELECTED_THEME = JSON.parse(localStorage.getItem("selected_theme"));
  521.  
  522. for (let category in OPTS_LIB) {
  523. const OPTIONS = document.createElement("div");
  524. OPTIONS.className = "section__options";
  525. const HEADER = createHeader(category);
  526.  
  527. for (let opt in OPTS_LIB[category]) {
  528. const PLAN = OPTS_LIB[category][opt];
  529. OPTIONS.append(createOption(opt, PLAN.el, PLAN.isLast));
  530. }
  531.  
  532. addSection(HEADER, OPTIONS);
  533. }
  534.  
  535. if (USERS_THEMES) {
  536. USERS_THEMES.map((t) => {
  537. createBthTheme(t.name, t.color, false, false);
  538. });
  539. [...CONTAINER.querySelectorAll(".themes__theme")].map((el) => {
  540. if (el.innerText === SELECTED_THEME.name) el.onclick();
  541. });
  542. }
  543. }
  544.  
  545. function addSection(header, options) {
  546. const SECTION = document.createElement("div");
  547. SECTION.className = "section";
  548.  
  549. SECTION.append(header, options);
  550.  
  551. document.querySelector("#dashboard__body").append(SECTION);
  552. }
  553.  
  554. function createHeader(text) {
  555. const HEADER = document.createElement("div");
  556. HEADER.className = "section__header";
  557. HEADER.innerText = text;
  558.  
  559. HEADER.onclick = function () {
  560. const OPTIONS = HEADER.parentElement.querySelector(".section__options");
  561. if (OPTIONS) {
  562. if (OPTIONS.style.display != "none") {
  563. HEADER.classList.add("hidden");
  564. OPTIONS.style.display = "none";
  565. } else {
  566. HEADER.classList.remove("hidden");
  567. OPTIONS.style.display = "";
  568. }
  569. }
  570. };
  571. return HEADER;
  572. }
  573.  
  574. function createOption(text, html, isLast = false) {
  575. const OPTION = document.createElement("div");
  576. OPTION.className = "section__option";
  577.  
  578. const OPTION_LABEL = document.createElement("span");
  579. OPTION_LABEL.className = "option__label";
  580. OPTION_LABEL.innerText = text + ": ";
  581.  
  582. const OPTION_VALUE = document.createElement("div");
  583. OPTION_VALUE.className = "option__value";
  584. OPTION_VALUE.append(html);
  585.  
  586. OPTION.append(OPTION_LABEL, OPTION_VALUE);
  587.  
  588. if (isLast) {
  589. OPTION.style.marginBottom = "10px";
  590. }
  591.  
  592. return OPTION;
  593. }
  594.  
  595. function initTheme(theme) {
  596. const { values } = theme;
  597. [
  598. ...document
  599. .querySelector("#dashboard__body")
  600. .querySelectorAll(".option__value *"),
  601. ].map((el) => el.setValue(values));
  602.  
  603. localStorage.setItem("selected_theme", JSON.stringify(theme));
  604. }
  605.  
  606. function createBthTheme(text, color, data, isGlobal = true) {
  607. const BUTTON = document.createElement("button");
  608. BUTTON.className = "themes__theme";
  609. BUTTON.style.backgroundColor = color;
  610. BUTTON.innerText = text;
  611. BUTTON.onclick = () => {
  612. if (!data) {
  613. initTheme(
  614. JSON.parse(localStorage.getItem("users_themes")).find(
  615. (el) => el.name === text
  616. )
  617. );
  618. } else {
  619. initTheme(data);
  620. }
  621. };
  622.  
  623. if (!isGlobal) {
  624. document.querySelector("#users-themes").append(BUTTON);
  625. USERS_BUTTONS.push(BUTTON);
  626. } else document.querySelector("#global-themes").append(BUTTON);
  627.  
  628. return BUTTON;
  629. }
  630.  
  631. function createDashHeadBtn(text, color, onclick) {
  632. const BUTTON = document.createElement("button");
  633. BUTTON.className = "header__btn";
  634. BUTTON.style.backgroundColor = color;
  635. BUTTON.innerText = text;
  636. BUTTON.onclick = onclick;
  637.  
  638. document.querySelector("#dashboard__header").append(BUTTON);
  639. }
  640.  
  641. function saveTheme() {
  642. const THEME_NAME = prompt("Write your theme name.");
  643. if (!THEME_NAME) {
  644. return alert("Invalid value!");
  645. }
  646. const THEME = {};
  647. var USERS_THEMES = JSON.parse(localStorage.getItem("users_themes"));
  648. if (!USERS_THEMES) {
  649. USERS_THEMES = [];
  650. }
  651. const isAdded = USERS_THEMES.find((t) => t.name === THEME_NAME);
  652. if (isAdded) {
  653. if (
  654. !confirm(
  655. "There is already the theme with the same name, that one will be updated, are you sure?"
  656. )
  657. )
  658. return;
  659. }
  660.  
  661. var THEME_COLOR = prompt(
  662. "Write your theme button color (hex color system but without #) or you can leave the current color if you click on 'Cancel'.\nExample: 'ff00ff' - piink."
  663. );
  664. if (THEME_COLOR !== null) {
  665. if (!/[a-f\d]{6}\b/i.test(THEME_COLOR)) {
  666. return alert("Invalid value! (a-f, 0-9)");
  667. }
  668. THEME_COLOR += "e6";
  669. }
  670.  
  671. const VALUES = [
  672. ...document
  673. .querySelector("#dashboard__body")
  674. .querySelectorAll(".option__value *"),
  675. ].map((el) => el.getValue());
  676.  
  677. if (!isAdded) {
  678. THEME.name = THEME_NAME;
  679. THEME.color = "#" + THEME_COLOR;
  680. THEME.values = VALUES;
  681. USERS_THEMES.push(THEME);
  682. createBthTheme(THEME.name, THEME.color, THEME, false);
  683. } else {
  684. if (THEME_COLOR !== null) isAdded.color = THEME_COLOR;
  685. isAdded.values = VALUES;
  686. if (
  687. !updateTheme(isAdded.name, isAdded.color, () => {
  688. isAdded.values.map((v) => input.execute(v));
  689. })
  690. ) {
  691. createBthTheme(
  692. THEME.name,
  693. THEME.color,
  694. () => THEME.values.map((v) => input.execute(v)),
  695. USERS_THEMES
  696. );
  697. }
  698. }
  699. localStorage.setItem("users_themes", JSON.stringify(USERS_THEMES));
  700. }
  701.  
  702. function updateTheme(name, new_color, new_onclick) {
  703. const BUTTON = USERS_BUTTONS.find((btn) => btn.innerText === name);
  704. if (!BUTTON) {
  705. return false;
  706. }
  707.  
  708. BUTTON.innerText = name;
  709. BUTTON.style.backgroundColor = new_color;
  710. BUTTON.onclick = () => {
  711. initTheme(
  712. JSON.parse(localStorage.getItem("users_themes")).find(
  713. (el) => el.name === name
  714. )
  715. );
  716.  
  717. new_onclick();
  718. };
  719.  
  720. return true;
  721. }
  722. function deleteTheme() {
  723. var USERS_THEMES = JSON.parse(localStorage.getItem("users_themes"));
  724. const NAME = prompt("Write theme name.");
  725.  
  726. const INDX = USERS_THEMES.findIndex((el) => el.name === NAME);
  727. if (INDX < 0) {
  728. return alert("Theme with a such name wasn't found!");
  729. }
  730. if (confirm("Are you sure?")) {
  731. USERS_THEMES.splice(INDX, 1);
  732. localStorage.setItem("users_themes", JSON.stringify(USERS_THEMES));
  733.  
  734. const BUTTON = USERS_BUTTONS.find((btn) => btn.innerText === NAME);
  735. if (BUTTON) {
  736. BUTTON.remove();
  737. }
  738. }
  739. }
  740.  
  741. createDashHeadBtn("Save theme", "green", saveTheme);
  742. createDashHeadBtn("Delete theme", "red", deleteTheme);
  743.  
  744. createBthTheme("Classic", "a5a5a5e6", { name: "Classic", values: [] });
  745. createBthTheme("Dark", "#222222e6", {
  746. name: "Dark",
  747. values: [
  748. "ren_border_color 0x858585",
  749. "ren_grid_color 0xffffff",
  750. "ren_background_color 0x101010",
  751. ],
  752. });
  753. createBthTheme("Arras", "#8bbe3de6", {
  754. name: "Arras",
  755. values: [
  756. "ren_score_bar_fill_color 0x8abc3f",
  757. "ren_xp_bar_fill_color 0xefc74b",
  758. "net_replace_color 0 0x484848",
  759. "net_replace_color 1 0xa7a7af",
  760. "net_replace_color 2 0x3ca4cb",
  761. "net_replace_color 3 0x3ca4cb",
  762. "net_replace_color 4 0xe03e41",
  763. "net_replace_color 5 0xcc669c",
  764. "net_replace_color 6 0x8abc3f",
  765. "net_replace_color 8 0xefc74b",
  766. "net_replace_color 9 0xe7896d",
  767. "net_replace_color 10 0x8d6adf",
  768. "net_replace_color 11 0xef99c3",
  769. "net_replace_color 12 0xfdf380",
  770. "net_replace_color 14 0xa7a7af",
  771. "net_replace_color 15 0xe03e41",
  772. "net_replace_color 17 0x726f6f",
  773. ],
  774. });
  775. createBthTheme("Neon", "#000000e6", {
  776. name: "Neon",
  777. values: [
  778. "ren_stroke_soft_color_intensity -100",
  779. "ren_solid_background true",
  780. "ren_stroke_soft_color true",
  781. "ren_background_color 0x000000",
  782. "ren_border_color 0xFFFFFF",
  783. "ren_border_alpha 100",
  784. "net_replace_color 0 0xFFFFFF",
  785. "net_replace_color 1 0x010101",
  786. "net_replace_color 2 0x000102",
  787. "net_replace_color 3 0x000102",
  788. "net_replace_color 4 0x020000",
  789. "net_replace_color 5 0x020002",
  790. "net_replace_color 6 0x000200",
  791. "net_replace_color 7 0x000100",
  792. "net_replace_color 8 0x010101",
  793. "net_replace_color 9 0x010101",
  794. "net_replace_color 10 0x010101",
  795. "net_replace_color 11 0x0e0e0e",
  796. "net_replace_color 12 0x020200",
  797. "net_replace_color 13 0x010101",
  798. "net_replace_color 14 0x010101",
  799. "net_replace_color 15 0x020000",
  800. "net_replace_color 16 0x010200",
  801. "net_replace_color 17 0x000202",
  802. ],
  803. });
  804.  
  805. document.querySelector("#themes button").onclick = () =>
  806. hideEl(document.querySelector("#main-content"));
  807. document.querySelector("#main-content .themes__switcher").onclick = () =>
  808. hideEl(document.querySelector("#users-themes"));
  809.  
  810. document.addEventListener("keydown", (event) => {
  811. if (["f", "а"].includes(event.key) && event.target == document.body) {
  812. hideEl(DASHBOARD);
  813. }
  814. });
  815.  
  816. setDrag(DASHBOARD, document.querySelector("#dashboard__header"));
  817. DASHBOARD.append(
  818. document.querySelector("#dashboard__header"),
  819. document.querySelector("#dashboard__body")
  820. );
  821.  
  822. const checking = setInterval(() => {
  823. try {
  824. if (input) {
  825. clearInterval(checking);
  826.  
  827. init();
  828. }
  829. } catch (err) {}
  830. }, 10);
  831. })();