DIEP TYLERS UTILITY V2

Themes, Anti-AFK, Anti-Cheat, Kill-Counter, net_predict_movement = false, Store-Convar, Build-Menu!

当前为 2024-07-19 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name DIEP TYLERS UTILITY V2
  3. // @namespace http://tampermonkey.net/
  4. // @version 2.76
  5. // @namespace http://tampermonkey.net/
  6. // @description Themes, Anti-AFK, Anti-Cheat, Kill-Counter, net_predict_movement = false, Store-Convar, Build-Menu!
  7. // @author pinkthc
  8. // @match https://diep.io/
  9. // @icon https://www.google.com/s2/favicons?sz=64&domain=diep.io
  10. // @grant GM_getValue
  11. // @grant GM_setValue
  12. // @grant GM_addStyle
  13. // @grant GM_registerMenuCommand
  14. // @grant GM_unregisterMenuCommand
  15. // @license DV | Do not plagiarize.
  16. // ==/UserScript==
  17.  
  18. (function() {
  19. 'use strict';
  20. window.alert('Welcome to TYLERS UTILITY!');
  21. })();
  22.  
  23.  
  24. function getInputObject() {
  25. return new Promise(resolve => {
  26. if (unsafeWindow.input) resolve(unsafeWindow.input);
  27.  
  28. let interval = setInterval(() => {
  29. if (unsafeWindow.input) {
  30. clearInterval(interval);
  31. resolve(unsafeWindow.input);
  32. }
  33. });
  34. });
  35. }
  36.  
  37. function modifyStoringConvar() {
  38. document.getElementById("textInput")
  39. .addEventListener("change", event => {
  40. let pair = event.target.value.split(/\s+/g);
  41. if (unsafeWindow.input.get_convar(pair[0]))
  42. GM_setValue(pair[0], pair[1]);
  43. });
  44.  
  45. let set_convar = unsafeWindow.input.set_convar;
  46. unsafeWindow.input.set_convar = function (key, value) {
  47. if (unsafeWindow.input.get_convar(key))
  48. GM_setValue(key, value);
  49. set_convar.apply(unsafeWindow.input, arguments);
  50. }
  51.  
  52. let execute = unsafeWindow.input.execute;
  53. unsafeWindow.input.execute = function (command) {
  54. let pair = command.split(/\s+/g);
  55. if (unsafeWindow.input.get_convar(pair[0]))
  56. GM_setValue(pair[0], pair[1]);
  57. execute.apply(unsafeWindow.input, arguments);
  58. }
  59. }
  60.  
  61. (function init() {
  62. getInputObject()
  63. .then(modifyStoringConvar)
  64. .then(() => GM_listValues().forEach(key => unsafeWindow.input.set_convar(key, GM_getValue(key))));
  65. })();
  66.  
  67. (function() {
  68. 'use strict';
  69.  
  70. function injectScript(code) {
  71. const script = document.createElement('script');
  72. script.textContent = code;
  73. (document.head || document.documentElement).appendChild(script);
  74. script.remove();
  75. }
  76.  
  77. injectScript('net_predict_movement = false;');
  78.  
  79. function hook(target, callback){
  80. const check = () => {
  81. window.requestAnimationFrame(check)
  82. const func = CanvasRenderingContext2D.prototype[target]
  83.  
  84. if(func.toString().includes(target)){
  85.  
  86. CanvasRenderingContext2D.prototype[target] = new Proxy (func, {
  87. apply (method, thisArg, args) {
  88. callback(thisArg, args)
  89.  
  90. return Reflect.apply (method, thisArg, args)
  91. }
  92. });
  93. }
  94. }
  95. check()
  96. }
  97. let blacklist = new Array (0);
  98. let killCounter = 0;
  99. hook('fillText', function(thisArg, args){
  100. if (args[0].includes("You've killed ")) {
  101. if (blacklist.indexOf(args[0]) === -1) {
  102. killCounter+=1;
  103. blacklist.push (args[0])
  104. setTimeout (function() {
  105. blacklist.splice(blacklist.indexOf(args[0]), 1);
  106. },1000);
  107.  
  108. setTimeout (function() {
  109. blacklist.push(args[0]);
  110. },4600);
  111.  
  112. setTimeout (function() {
  113. blacklist.splice(blacklist.indexOf(args[0]), 1);
  114. },5000);
  115. }
  116. }
  117. })
  118.  
  119. const canvas = document.getElementById('canvas');
  120. const ctx = canvas.getContext('2d');
  121.  
  122. setInterval(() => {
  123. let gui = () => {
  124. ctx.fillStyle = "white";
  125. ctx.lineWidth = 5;
  126. ctx.font = "1.5em Ubuntu";
  127. ctx.strokeStyle = "black";
  128. ctx.strokeText(`Kills: ` + killCounter, canvas.width * 0.935, canvas.height * 0.8);
  129. ctx.fillText(`Kills: ` + killCounter, canvas.width * 0.935, canvas.height * 0.8);
  130.  
  131. window.requestAnimationFrame(gui);
  132. }
  133. gui();
  134. }, 1000);
  135.  
  136. function getBuilds() {
  137. const savedBuilds = GM_getValue("builds", null);
  138. return savedBuilds ? JSON.parse(savedBuilds) : [
  139. { name: "Anni", values: [1, 1, 0, 7, 7, 7, 3, 7] },
  140. { name: "Glass", values: [0, 0, 0, 7, 7, 7, 7, 5] },
  141. { name: "Ram", values: [5, 7, 7, 0, 0, 0, 7, 7] },
  142. { name: "OverLord", values: [0, 5, 0, 7, 7, 7, 0, 7] },
  143. { name: "Trapper", values: [5, 7, 0, 0, 7, 7, 7, 0] },
  144. { name: "Necro", values: [0, 0, 0, 7, 6, 7, 6, 7] },
  145. { name: "Spammer", values: [2, 3, 0, 7, 7, 7, 7, 0] },
  146. { name: "Tri-Angle", values: [4, 4, 4, 0, 7, 7, 7, 0] },
  147. { name: "Assassin", values: [2, 3, 0, 7, 7, 7, 3, 4] },
  148. { name: "Predator", values: [0, 0, 0, 6, 7, 7, 7, 6] },
  149. { name: "Penta", values: [1, 3, 0, 5, 6, 6, 7, 5] }
  150. ];
  151. }
  152.  
  153. function saveBuilds(builds) {
  154. GM_setValue("builds", JSON.stringify(builds));
  155. updateBuildMenu();
  156. }
  157.  
  158. let builds = getBuilds();
  159.  
  160. function sendCommand(command) {
  161. input.execute(command);
  162. }
  163.  
  164. function convertBuildToString(build) {
  165. return build.values.map((value, index) => (index + 1).toString().repeat(value)).join('');
  166. }
  167.  
  168. function optimizeBuildString(buildString) {
  169. const count = new Array(8).fill(0);
  170. for (let i = 0; i < buildString.length; i++) {
  171. count[buildString[i] - 1]++;
  172. }
  173.  
  174. let result = "";
  175. while (result.length < buildString.length) {
  176. let max = 0;
  177. let maxValue = null;
  178. for (let i = 0; i < count.length; i++) {
  179. if (count[i] > max) {
  180. max = count[i];
  181. maxValue = i + 1;
  182. }
  183. }
  184. result += maxValue.toString();
  185. count[maxValue - 1]--;
  186. }
  187.  
  188. return result;
  189. }
  190.  
  191. function determineBuildType(values) {
  192. const damageStats = values[4] + values[5];
  193. const ramStats = values[1] + values[2];
  194.  
  195. if (damageStats > ramStats) {
  196. return "damage";
  197. } else if (ramStats > damageStats) {
  198. return "ram";
  199. } else {
  200. return "balanced";
  201. }
  202. }
  203.  
  204. function selectBuild(build) {
  205. const buildType = determineBuildType(build.values);
  206. const initialPoints = buildType === "damage" ? "65" : buildType === "ram" ? "23" : "";
  207.  
  208. const buildString = initialPoints + optimizeBuildString(convertBuildToString(build));
  209. sendCommand(`game_stats_build ${buildString}`);
  210. console.log(`Build order: ${buildString}`);
  211. closeSubmenus();
  212. hideBuildValues();
  213. }
  214.  
  215. function createButton(label, icon, clickHandler) {
  216. const button = document.createElement("button");
  217. button.innerHTML = icon + " " + label;
  218. button.style.marginTop = "5px";
  219. button.style.backgroundColor = "rgba(0, 0, 0, 0.7)";
  220. button.style.color = "white";
  221. button.style.border = "none";
  222. button.style.cursor = "pointer";
  223. button.style.padding = "3px 6px";
  224. button.style.fontSize = "0.8em";
  225. button.addEventListener("click", clickHandler);
  226. return button;
  227. }
  228.  
  229. function showManageBuildsMenu() {
  230. let menu = document.querySelector("#manageBuildsMenu");
  231.  
  232. if (menu) {
  233. menu.parentNode.removeChild(menu);
  234. closeSubmenus();
  235. hideBuildValues();
  236. return;
  237. }
  238.  
  239. menu = document.createElement("div");
  240. menu.id = "manageBuildsMenu";
  241. menu.style.cssText = "position: fixed; top: 55%; left: 50%; transform: translate(-50%, -50%); background-color: rgba(0, 0, 0, 0.7); border: 1px solid grey; padding: 10px; text-align: center; z-index: 9999; color: white; font-size: 0.8em;";
  242.  
  243. builds.forEach((build, index) => {
  244. const buildElement = document.createElement("div");
  245. buildElement.classList.add("menu-item");
  246. buildElement.style.cssText = "font-family: sans-serif; display: flex; justify-content: space-between; align-items: center;";
  247.  
  248. const buildInfo = document.createElement("span");
  249. buildInfo.innerHTML = `${build.name}`;
  250. buildInfo.style.flex = "1";
  251.  
  252. const editButton = createButton("", "✎", (event) => {
  253. event.stopPropagation();
  254. editBuild(index);
  255. });
  256.  
  257. const deleteButton = createButton("", "⛌", (event) => {
  258. event.stopPropagation();
  259. deleteBuild(index);
  260. });
  261.  
  262. buildElement.appendChild(buildInfo);
  263. buildElement.appendChild(editButton);
  264. buildElement.appendChild(deleteButton);
  265.  
  266. menu.appendChild(buildElement);
  267. });
  268.  
  269. menu.appendChild(createButton("Add New Build", "➕", addNewBuild));
  270. menu.appendChild(createButton("Close", "➖", () => {
  271. menu.parentNode.removeChild(menu);
  272. hideBuildValues();
  273. }));
  274.  
  275. document.body.appendChild(menu);
  276. }
  277.  
  278. function editBuild(index) {
  279. let buildName = prompt("Enter build name", builds[index].name);
  280. let buildValues = prompt("Enter build values (e.g., 1,1,0,7,7,7,3,7)", builds[index].values.join(","));
  281.  
  282. if (buildName !== null && buildValues !== null) {
  283. builds[index].name = buildName;
  284. builds[index].values = buildValues.split(",").map(value => parseInt(value.trim(), 10));
  285. saveBuilds(builds);
  286. closeSubmenus();
  287. showManageBuildsMenu();
  288. }
  289. }
  290.  
  291. function deleteBuild(index) {
  292. builds.splice(index, 1);
  293. saveBuilds(builds);
  294. closeSubmenus();
  295. showManageBuildsMenu();
  296. }
  297.  
  298. function addNewBuild() {
  299. let buildName = prompt("Enter build name");
  300. let buildValues = prompt("Enter build values (e.g., 1,1,0,7,7,7,3,7)");
  301.  
  302. if (buildName !== null && buildValues !== null) {
  303. const newBuild = {
  304. name: buildName,
  305. values: buildValues.split(",").map(value => parseInt(value.trim(), 10))
  306. };
  307. builds.push(newBuild);
  308. saveBuilds(builds);
  309. closeSubmenus();
  310. showManageBuildsMenu();
  311. }
  312. }
  313.  
  314. function closeSubmenus() {
  315. document.querySelectorAll(".submenu").forEach(menu => menu.parentNode.removeChild(menu));
  316. }
  317.  
  318. function updateBuildMenu() {
  319. const menu = document.querySelector("#buildMenu");
  320. if (menu) {
  321. menu.innerHTML = '';
  322. builds.forEach((build, index) => {
  323. const buildElement = document.createElement("div");
  324. buildElement.classList.add("menu-item");
  325. buildElement.style.cssText = "font-family: sans-serif; display: flex; justify-content: space-between; align-items: center;";
  326.  
  327. const buildInfo = document.createElement("span");
  328. buildInfo.innerHTML = `${build.name}`;
  329. buildInfo.style.flex = "1";
  330.  
  331. const selectButton = createButton("Select", "", () => selectBuild(build));
  332.  
  333. buildElement.appendChild(buildInfo);
  334. buildElement.appendChild(selectButton);
  335. menu.appendChild(buildElement);
  336.  
  337. buildElement.addEventListener("mouseover", () => showBuildValues(build));
  338. buildElement.addEventListener("mouseout", hideBuildValues);
  339. });
  340. }
  341. }
  342.  
  343. function showBuildValues(build) {
  344. let buildValuesDisplay = document.querySelector("#buildValuesDisplay");
  345.  
  346. if (!buildValuesDisplay) {
  347. buildValuesDisplay = document.createElement("div");
  348. buildValuesDisplay.id = "buildValuesDisplay";
  349. buildValuesDisplay.style.cssText = "position: fixed; top: 55%; left: 50%; transform: translate(-50%, -50%); background-color: rgba(0, 0, 0, 0.7); border: 1px solid grey; padding: 5px; text-align: center; z-index: 9999; color: white; font-size: 0.8em;";
  350. document.body.appendChild(buildValuesDisplay);
  351. }
  352.  
  353. buildValuesDisplay.textContent = build.values.join("/");
  354. }
  355.  
  356. function hideBuildValues() {
  357. const buildValuesDisplay = document.querySelector("#buildValuesDisplay");
  358. if (buildValuesDisplay) {
  359. buildValuesDisplay.parentNode.removeChild(buildValuesDisplay);
  360. }
  361. }
  362.  
  363. function showBuildMenu() {
  364. let menu = document.querySelector("#buildMenu");
  365.  
  366. if (menu) {
  367. menu.parentNode.removeChild(menu);
  368. closeSubmenus();
  369. hideBuildValues();
  370. return;
  371. }
  372.  
  373. menu = document.createElement("div");
  374. menu.id = "buildMenu";
  375. menu.classList.add("submenu");
  376. menu.style.cssText = "position: fixed; top: 50%; transform: translateY(-50%); right: 20px; background-color: rgba(0, 0, 0, 0.7); border: 1px solid grey; padding: 5px; text-align: center; z-index: 9999; color: white; font-size: 0.8em;";
  377.  
  378. builds.forEach((build, index) => {
  379. const buildElement = document.createElement("div");
  380. buildElement.classList.add("menu-item");
  381. buildElement.style.cssText = "font-family: sans-serif; display: flex; justify-content: space-between; align-items: center;";
  382.  
  383. const buildInfo = document.createElement("span");
  384. buildInfo.innerHTML = `${build.name}`;
  385. buildInfo.style.flex = "1";
  386.  
  387. const selectButton = createButton("Select", "", () => selectBuild(build));
  388.  
  389. buildElement.appendChild(buildInfo);
  390. buildElement.appendChild(selectButton);
  391. menu.appendChild(buildElement);
  392.  
  393. buildElement.addEventListener("mouseover", () => showBuildValues(build));
  394. buildElement.addEventListener("mouseout", hideBuildValues);
  395. });
  396.  
  397. menu.appendChild(createButton("Manage Builds", "🛠", showManageBuildsMenu));
  398. menu.appendChild(createButton("Close", "➖", () => {
  399. menu.parentNode.removeChild(menu);
  400. hideBuildValues();
  401. }));
  402.  
  403. document.body.appendChild(menu);
  404. }
  405.  
  406. document.addEventListener('keydown', function(event) {
  407. if (event.key === 'r' || event.key === 'R') {
  408. showBuildMenu();
  409. }
  410. });
  411.  
  412. updateBuildMenu();
  413.  
  414. })();
  415.  
  416.  
  417. Object.freeze = new Proxy(Object.freeze, {
  418. apply(r, o, a) {
  419. Error.stackTraceLimit = 0;
  420. return r.apply(o, a);
  421. }
  422. });
  423.  
  424. (function () {
  425. "use strict";
  426. const jsColorPackage=`https://cdnjs.cloudflare.com/ajax/libs/jscolor/2.0.4/jscolor.min.js`;
  427. var localStorage;
  428. var saveList;
  429. var nowSetting;
  430. var isLocal;
  431. var clone;
  432. jsInit();
  433. setTimeout(pluginInit, 2000);
  434.  
  435. function jsInit() {
  436. Storage.prototype.setObject = function (key, value) {
  437. this.setItem(key, JSON.stringify(value));
  438. };
  439. Storage.prototype.getObject = function (key) {
  440. var value = this.getItem(key);
  441. return value && JSON.parse(value);
  442. };
  443. clone = function (obj) {
  444. return JSON.parse(JSON.stringify(obj));
  445. };
  446. window.diepStyle = {};
  447. localStorage = window.localStorage;
  448. if (location.href.indexOf("file://") >= 0) {
  449. var warning = false;
  450. warning ? "" : console.warn("off warning");
  451. isLocal = true;
  452. window.input = {
  453. set_convar: function () {
  454. warning ? console.warn("block input.set_convar") : "";
  455. },
  456. execute: function () {
  457. warning ? console.warn("block input.set_execute") : "";
  458. },
  459. };
  460. }
  461. }
  462.  
  463. function pluginInit() {
  464. storageInit();
  465. keyListen();
  466. tempInit();
  467. styleInit();
  468. diepStyle.onColor = onColor;
  469. diepStyle.storageInit = storageInit;
  470.  
  471. function storageInit(cmd) {
  472. var th = 50,
  473. netTH = 110;
  474. var colors = [
  475. {
  476. id: 2,
  477. name: "You FFA",
  478. color: "00b1de",
  479. },
  480. {
  481. id: 15,
  482. name: "Other FFA",
  483. color: "f14e54",
  484. },
  485. {
  486. id: 3,
  487. name: "Blue Team",
  488. color: "00b1de",
  489. },
  490. {
  491. id: 4,
  492. name: "Red Team",
  493. color: "f14e54",
  494. },
  495. {
  496. id: 5,
  497. name: "Purple Team",
  498. color: "bf7ff5",
  499. },
  500. {
  501. id: 6,
  502. name: "Green Team",
  503. color: "00e16e",
  504. },
  505. {
  506. id: 17,
  507. name: "Fallen team",
  508. color: "c6c6c6",
  509. },
  510. {
  511. id: 12,
  512. name: "Arena Closer",
  513. color: "ffe869",
  514. },
  515. {
  516. id: 8,
  517. name: "Square",
  518. color: "ffe869",
  519. },
  520. {
  521. id: 7,
  522. name: "Green Square?",
  523. color: "89ff69",
  524. },
  525. {
  526. id: 16,
  527. name: "Necro Square",
  528. color: "fcc376",
  529. },
  530. {
  531. id: 9,
  532. name: "Triangle",
  533. color: "fc7677",
  534. },
  535. {
  536. id: 10,
  537. name: "Pentagon",
  538. color: "768dfc",
  539. },
  540. {
  541. id: 11,
  542. name: "Crasher",
  543. color: "f177dd",
  544. },
  545. {
  546. id: 14,
  547. name: "Waze Wall",
  548. color: "bbbbbb",
  549. },
  550. {
  551. id: 1,
  552. name: "Turret",
  553. color: "999999",
  554. },
  555. {
  556. id: 0,
  557. name: "Smasher",
  558. color: "4f4f4f",
  559. },
  560. {
  561. id: th++,
  562. name: "All Bars",
  563. color: "000000",
  564. cmd: "ren_bar_background_color",
  565. },
  566. {
  567. id: th++,
  568. name: "Outline",
  569. color: "555555",
  570. cmd: "ren_stroke_solid_color",
  571. },
  572. {
  573. id: 13,
  574. name: "Leader Board",
  575. color: "64ff8c",
  576. },
  577. {
  578. id: th++,
  579. name: "Xp Bar",
  580. color: "ffde43",
  581. cmd: "ren_xp_bar_fill_color",
  582. },
  583. {
  584. id: th++,
  585. name: "Score Bar",
  586. color: "43ff91",
  587. cmd: "ren_score_bar_fill_color",
  588. },
  589. {
  590. id: th++,
  591. name: "Health Bar1",
  592. color: "85e37d",
  593. cmd: "ren_health_fill_color",
  594. },
  595. {
  596. id: th++,
  597. name: "Health Bar2",
  598. color: "555555",
  599. cmd: "ren_health_background_color",
  600. },
  601. {
  602. id: th++,
  603. name: "Grid Color",
  604. color: "000000",
  605. cmd: "ren_grid_color",
  606. },
  607. {
  608. id: th++,
  609. name: "Minimap 1",
  610. color: "CDCDCD",
  611. cmd: "ren_minimap_background_color",
  612. },
  613. {
  614. id: th++,
  615. name: "Minimap 2",
  616. color: "797979",
  617. cmd: "ren_minimap_border_color",
  618. },
  619. {
  620. id: th++,
  621. name: "Background 1",
  622. color: "CDCDCD",
  623. cmd: "ren_background_color",
  624. },
  625. {
  626. id: th++,
  627. name: "Background 2",
  628. color: "797979",
  629. cmd: "ren_border_color",
  630. },
  631. {
  632. id: netTH++,
  633. name: "UI Color1",
  634. color: "e69f6c",
  635. cmd: "ui_replace_colors",
  636. },
  637. {
  638. id: netTH++,
  639. name: "UI Color2",
  640. color: "ff73ff",
  641. cmd: "ui_replace_colors",
  642. },
  643. {
  644. id: netTH++,
  645. name: "UI Color3",
  646. color: "c980ff",
  647. cmd: "ui_replace_colors",
  648. },
  649. {
  650. id: netTH++,
  651. name: "UI Color4",
  652. color: "71b4ff",
  653. cmd: "ui_replace_colors",
  654. },
  655. {
  656. id: netTH++,
  657. name: "UI Color5",
  658. color: "ffed3f",
  659. cmd: "ui_replace_colors",
  660. },
  661. {
  662. id: netTH++,
  663. name: "UI Color6",
  664. color: "ff7979",
  665. cmd: "ui_replace_colors",
  666. },
  667. {
  668. id: netTH++,
  669. name: "UI Color7",
  670. color: "88ff41",
  671. cmd: "ui_replace_colors",
  672. },
  673. {
  674. id: netTH++,
  675. name: "UI Color8",
  676. color: "41ffff",
  677. cmd: "ui_replace_colors",
  678. },
  679. ];
  680. diepStyle.colorMap = new Map(
  681. colors.map(function (elem) {
  682. return [
  683. elem.id,
  684. {
  685. color: elem.color,
  686. cmd: elem.cmd || "no cmd",
  687. },
  688. ];
  689. })
  690. );
  691.  
  692. diepStyle.uiColorMap = function (cmd) {
  693. var uiTH = nowSetting.colors.findIndex(
  694. (elem) => elem.name == "UI Color1"
  695. );
  696. var colorBunch = "";
  697. var arr = [];
  698. if (cmd == "0x") {
  699. for (var i = 0; i < 8; i++) {
  700. colorBunch = " 0x" + nowSetting.colors[uiTH + i].color + colorBunch;
  701. }
  702. return colorBunch;
  703. }
  704. if (cmd == "array") {
  705. for (var i = 0; i < 8; i++) {
  706. arr.push(nowSetting.colors[uiTH + i].color);
  707. }
  708. return arr;
  709. }
  710. };
  711. var renders = [
  712. {
  713. name: "Grid Alpha",
  714. value: 0.1,
  715. cmd: "grid_base_alpha",
  716. },
  717. {
  718. name: "Outline Intensity",
  719. value: 0.25,
  720. cmd: "stroke_soft_color_intensity",
  721. },
  722. {
  723. name: "Show Outline",
  724. value: false,
  725. cmd: "stroke_soft_color",
  726. reverse: true,
  727. },
  728. {
  729. name: "Border Alpha",
  730. value: 0.1,
  731. cmd: "border_color_alpha",
  732. },
  733. {
  734. name: "UI Scale",
  735. value: 1,
  736. cmd: "ui_scale",
  737. },
  738. {
  739. name: "Clear UI",
  740. value: false,
  741. cmd: "ui",
  742. reverse: true,
  743. },
  744. {
  745. name: "Show FPS",
  746. value: false,
  747. cmd: "fps",
  748. },
  749. {
  750. name: "Show Health",
  751. value: false,
  752. cmd: "raw_health_values",
  753. },
  754. {
  755. name: "Hide Name",
  756. value: false,
  757. cmd: "names",
  758. reverse: true,
  759. },
  760. ];
  761.  
  762. (function checkHasStorage() {
  763. var _localStorage = localStorage.getObject("diepStyle");
  764. var page = 1;
  765. if (nowSetting && nowSetting.saveTH) {
  766. page = nowSetting.saveTH;
  767. }
  768. if (_localStorage && _localStorage.saveList) {
  769. saveList = _localStorage.saveList;
  770. nowSetting = _localStorage.nowSetting;
  771. }
  772. if (!nowSetting || cmd == "reset") {
  773. nowSetting = getBlankSetting();
  774. nowSetting.saveTH = page;
  775. }
  776.  
  777. if (!saveList) saveList = getBlankSaveList();
  778. saveList[0] = getBlankSetting();
  779. (function checkMissing() {
  780. var plain = getBlankSetting();
  781. plain.renders.forEach((elem, th) => {
  782. var index = nowSetting.renders.findIndex(
  783. (now) => elem.cmd == now.cmd
  784. );
  785. if (index < 0) {
  786. nowSetting.renders.splice(th, 0, elem);
  787. saveList[nowSetting.saveTH].renders.splice(th, 0, elem);
  788. }
  789. });
  790. plain.colors.forEach((elem, th) => {
  791. var index = nowSetting.colors.findIndex((now) => {
  792. if (elem.cmd && elem.cmd == now.cmd) return true;
  793. if ((elem.id || elem.id == 0) && elem.id == now.id) return true;
  794. });
  795. if (index < 0) {
  796. nowSetting.colors.splice(th, 0, elem);
  797. saveList[nowSetting.saveTH].colors.splice(th, 0, elem);
  798. }
  799. });
  800. })();
  801. })();
  802.  
  803. (function command() {
  804. diepStyle.command = {};
  805. renders.forEach((elem) => {
  806. diepStyle.command[elem.cmd] = {};
  807. if (elem.reverse) diepStyle.command[elem.cmd].reverse = true;
  808. });
  809. diepStyle.command.fn = function (cmd, value) {
  810. nowSetting.renders = nowSetting.renders.map((elem) => {
  811. if (elem.cmd == cmd) elem.value = value;
  812. return elem;
  813. });
  814. if (diepStyle.command[cmd].reverse) value = !value;
  815. input.set_convar("ren_" + cmd, value);
  816. };
  817. })();
  818.  
  819. function getBlankSetting() {
  820. return {
  821. version: 1.0,
  822. saveTH: 1,
  823. lock: false,
  824. colors,
  825. renders,
  826. };
  827. }
  828.  
  829. function getBlankSaveList() {
  830. var list = [];
  831. for (var i = 0; i < 6; i++) {
  832. list[i] = getBlankSetting();
  833. if (i == 0) list[i].isDefault = "default,no save";
  834. }
  835. return clone(list);
  836. }
  837. Storage.prototype.pluginSave = function () {
  838. saveList[nowSetting.saveTH] = clone(nowSetting);
  839. var _storageObj = {
  840. nowSetting: clone(nowSetting),
  841. saveList: clone(saveList),
  842. };
  843. localStorage.setObject("diepStyle", _storageObj);
  844. };
  845. localStorage.pluginSave();
  846. }
  847.  
  848. function keyListen() {
  849. var input = "";
  850. document.addEventListener("keyup", function (evt) {
  851. var that = this;
  852. if (that.pluginOn == undefined) that.pluginOn = false;
  853. var e = window.event || evt;
  854. var key = e.which || e.keyCode;
  855. input += key;
  856. if (input.indexOf("2727") >= 0) {
  857. input = "";
  858. that.pluginOn = !that.pluginOn;
  859. togglePanel(that.pluginOn);
  860. (function save() {
  861. if (!that.pluginOn) {
  862. localStorage.pluginSave();
  863. }
  864. })();
  865. }
  866. if (input.length > 10) input = input.substring(input.length - 10);
  867. });
  868. }
  869.  
  870. function tempInit() {
  871. var colorObj = {
  872. th: 0,
  873. };
  874. var setObj = {
  875. th: 0,
  876. };
  877.  
  878. diepStyle.exportJSON = exportJSON;
  879. diepStyle.importJSON = importJSON;
  880. init1();
  881. loadColor();
  882. setTimeout(diepStyle.resetRender, 1500);
  883. diepStyle.resetColor = loadColor;
  884.  
  885. function init1() {
  886. diepStyle.resetRender = resetRender;
  887.  
  888. var title = `<div class="title">TYLERS THEME MENU<br>
  889. Press Esc twice to toggle this</div>`;
  890.  
  891. var colorPlane = function (id) {
  892. return `{position:'left',width:300, height:200,onFineChange:'diepStyle.onColor(${id},this)'}`;
  893. };
  894.  
  895. colorObj.setClass = function () {
  896. return `colorBlock colorBlock${this.th++}`;
  897. };
  898. setObj.setClass = function () {
  899. return `setting setting${this.th++}`;
  900. };
  901.  
  902. function resetRender(cmd) {
  903. document
  904. .querySelectorAll("#styleSetting .render")
  905. .forEach(function (elem) {
  906. elem.outerHTML = ``;
  907. });
  908. var it = document.querySelector(".renderBegin");
  909. it.insertAdjacentHTML("afterend", getRenderBody());
  910. it.remove();
  911. nowSetting.renders.forEach(function (elem) {
  912. diepStyle.command.fn(elem.cmd, elem.value);
  913. });
  914. listenerInit(cmd);
  915. }
  916. var bodyTheme = getThemeBody();
  917. var bodyRender = getRenderBody();
  918. var bodyColor = getColorBody();
  919. var bodyImport = getImportBody();
  920.  
  921. function getThemeBody() {
  922. var th = 0;
  923. var html = `
  924. <div class="themeBody">
  925. <div class="themeBegin">Theme</div>
  926. <div class="header hide themeDesc">
  927. <span class="name"></span>
  928. <span class="author"></span>
  929. </div>
  930. <div class="theme">
  931. <div class="list">
  932. <div data-theme="dark"><img src="https://imgur.com/bFyXqs5.jpg"><br>Dark</div>
  933. <div data-theme="glass"><img src="https://imgur.com/4fnXdkE.jpg"><br>Glass</div>
  934. <div data-theme="moomoo"><img src="https://imgur.com/XJwGabH.jpg"><br>Moomoo</div>
  935. <div data-theme="80s"><img src="https://imgur.com/9Lma43A.jpg"><br>80s </div>
  936. </div>
  937. </div>
  938. </div>
  939. `;
  940. return html;
  941. }
  942.  
  943. function getRenderBody() {
  944. var renders = nowSetting.renders;
  945. var th = -1;
  946. var html = `
  947. <div class="renderBegin">Render</div>
  948.  
  949. <div class="row render">
  950. <div class="cell">${
  951. renders[++th].name
  952. } <br><span class="grid_base_value">${
  953. renders[th].value
  954. }</span></div>
  955. <div class="cell"><input type="range" name="grid_base_alpha" value=${
  956. renders[th].value * 100
  957. } max="200"></div>
  958. </div>
  959. <div class="row render">
  960. <div class="cell">${
  961. renders[++th].name
  962. } <br><span class="stroke_intensity_value">${
  963. renders[th].value
  964. }</span></div>
  965. <div class="cell"><input type="range" name="stroke_soft_color_intensity" value=${
  966. renders[th].value * 100
  967. } max="100"></div>
  968. </div>
  969. <div class="row render">
  970. <div class="cell">${renders[++th].name}</div>
  971. <div class="cell"><input type="checkbox" name="stroke_soft_color" ${
  972. renders[th].value ? "checked" : ""
  973. }></div>
  974. </div>
  975. <div class="row render">
  976. <div class="cell">${
  977. renders[++th].name
  978. } <br><span class="border_value">${
  979. renders[th].value
  980. }</span></div>
  981. <div class="cell"><input type="range" name="border_color_alpha" value=${
  982. renders[th].value * 100
  983. } max="100"></div>
  984. </div>
  985. <div class="row render">
  986. <div class="cell">${
  987. renders[++th].name
  988. } <br><span class="ui_scale_value">${
  989. renders[th].value
  990. }</span></div>
  991. <div class="cell"><input type="range" name="ui_scale" value=${
  992. renders[th].value * 100
  993. } max="200"></div>
  994. </div>
  995. <div class="row render">
  996. <div class="cell">${renders[++th].name}</div>
  997. <div class="cell"><input type="checkbox" name="ui" ${
  998. renders[th].value ? "checked" : ""
  999. }></div>
  1000. </div>
  1001. <div class="row render">
  1002. <div class="cell">${renders[++th].name}</div>
  1003. <div class="cell"><input type="checkbox" name="fps" ${
  1004. renders[th].value ? "checked" : ""
  1005. }></div>
  1006. </div>
  1007. <div class="row render">
  1008. <div class="cell">${renders[++th].name}</div>
  1009. <div class="cell"><input type="checkbox" name="raw_health_values" ${
  1010. renders[th].value ? "checked" : ""
  1011. }></div>
  1012. </div>
  1013. <div class="row render">
  1014. <div class="cell">${renders[++th].name}</div>
  1015. <div class="cell"><input type="checkbox" name="names" ${
  1016. renders[th].value ? "checked" : ""
  1017. }></div>
  1018. </div>
  1019. `;
  1020. return html;
  1021. }
  1022.  
  1023. function getColorBody() {
  1024. var it = `<div class="row colorBegin">Color</div>\n`;
  1025. nowSetting.colors.forEach(function (elem, th) {
  1026. var id = elem.id;
  1027. it += `
  1028. <div class="row colorBlock colorBlock${th}">
  1029. <div class="cell"></div>
  1030. <div class="cell"><input class="jscolor ${colorPlane(
  1031. `${id}`
  1032. )}"> </div>
  1033. </div>
  1034. `;
  1035. });
  1036. return it;
  1037. }
  1038.  
  1039. var allBody = `
  1040. <div class="pluginBody">${title}
  1041. <hr>
  1042. ${bodyTheme}
  1043. <div class="table">
  1044. ${bodyRender} ${bodyColor} <br>
  1045. </div>
  1046. </div>
  1047. `;
  1048. var getSaveBtns = function () {
  1049. var btn = "";
  1050. for (var i = 0; i < 6; i++) {
  1051. if (i == 0) {
  1052. btn += `<button>Default</button>`;
  1053. continue;
  1054. }
  1055. btn += `<button>${i}</button>`;
  1056. }
  1057. return btn;
  1058. };
  1059.  
  1060. function getImportBody() {
  1061. var html = `
  1062. <div class="importBegin">Import / Export Save</div>
  1063. <div class="row">
  1064. <div class="cell">
  1065. <button class="import">Import</button>
  1066. </div>
  1067. <div class="cell">
  1068. <button class="export">Export</button>
  1069. </div>
  1070. </div>
  1071. `;
  1072. return html;
  1073. }
  1074. var footer = `
  1075. <div class="footer">
  1076. <div class="saveBtns">${getSaveBtns()}</div>
  1077. <div class="otherBtns">
  1078. <span><button class="import">Import</button></span>
  1079. <span><button class="export">Export</button></span>
  1080. <span class="lock"><button>Lock</button></span>
  1081. <span class="reset"><button>Reset</button></span>
  1082. </div>
  1083. </div>
  1084. `;
  1085. var id = 0;
  1086. var temp = `<div id="styleSetting"> ${allBody} ${footer} </div>`;
  1087. document.querySelector("body").insertAdjacentHTML("afterend", temp);
  1088. addScript(jsColorPackage);
  1089.  
  1090. function listenerInit(cmd) {
  1091. (function () {
  1092. var theName = "grid_base_alpha";
  1093. document
  1094. .querySelector(`input[name=${theName}]`)
  1095. .addEventListener("input", function (e) {
  1096. var value = (e.target.value - (e.target.value % 2)) / 100;
  1097. document.querySelector(".grid_base_value").innerHTML = value;
  1098. diepStyle.command.fn(theName, value);
  1099. });
  1100. })();
  1101. (function () {
  1102. var theName = "stroke_soft_color_intensity";
  1103. document
  1104. .querySelector(`input[name=${theName}]`)
  1105. .addEventListener("input", function (e) {
  1106. var value = (e.target.value - (e.target.value % 5)) / 100;
  1107. document.querySelector(".stroke_intensity_value").innerHTML =
  1108. value;
  1109. diepStyle.command.fn(theName, value);
  1110. });
  1111. })();
  1112. (function () {
  1113. var theName = "stroke_soft_color";
  1114. document
  1115. .querySelector(`input[name=${theName}]`)
  1116. .addEventListener("change", function (e) {
  1117. diepStyle.command.fn(theName, e.target.checked);
  1118. });
  1119. })();
  1120. (function () {
  1121. var theName = "border_color_alpha";
  1122. document
  1123. .querySelector(`input[name=${theName}]`)
  1124. .addEventListener("input", function (e) {
  1125. var value = (e.target.value - (e.target.value % 2)) / 100;
  1126. document.querySelector(".border_value").innerHTML = value;
  1127. diepStyle.command.fn(theName, value);
  1128. });
  1129. })();
  1130. (function () {
  1131. var theName = "ui_scale";
  1132. document
  1133. .querySelector(`input[name=${theName}]`)
  1134. .addEventListener("input", function (e) {
  1135. var value = (e.target.value - (e.target.value % 2)) / 100;
  1136. document.querySelector(`.${theName}_value`).innerHTML = value;
  1137. diepStyle.command.fn(theName, value);
  1138. });
  1139. })();
  1140. (function () {
  1141. var theName = "ui";
  1142. document
  1143. .querySelector(`input[name=${theName}]`)
  1144. .addEventListener("change", function (e) {
  1145. diepStyle.command.fn(theName, e.target.checked);
  1146. });
  1147. })();
  1148. (function () {
  1149. var theName = "fps";
  1150. document
  1151. .querySelector(`input[name=${theName}]`)
  1152. .addEventListener("change", function (e) {
  1153. diepStyle.command.fn(theName, e.target.checked);
  1154. });
  1155. })();
  1156. (function () {
  1157. var theName = "raw_health_values";
  1158. document
  1159. .querySelector(`input[name=${theName}]`)
  1160. .addEventListener("change", function (e) {
  1161. diepStyle.command.fn(theName, e.target.checked);
  1162. });
  1163. })();
  1164. (function () {
  1165. var theName = "names";
  1166. document
  1167. .querySelector(`input[name=${theName}]`)
  1168. .addEventListener("change", function (e) {
  1169. diepStyle.command.fn(theName, e.target.checked);
  1170. });
  1171. })();
  1172. if (cmd == "reset") return;
  1173. (function () {
  1174. document
  1175. .querySelectorAll(`.theme div[data-theme]`)
  1176. .forEach((dom) => {
  1177. dom.addEventListener("click", () => {
  1178. const name = dom.getAttribute("data-theme");
  1179. const themes = diepStyle.themeJson;
  1180. diepStyle.importJSON(themes[name]);
  1181. });
  1182. });
  1183. })();
  1184. document
  1185. .querySelector("button.import")
  1186. .addEventListener("click", () => {
  1187. var example =
  1188. '[\n{"cmd":"ui_scale","value":"1.5"},' +
  1189. '\n{"id":"8","value":"888888"}\n]';
  1190. var gotValue = prompt(
  1191. "Enter The JSON\nExample:\n" + example,
  1192. example.replace(/\s/g, "")
  1193. );
  1194. diepStyle.importJSON(gotValue);
  1195. });
  1196. document
  1197. .querySelector("button.export")
  1198. .addEventListener("click", function (e) {
  1199. prompt("Copy the Json", diepStyle.exportJSON("one"));
  1200. });
  1201. document.querySelectorAll(".saveBtns button").forEach((elem, th) => {
  1202. elem.addEventListener("click", function () {
  1203. localStorage.pluginSave();
  1204. nowSetting = clone(saveList[th]);
  1205. nowSetting.saveTH = th;
  1206. diepStyle.resetColor();
  1207. diepStyle.resetRender("reset");
  1208. updateSaveBtns();
  1209. });
  1210. });
  1211. document
  1212. .querySelector(".lock button")
  1213. .addEventListener("click", function (e) {
  1214. nowSetting.lock = !nowSetting.lock;
  1215. updateSaveBtns();
  1216. });
  1217. document
  1218. .querySelector(".reset button")
  1219. .addEventListener("click", function (e) {
  1220. if (e.target.innerHTML != "Confirm") {
  1221. e.target.innerHTML = "Confirm";
  1222. } else {
  1223. diepStyle.storageInit("reset");
  1224. diepStyle.resetColor();
  1225. diepStyle.resetRender("reset");
  1226. updateSaveBtns();
  1227. }
  1228. });
  1229. document
  1230. .querySelector(".reset button")
  1231. .addEventListener("mouseleave", function (e) {
  1232. e.target.innerHTML = "Reset";
  1233. });
  1234. updateSaveBtns();
  1235.  
  1236. function updateSaveBtns() {
  1237. var theTH = nowSetting.saveTH;
  1238. var status = saveList[theTH];
  1239. var lockBtn = document.querySelector(".lock button");
  1240. var resetBtn = document.querySelector(".reset button");
  1241. if (theTH == 0) {
  1242. lockBtn.disabled = true;
  1243. resetBtn.disabled = true;
  1244. nowSetting.lock = true;
  1245. } else {
  1246. resetBtn.disabled = nowSetting.lock;
  1247. lockBtn.disabled = false;
  1248. }
  1249. if (resetBtn.disabled) {
  1250. document.querySelector(".table").classList.add("noClicks");
  1251. document.querySelector(".themeBody").classList.add("noClicks");
  1252. document.querySelector("button.import").classList.add("noClicks");
  1253. lockBtn.innerHTML = "locked";
  1254. } else {
  1255. document.querySelector(".table").classList.remove("noClicks");
  1256. document.querySelector(".themeBody").classList.remove("noClicks");
  1257. document
  1258. .querySelector("button.import")
  1259. .classList.remove("noClicks");
  1260. lockBtn.innerHTML = "no lock";
  1261. }
  1262. (function () {
  1263. document
  1264. .querySelectorAll(".saveBtns button")
  1265. .forEach(function (elem, th) {
  1266. elem.classList.remove("chosenBtn");
  1267. if (theTH == th) elem.classList.add("chosenBtn");
  1268. });
  1269. })();
  1270. }
  1271. }
  1272. }
  1273.  
  1274. function loadColor() {
  1275. if (nowSetting.theme) {
  1276. document.querySelector(".themeDesc").classList.remove("hide");
  1277. var it = document.querySelector(".themeDesc .name");
  1278. it.innerText = nowSetting.theme.name;
  1279. it = document.querySelector(".themeDesc .author");
  1280. it.innerText = "by\n " + nowSetting.theme.author;
  1281. } else {
  1282. document.querySelector(".themeDesc").classList.add("hide");
  1283. }
  1284.  
  1285. nowSetting.colors.some(function (elem, th) {
  1286. var target = document.querySelector(`.colorBlock${th}`);
  1287. if (!target || !target.querySelector(".cell input").jscolor) {
  1288. setTimeout(loadColor, 500);
  1289. return true;
  1290. }
  1291. onColor(elem.id, elem.color);
  1292. target.querySelector(".cell").innerHTML = elem.name;
  1293. target.querySelector(".cell input").jscolor.fromString(elem.color);
  1294. });
  1295. }
  1296.  
  1297. function exportJSON(cmd) {
  1298. var toExport = [];
  1299. if (cmd == "one") toExport = write(nowSetting);
  1300. if (cmd == "all")
  1301. saveList.forEach((elem) => toExport.push(write(elem)));
  1302. return JSON.stringify(toExport);
  1303.  
  1304. function write(now) {
  1305. var array = [];
  1306. now.colors.forEach(function (elem) {
  1307. if (elem.id && elem.id < 50)
  1308. array.push({
  1309. id: elem.id,
  1310. value: elem.color,
  1311. });
  1312. if (elem.id && elem.id >= 50 && elem.id < 100)
  1313. array.push({
  1314. cmd: elem.cmd,
  1315. value: elem.color,
  1316. });
  1317. if (!elem.id && elem.cmd)
  1318. array.push({
  1319. cmd: elem.cmd,
  1320. value: elem.color,
  1321. });
  1322. });
  1323. array.push({
  1324. cmd: "ui_replace_colors",
  1325. value: diepStyle.uiColorMap("array"),
  1326. });
  1327. now.renders.forEach(function (elem) {
  1328. array.push({
  1329. cmd: elem.cmd,
  1330. value: elem.value,
  1331. });
  1332. });
  1333. if (now.theme) {
  1334. array.unshift({
  1335. theme: {
  1336. name: now.theme.name || "",
  1337. author: now.theme.author || "",
  1338. },
  1339. });
  1340. } else {
  1341. array.unshift({
  1342. theme: {
  1343. name: "",
  1344. author: "",
  1345. },
  1346. });
  1347. }
  1348. return array;
  1349. }
  1350. }
  1351.  
  1352. function importJSON(json) {
  1353. if (!isJson(json)) {
  1354. alert("Code Incorrect\nPlz git gud and check your JSON");
  1355. return;
  1356. }
  1357. var gotArr = JSON.parse(json);
  1358. if (!gotArr) return;
  1359. gotArr.forEach(function (elem) {
  1360. nowSetting.colors = nowSetting.colors.map(function (now) {
  1361. if (elem.id && now.id == elem.id) now.color = elem.value;
  1362. if (!elem.id && elem.cmd && now.cmd == elem.cmd)
  1363. now.color = elem.value;
  1364. return now;
  1365. });
  1366. nowSetting.renders = nowSetting.renders.map(function (now) {
  1367. if (elem.cmd && now.cmd == elem.cmd) now.value = elem.value;
  1368. return now;
  1369. });
  1370. if (elem.cmd == "ui_replace_colors") {
  1371. var uiTH = nowSetting.colors.findIndex(
  1372. (elem) => elem.name == "UI Color1"
  1373. );
  1374. for (var i = 0; i < 8; i++) {
  1375. nowSetting.colors[uiTH + i].color = elem.value[i];
  1376. }
  1377. }
  1378. if (elem.theme) {
  1379. if (elem.theme.name || elem.theme.author)
  1380. nowSetting.theme = elem.theme;
  1381. } else {
  1382. elem.theme = {};
  1383. }
  1384. });
  1385. document
  1386. .querySelectorAll(".saveBtns button")
  1387. [nowSetting.saveTH].click();
  1388.  
  1389. function isJson(str) {
  1390. try {
  1391. JSON.parse(str);
  1392. } catch (e) {
  1393. return false;
  1394. }
  1395. if (typeof JSON.parse(str) == "object") return true;
  1396. }
  1397. }
  1398. }
  1399.  
  1400. function onColor(id, e) {
  1401. var target = id;
  1402. var color = e.toString();
  1403. if (id >= 0 && id < 50) {
  1404. input.execute(`net_replace_color ${target} 0x${color}`);
  1405. } else if (id >= 50 && id < 100) {
  1406. var cmd = diepStyle.colorMap.get(id).cmd;
  1407. input.set_convar(cmd, `0x${color}`);
  1408. } else {
  1409. input.execute("ui_replace_colors" + diepStyle.uiColorMap("0x"));
  1410. }
  1411. nowSetting.colors = nowSetting.colors.map(function (elem) {
  1412. if (elem.id === id) elem.color = color;
  1413. return elem;
  1414. });
  1415. }
  1416.  
  1417. function styleInit() {
  1418. addGlobalStyle(`#styleSetting{padding: 0.2em; margin:0.2em; position: absolute;top: 0;right: 0;width: 35%;
  1419. min-width:20em; background-color: rgba(200,200,200,0.8);display:none;border: 1px solid black;height: 85vh;}`);
  1420. addGlobalStyle(
  1421. ".table{ display: table; text-align: center; width: 99%;}"
  1422. );
  1423. addGlobalStyle(".row{ display: table-row; }");
  1424. addGlobalStyle(`.cell{ display: table-cell;}`);
  1425. addGlobalStyle(
  1426. `.cell:not(.noBoard){ display: table-cell; padding: 0.1em 0.3em;border: 1px solid black;}`
  1427. );
  1428. addGlobalStyle(
  1429. "input[type=checkbox],input[type=range]{transform: scale(1.2); }"
  1430. );
  1431. addGlobalStyle(`.pluginBody{height: 90%; overflow-y: auto;}`);
  1432. addGlobalStyle(
  1433. `.theme .list div{width: 48%; float: left; text-align: center; padding: 1%;}`
  1434. );
  1435. addGlobalStyle(`.theme img {width: 90%;}`);
  1436. addGlobalStyle(
  1437. `.colorBegin, .renderBegin, .importBegin,.themeBegin,.header{font-size:1.1rem; line-height:1.3em;text-align: center;}`
  1438. );
  1439. addGlobalStyle(`.saveBtns button{margin: 0 3%; padding: 0.2em 0.5em;}`);
  1440. addGlobalStyle(
  1441. `@-moz-document url-prefix() {.saveBtns button{margin: 0 1%;padding: 0.1em 0.3em;} } }`
  1442. );
  1443. addGlobalStyle(`.otherBtns button{margin: 0 4%; padding: 0.2em 0.5em;}`);
  1444. addGlobalStyle(
  1445. `.footer{text-align:center;height:10%; border: 1px solid black;}`
  1446. );
  1447. addGlobalStyle(`.footer > *{margin: 0.2vh 0 1.3vh 0;}`);
  1448.  
  1449. addGlobalStyle(`.reset button{box-shadow: 0 0 1em red;}`);
  1450. addGlobalStyle(`.backRed{background-color:#f14e54}`);
  1451. addGlobalStyle(
  1452. `.chosenBtn{-webkit-filter: brightness(0.8);filter:brightness(0.8);}`
  1453. );
  1454. addGlobalStyle(
  1455. `.noClicks{pointer-events:none; -webkit-filter: opacity(50%); filter: opacity(50%);}`
  1456. );
  1457. addGlobalStyle(`.hide{display:none}`);
  1458.  
  1459. function addGlobalStyle(css) {
  1460. var head, style;
  1461. head = document.getElementsByTagName("head")[0];
  1462. if (!head) {
  1463. return;
  1464. }
  1465. style = document.createElement("style");
  1466. style.type = "text/css";
  1467. style.innerHTML = css;
  1468. head.appendChild(style);
  1469. }
  1470. }
  1471. }
  1472.  
  1473. function togglePanel(tf) {
  1474. if (tf) {
  1475. try {
  1476. document.querySelector("#styleSetting").style.display = "block";
  1477. } catch (err) {
  1478. var warn =
  1479. "\n\nYou can DELETE ALL PLUGIN SAVES to fix this" +
  1480. "\nType delete to confirm" +
  1481. "\nor cancel to download all saves";
  1482. var gotValue = prompt("Got an error\n" + err + warn);
  1483. if (gotValue == "delete") {
  1484. localStorage.removeItem("diepStyle");
  1485. alert("Deleted,refresh to take effect");
  1486. return;
  1487. } else {
  1488. download("diep.style saves.txt", diepStyle.exportJSON("all"));
  1489. }
  1490. }
  1491. } else {
  1492. document.querySelector("#styleSetting").style.display = "none";
  1493. }
  1494. function download(filename, text) {
  1495. var element = document.createElement("a");
  1496. element.setAttribute(
  1497. "href",
  1498. "data:text/plain;charset=utf-8," + encodeURIComponent(text)
  1499. );
  1500. element.setAttribute("download", filename);
  1501. element.style.display = "none";
  1502. document.body.appendChild(element);
  1503. element.click();
  1504. document.body.removeChild(element);
  1505. }
  1506. }
  1507.  
  1508. (function loadThemes() {
  1509. diepStyle.themeJson = {
  1510. dark: `[{"theme":{"name":"Dark Mode","author":"/u/162893476"}} ,{"id":2,"value":"001117"},{"id":15,"value":"140000"},{"id":3,"value":"005574"},{"id":4,"value":"540000"},{"id":5,"value":"090413"},{"id":6,"value":"00121a"},{"id":17,"value":"0D0D0D"},{"id":12,"value":"0D0D0D"},{"id":8,"value":"141400"},{"id":7,"value":"0d1500"},{"id":9,"value":"170606"},{"id":10,"value":"0a0016"},{"id":11,"value":"160517"},{"id":14,"value":"141414"},{"id":1,"value":"0f0f0f"},{"cmd":"ren_bar_background_color","value":"000000"},{"cmd":"ren_stroke_solid_color","value":"555555"},{"id":13,"value":"00bd88"},{"cmd":"ren_xp_bar_fill_color","value":"ffde43"},{"cmd":"ren_score_bar_fill_color","value":"43ff91"},{"cmd":"ren_health_fill_color","value":"85e37d"},{"cmd":"ren_health_background_color","value":"555555"},{"cmd":"ren_grid_color","value":"111111"},{"cmd":"ren_minimap_background_color","value":"323232"},{"cmd":"ren_minimap_border_color","value":"986895"},{"cmd":"ren_background_color","value":"000000"},{"cmd":"ren_border_color","value":"0f0f0f"},{"cmd":"ui_replace_colors","value":["ffe280","ff31a0","882dff","2d5aff","ffde26","ff2626","95ff26","17d2ff"]},{"cmd":"grid_base_alpha","value":2},{"cmd":"stroke_soft_color_intensity","value":-10},{"cmd":"stroke_soft_color","value":false},{"cmd":"border_color_alpha","value":0.5},{"cmd":"ui_scale","value":1},{"cmd":"ui","value":false},{"cmd":"fps","value":false},{"cmd":"raw_health_values","value":false},{"cmd":"names","value":false}] `,
  1511. glass: `[{"theme":{"name":"Glass","author":"/u/162893476"}}, {"id":2,"value":"00627D"},{"id":15,"value":"7E0000"},{"id":3,"value":"00627D"},{"id":4,"value":"7E0000"},{"id":5,"value":"3D007E"},{"id":6,"value":"007E00"},{"id":17,"value":"464646"},{"id":12,"value":"7E7E00"},{"id":8,"value":"7E7E00"},{"id":7,"value":"457E00"},{"id":16,"value":"795C00"},{"id":9,"value":"7C0320"},{"id":10,"value":"43397d"},{"id":11,"value":"7E037A"},{"id":14,"value":"252525"},{"id":1,"value":"464646"},{"cmd":"ren_bar_background_color","value":"191919"},{"cmd":"ren_stroke_solid_color","value":"555555"},{"id":13,"value":"008B54"},{"cmd":"ren_xp_bar_fill_color","value":"666600"},{"cmd":"ren_score_bar_fill_color","value":"008B54"},{"cmd":"ren_health_fill_color","value":"85e37d"},{"cmd":"ren_health_background_color","value":"555555"},{"cmd":"ren_grid_color","value":"373737"},{"cmd":"ren_minimap_background_color","value":"464646"},{"cmd":"ren_minimap_border_color","value":"676767"},{"cmd":"ren_background_color","value":"000000"},{"cmd":"ren_border_color","value":"454545"},{"cmd":"ui_replace_colors","value":["e69f6c","ff73ff","c980ff","71b4ff","ffed3f","ff7979","88ff41","41ffff"]},{"cmd":"grid_base_alpha","value":2},{"cmd":"stroke_soft_color_intensity","value":-9},{"cmd":"stroke_soft_color","value":false},{"cmd":"border_color_alpha","value":0.5},{"cmd":"ui_scale","value":1},{"cmd":"ui","value":false},{"cmd":"fps","value":false},{"cmd":"raw_health_values","value":false},{"cmd":"names","value":false}] `,
  1512. moomoo: `[{"theme":{"name":"Moomoo","author":"yst6zJTuKCHQvAXW4IPV"}}, {"id":2,"value":"847377"},{"id":15,"value":"7F4B63"},{"id":3,"value":"475F9E"},{"id":4,"value":"844052"},{"id":5,"value":"A330B1"},{"id":6,"value":"A66E4F"},{"id":17,"value":"6D6B84"},{"id":12,"value":"596B4A"},{"id":8,"value":"5b6b4d"},{"id":7,"value":"928150"},{"id":16,"value":"596B4A"},{"id":9,"value":"8c4256"},{"id":10,"value":"63647e"},{"id":11,"value":"5A5B72"},{"id":14,"value":"837752"},{"id":1,"value":"535377"},{"cmd":"ren_bar_background_color","value":"586B44"},{"cmd":"ren_stroke_solid_color","value":"35354E"},{"id":13,"value":"64ff8c"},{"cmd":"ren_xp_bar_fill_color","value":"FFFFFF"},{"cmd":"ren_score_bar_fill_color","value":"586B44"},{"cmd":"ren_health_fill_color","value":"8ECC51"},{"cmd":"ren_health_background_color","value":"3D3F42"},{"cmd":"ren_grid_color","value":"000000"},{"cmd":"ren_minimap_background_color","value":"586B44"},{"cmd":"ren_minimap_border_color","value":"586B44"},{"cmd":"ren_background_color","value":"768F5B"},{"cmd":"ren_border_color","value":"333333"},{"cmd":"ui_replace_colors","value":["5d4322","825d30","a8783e","bf8f54","c89e6a","d6b68f","e3ceb5","f1e7da"]},{"cmd":"grid_base_alpha","value":0.1},{"cmd":"stroke_soft_color_intensity","value":0.25},{"cmd":"stroke_soft_color","value":false},{"cmd":"border_color_alpha","value":0.1},{"cmd":"ui_scale","value":1},{"cmd":"ui","value":false},{"cmd":"fps","value":false},{"cmd":"raw_health_values","value":false},{"cmd":"names","value":false}]`,
  1513. "80s": `[{"theme":{"name":"80s Light","author":"Road-to-100k"}}, {"id":2,"value":"00efff"},{"id":15,"value":"ff00ff"},{"id":3,"value":"00efff"},{"id":4,"value":"ff00ff"},{"id":5,"value":"ffaa00"},{"id":6,"value":"4FFFB0"},{"id":17,"value":"c6c6c6"},{"id":12,"value":"ffe869"},{"id":8,"value":"FFD800"},{"id":7,"value":"89ff69"},{"id":16,"value":"fcc376"},{"id":9,"value":"FF004F"},{"id":10,"value":"0000CD"},{"id":11,"value":"ffffff"},{"id":14,"value":"43197e"},{"id":1,"value":"999999"},{"cmd":"ren_bar_background_color","value":"1e0b38"},{"cmd":"ren_stroke_solid_color","value":"555555"},{"id":13,"value":"64ff8c"},{"cmd":"ren_xp_bar_fill_color","value":"ffde43"},{"cmd":"ren_score_bar_fill_color","value":"43ff91"},{"cmd":"ren_health_fill_color","value":"85e37d"},{"cmd":"ren_health_background_color","value":"555555"},{"cmd":"ren_grid_color","value":"ff00ff"},{"cmd":"ren_minimap_background_color","value":"CDCDCD"},{"cmd":"ren_minimap_border_color","value":"797979"},{"cmd":"ren_background_color","value":"1e0b38"},{"cmd":"ren_border_color","value":"000000"},{"cmd":"ui_replace_colors","value":["e69f6c","ff73ff","c980ff","71b4ff","ffed3f","ff7979","88ff41","41ffff"]},{"cmd":"grid_base_alpha","value":1.1},{"cmd":"stroke_soft_color_intensity","value":0.3},{"cmd":"stroke_soft_color","value":false},{"cmd":"border_color_alpha","value":0.6},{"cmd":"ui_scale","value":1},{"cmd":"ui","value":false},{"cmd":"fps","value":false},{"cmd":"raw_health_values","value":false},{"cmd":"names","value":false}] `,
  1514. };
  1515. })();
  1516. function addScript(src) {
  1517. var s = document.createElement("script");
  1518. s.setAttribute("src", src);
  1519. document.body.appendChild(s);
  1520. }
  1521. })();
  1522.  
  1523.  
  1524.  
  1525. setTimeout (function() {
  1526. function hook(target, callback){
  1527. const check = () => {
  1528. window.requestAnimationFrame(check)
  1529. const func = CanvasRenderingContext2D.prototype[target]
  1530.  
  1531. if(func.toString().includes(target)){
  1532.  
  1533. CanvasRenderingContext2D.prototype[target] = new Proxy (func, {
  1534. apply (method, thisArg, args) {
  1535. callback(thisArg, args)
  1536.  
  1537. return Reflect.apply (method, thisArg, args)
  1538. }
  1539. });
  1540. }
  1541. }
  1542. check()
  1543. }
  1544. const canvas = document.getElementById('canvas');
  1545. const ctx = canvas.getContext('2d');
  1546. let distance = [0, 0];
  1547. let isActive = false;
  1548. let storedPos = [0, 0];
  1549. let arrowPos = [0, 0];
  1550. let minimapPos = [0, 0];
  1551. let minimapDim = [0, 0];
  1552. let worldPosition = [0, 0];
  1553.  
  1554. let teamSnapshot = false;
  1555. let team = '#f14e54';
  1556. function hookMinimapArrow() {
  1557. let drawInstructions = 0;
  1558. let vertices = new Array(0);
  1559.  
  1560. hook('beginPath', function(context, args) {
  1561. drawInstructions = 1;
  1562. vertices = new Array(0);
  1563. });
  1564. hook('moveTo', function(context, args) {
  1565. drawInstructions = 2;
  1566. vertices.push(args);
  1567. });
  1568. hook('lineTo', function(context, args) {
  1569. if (drawInstructions >= 2 && drawInstructions <= 5) {
  1570. drawInstructions++;
  1571. vertices.push(args);
  1572. return;
  1573. }
  1574. drawInstructions = 0;
  1575. });
  1576. hook('fill', function(context, args) {
  1577. if (context.globalAlpha != 1 || context.fillStyle != '#000000') {
  1578. return;
  1579. }
  1580. if (drawInstructions === 4) {
  1581. const pos = getAverage (vertices);
  1582. arrowPos = pos;
  1583. }
  1584. });
  1585. }
  1586. function hookMinimap() {
  1587. hook('strokeRect', function(context, args) {
  1588. const t = context.getTransform();
  1589. minimapPos = [t.e, t.f];
  1590. minimapDim = [t.a, t.d];
  1591. });
  1592. hook('rect', function(context, args) {
  1593. const c = context.fillStyle;
  1594. if (teamSnapshot) {
  1595. if (c == '#f14e54') {
  1596. team = c;
  1597. }
  1598. if (c == '#00b2e1') {
  1599. team = c;
  1600. }
  1601. if (c == '#bf7ff5') {
  1602. team = c;
  1603. }
  1604. if (c == '#00e16e') {
  1605. team = c;
  1606. }
  1607. }
  1608. });
  1609. }
  1610. hookMinimap();
  1611. hookMinimapArrow();
  1612. function getAverage(points) {
  1613. let ret = [0, 0];
  1614. points.forEach (point => {
  1615. ret[0] += point[0];
  1616. ret[1] += point[1];
  1617. });
  1618. ret[0] /= points.length;
  1619. ret[1] /= points.length;
  1620. return ret;
  1621. }
  1622. function getWorldPos () {
  1623. const ret = [
  1624. parseFloat((((arrowPos[0] - minimapPos[0] - minimapDim[0] / 2) / minimapDim[0] * 100) * 460).toFixed (3)),
  1625. parseFloat((((arrowPos[1] - minimapPos[1] - minimapDim[1] / 2) / minimapDim[1] * 100) * 460).toFixed (3)),
  1626. ]
  1627. return ret;
  1628. }
  1629. let lineWidth = 0;
  1630. let cameraZoom = 0;
  1631. CanvasRenderingContext2D.prototype.stroke = new Proxy(CanvasRenderingContext2D.prototype.stroke, {
  1632. apply(method, self, args) {
  1633. lineWidth = self.lineWidth;
  1634. return Reflect.apply(method, self, args);
  1635. }
  1636. });
  1637. CanvasRenderingContext2D.prototype.createPattern = new Proxy(CanvasRenderingContext2D.prototype.createPattern, {
  1638. apply(method, self, args) {
  1639. cameraZoom = 1 / lineWidth;
  1640. return Reflect.apply(method, self, args);
  1641. }
  1642. });
  1643. input.try_spawn = new Proxy(input.try_spawn, {
  1644. apply(method, self, args) {
  1645. teamSnapshot = true;
  1646. setTimeout(function() {
  1647. teamSnapshot = false;
  1648. console.log (team)
  1649. },1000);
  1650. return Reflect.apply(method, self, args);
  1651. }
  1652. });
  1653. function tick() {
  1654. window.requestAnimationFrame(tick);
  1655. worldPosition = getWorldPos();
  1656. distance = getDist(
  1657. worldPosition,
  1658. storedPos,
  1659. )
  1660. if (isActive) {
  1661. move();
  1662. }
  1663. drawAfkPos();
  1664. }
  1665. tick();
  1666. function toGrid(dist) {
  1667. return [
  1668. dist[0] / ((1 - cameraZoom) * 8),
  1669. dist[1] / ((1 - cameraZoom) * 8),
  1670. dist[2] / ((1 - cameraZoom) * 8),
  1671. ]
  1672. }
  1673. function drawAfkPos() {
  1674. const width = canvas.width;
  1675. const height = canvas.height;
  1676.  
  1677. const grid = toGrid(distance);
  1678. const size = 50;
  1679. let toDraw = [
  1680. width / 2 - grid[1],
  1681. height / 2 - grid[2],
  1682. ]
  1683. ctx.beginPath();
  1684. ctx.globalAlpha = 0.5;
  1685. ctx.fillStyle = team
  1686. ctx.arc(...toDraw, size, 0, Math.PI * 2, false);
  1687. ctx.fill();
  1688. ctx.stroke();
  1689. ctx.globalAlpha = 1;
  1690.  
  1691. ctx.beginPath();
  1692. ctx.lineWidth = 4;
  1693. ctx.font = "23px bold arial"
  1694. ctx.fillStyle = 'white';
  1695. ctx.strokeStyle = 'black';
  1696. if (isActive) {
  1697. ctx.strokeText('[J] Locked', toDraw[0] - 50, toDraw[1] + 25);
  1698. ctx.fillText('[J] Locked', toDraw[0] - 50, toDraw[1] + 25);
  1699. } else {
  1700. ctx.strokeText('[J] Unlocked', toDraw[0] - 50, toDraw[1] + 25);
  1701. ctx.fillText('[J] Unlocked', toDraw[0] - 50, toDraw[1] + 25);
  1702. }
  1703.  
  1704. }
  1705. document.addEventListener('keydown', e => {
  1706. if(e.key === 'j') {
  1707. isActive = !isActive;
  1708. input.key_up (83);
  1709. input.key_up (87);
  1710. input.key_up (68);
  1711. input.key_up (65);
  1712. }
  1713. if(e.key === 'f') {
  1714. storedPos = worldPosition;
  1715. }
  1716. });
  1717. function getDist(t1, t2) {
  1718. const distX = t1[0] - t2[0];
  1719. const distY = t1[1] - t2[1];
  1720. return [Math.hypot(distX, distY), distX, distY];
  1721. };
  1722. function move() {
  1723. if (distance[1] < 0.1) {
  1724. input.key_up (65);
  1725. input.key_down (68);
  1726. } else if (distance[1] > -0.1) {
  1727. input.key_up (68);
  1728. input.key_down (65);
  1729. } else {
  1730. input.key_up (68);
  1731. input.key_up (65);
  1732. }
  1733.  
  1734. if (distance[2] < 0.1) {
  1735. input.key_up (87);
  1736. input.key_down (83);
  1737. } else if (distance[2] > 0.1) {
  1738. input.key_up (83);
  1739. input.key_down (87);
  1740. } else {
  1741. input.key_up (83);
  1742. input.key_up (87);
  1743. }
  1744. }
  1745. },2500);
  1746. (function() {
  1747. 'use strict';
  1748. setInterval(() => {
  1749. let screen = window.ui.screen;
  1750. if (screen === "stats") return;
  1751. else window.input.grantReward();
  1752. }, 250);
  1753. })();
  1754.  
  1755. (function() {
  1756. 'use strict';
  1757.  
  1758. document.addEventListener('keydown', function(event) {
  1759. if (event.key === 'x' || event.key === 'X') {
  1760. const input = document.querySelector('input');
  1761. if (input) {
  1762. input.dispatchEvent(new Event('keydown', { key: 'ArrowLeft', keyCode: 37 }));
  1763. input.dispatchEvent(new Event('keyup', { key: 'ArrowLeft', keyCode: 37 }));
  1764. }
  1765. }
  1766. });
  1767. })();