DIEP TYLERS UTILITY

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