DIEP TYLERS UTILITY V2

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

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

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