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