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