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