diep_Shortcut

try to take over the world!

当前为 2022-12-20 提交的版本,查看 最新版本

此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.cn-greasyfork.org/scripts/456843/1130312/diep_Shortcut.js

  1. // ==UserScript==
  2. // @name diep_Shortcut
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description try to take over the world!
  6. // @author tariteur
  7. // @match https://diep.io/
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=diep.io
  9. // @grant none
  10. // ==/UserScript==
  11. (() => {
  12. const { backgroundOverlay, overlay } = window.diepAPI.tools;
  13. const { Vector } = window.diepAPI.core;
  14. const { scaling, player, game, minimap, arena } = window.diepAPI.apis;
  15. const ctx2 = backgroundOverlay.ctx;
  16. const ctx = overlay.ctx;
  17. const _window = 'undefined' == typeof unsafeWindow ? window : unsafeWindow;
  18. if (_window.diep_Shortcut) return;
  19.  
  20. //diepAPI start
  21. var diep_Shortcut;
  22. /******/ (() => {
  23. // webpackBootstrap
  24. /******/ 'use strict';
  25. /******/ // The require scope
  26. /******/ var __webpack_require__ = {};
  27. /******/
  28. /************************************************************************/
  29. /******/ /* webpack/runtime/define property getters */
  30. /******/ (() => {
  31. /******/ // define getter functions for harmony exports
  32. /******/ __webpack_require__.d = (exports, definition) => {
  33. /******/ for (var key in definition) {
  34. /******/ if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  35. /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  36. /******/
  37. }
  38. /******/
  39. }
  40. /******/
  41. };
  42. /******/
  43. })();
  44. /******/
  45. /******/ /* webpack/runtime/hasOwnProperty shorthand */
  46. /******/ (() => {
  47. /******/ __webpack_require__.o = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
  48. /******/
  49. })();
  50. /******/
  51. /******/ /* webpack/runtime/make namespace object */
  52. /******/ (() => {
  53. /******/ // define __esModule on exports
  54. /******/ __webpack_require__.r = (exports) => {
  55. /******/ if (typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  56. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  57. /******/
  58. }
  59. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  60. /******/
  61. };
  62. /******/
  63. })();
  64. /******/
  65. /************************************************************************/
  66. var __webpack_exports__ = {};
  67. // ESM COMPAT FLAG
  68. __webpack_require__.r(__webpack_exports__);
  69.  
  70. // EXPORTS
  71. __webpack_require__.d(__webpack_exports__, {
  72. core: () => /* reexport */ core_namespaceObject,
  73. });
  74.  
  75. // NAMESPACE OBJECT: ./src/core/index.ts
  76. var core_namespaceObject = {};
  77. __webpack_require__.r(core_namespaceObject);
  78. __webpack_require__.d(core_namespaceObject, {
  79. Canvas: () => Canvas,
  80. });
  81. function toMinimapPosition(vector) {
  82. var unscale = arena.unscale(vector);
  83. var minimapPos = Vector.multiply(minimap.minimapDim, unscale);
  84. return Vector.add(minimap.minimapPos, minimapPos);
  85. }
  86. const textShadow = 'text-shadow:black 0.18vh 0, black -0.18vh 0, black 0 -0.18vh, black 0 0.18vh, black 0.18vh 0.18vh, black -0.18vh 0.18vh, black 0.18vh -0.18vh, black -0.18vh -0.18vh, black 0.09vh 0.18vh, black -0.09vh 0.18vh, black 0.09vh -0.18vh, black -0.09vh -0.18vh, black 0.18vh 0.09vh, black -0.18vh 0.09vh, black 0.18vh -0.09vh, black -0.18vh -0.09vh'
  87. class CANVAS {
  88. GUI_create(id, Class, text, x, y,width, height, color, callback) {
  89. // Créer l'élément de l'interface graphique
  90. const guiElement = document.createElement('button');
  91. guiElement.id = id;
  92. guiElement.classList.add(Class);
  93. guiElement.innerHTML = text;
  94. guiElement.style.top = x;
  95. guiElement.style.left = y;
  96. guiElement.style.backgroundColor = color;
  97. guiElement.style.textShadow = textShadow;
  98. guiElement.style.position = 'absolute';
  99. guiElement.style.width = width+"vw";
  100. guiElement.style.height = height+"vh";
  101. // Appliquer les styles supplémentaires
  102. guiElement.style.borderRadius = '0.5vw';
  103. guiElement.style.fontFamily = 'Ubuntu';
  104. guiElement.style.opacity = '60%';
  105. guiElement.style.color = '#FFFFFF';
  106. guiElement.style.fontStyle = 'normal';
  107. guiElement.style.fontSize = '0.9vw';
  108.  
  109. guiElement.addEventListener('mouseover', function() {
  110. guiElement.style.opacity = '100%'
  111. });
  112. guiElement.addEventListener('mouseout', function() {
  113. guiElement.style.opacity = '60%'
  114. });
  115.  
  116. guiElement.addEventListener('click', callback);
  117. // Append the GUI element to the body of the document
  118. document.body.appendChild(guiElement);
  119. }
  120. GUI_changeName(id, text) {
  121. const element = document.getElementById(id);
  122. element.innerHTML = text;
  123. }
  124. GUI_hide_or_showID(id, truefalse) {
  125. const element = document.getElementById(id);
  126. if (truefalse == undefined) {
  127. if (element.style.display === 'none') {
  128. element.style.display = 'block';
  129. } else {
  130. element.style.display = 'none';
  131. }
  132. } else if (truefalse == true) {
  133. element.style.display = 'block';
  134. } else if (truefalse == false) {
  135. element.style.display = 'none';
  136. }
  137. }
  138. GUI_hide_or_showClass(Class, truefalse) {
  139. const elements = document.querySelectorAll(Class);
  140. for (const element of elements) {
  141. if (truefalse == undefined) {
  142. if (element.style.display === 'none') {
  143. element.style.display = 'block';
  144. } else {
  145. element.style.display = 'none';
  146. }
  147. } else if (truefalse == true) {
  148. element.style.display = 'block';
  149. } else if (truefalse == false) {
  150. element.style.display = 'none';
  151. }
  152. }
  153. }
  154. GUI_delete(id) {
  155. const element = document.getElementById(id);
  156. if (element) {
  157. element.parentNode.removeChild(element);
  158. }
  159. }
  160. drawText(Scaling, ctx , x, y, text, color, size, visibility, StrokeStyle, strokeStyleColor) {
  161. if (Scaling == "map") {
  162. const Pos = scaling.toCanvasPos(new Vector(x, y));
  163. x = Pos.x;
  164. y = Pos.y;
  165. const radius = scaling.toCanvasPos(new Vector(0, size+y)).y - Pos.y
  166. size = radius;
  167. } else if (Scaling == "minimap") {
  168. const Pos = toMinimapPosition(new Vector(x, y));
  169. x = Pos.x;
  170. y = Pos.y;
  171. }
  172. ctx.save();
  173. ctx.textAlign = "center"
  174. ctx.font = `${size}px Ubuntu`;
  175. ctx.fillStyle = color;
  176. ctx.globalAlpha = visibility;
  177. ctx.fillText(text, x, y)
  178. if (StrokeStyle) {
  179. ctx.strokeStyle = strokeStyleColor;
  180. ctx.strokeText(text, x, y);
  181. }
  182. ctx.restore();
  183. }
  184. drawLine(Scaling, ctx, x1, y1, x2, y2, color, visibility) {
  185. if (Scaling == "map") {
  186. const Pos1 = scaling.toCanvasPos(new Vector(x1, y1));
  187. const Pos2 = scaling.toCanvasPos(new Vector(x2, y2));
  188. x1 = Pos1.x;
  189. y1 = Pos1.y;
  190. x1 = Pos2.x;
  191. y2 = Pos2.y;
  192. } else if (Scaling == "minimap") {
  193. const Pos1 = toMinimapPosition(new Vector(x1, y1));
  194. const Pos2 = toMinimapPosition(new Vector(x2, y2));
  195. x1 = Pos1.x;
  196. y1 = Pos1.y;
  197. x1 = Pos2.x;
  198. y2 = Pos2.y;
  199. }
  200. ctx.save();
  201. ctx.fillStyle = color;
  202. ctx.globalAlpha = visibility;
  203. ctx.beginPath();
  204. ctx.moveTo(x1, y1);
  205. ctx.lineTo(x2, y2);
  206. ctx.stroke();
  207. ctx.restore();
  208. }
  209.  
  210. drawPoint(Scaling, ctx, x, y, size, color, visibility, StrokeStyle, strokeStyleColor, strokeStyleSize) {
  211. if (Scaling == "map") {
  212. const Pos = scaling.toCanvasPos(new Vector(x, y));
  213. x = Pos.x;
  214. y = Pos.y;
  215. const radius = scaling.toCanvasPos(new Vector(0, size+y)).y - Pos.y
  216. size = radius;
  217. } else if (Scaling == "minimap") {
  218. const Pos = toMinimapPosition(new Vector(x, y));
  219. x = Pos.x;
  220. y = Pos.y;
  221. const radius = toMinimapPosition(new Vector(0, size+y)).y - Pos.y
  222. size = radius;
  223. }
  224. ctx.save();
  225. ctx.fillStyle = color;
  226. ctx.globalAlpha = visibility;
  227. ctx.beginPath();
  228. ctx.arc(x, y, size, 0, 2 * Math.PI);
  229. ctx.fill();
  230. if (StrokeStyle) {
  231. ctx.lineWidth = strokeStyleSize;
  232. ctx.strokeStyle = strokeStyleColor;
  233. ctx.stroke();
  234. }
  235. ctx.restore();
  236. }
  237. drawSquar(scaling, ctx, x1, y1, x2, y2, size, color, visibility, StrokeStyle, strokeStyleColor, strokeStyleSize) {
  238. if (scaling == "map") {
  239. //mapPos = "scaling.toCanvasPos" or "toMinimapPosition"
  240. const Pos1 = scaling(new Vector(x1+size, y1+size));
  241. const Pos2 = scaling(new Vector(x2+size, y2+size));
  242. x1 = Pos1.x;
  243. y1= Pos1.y;
  244. x2 = Pos2.x;
  245. y2= Pos2.y;
  246. } else if (scaling == "minimap") {
  247. } else if (scaling == "screen") {
  248. }
  249. ctx.save();
  250. ctx.fillStyle = color;
  251. ctx.globalAlpha = visibility;
  252. ctx.fillRect(x1, y1, x2 - x1, y2 - y1);
  253. if (StrokeStyle) {
  254. ctx.lineWidth = strokeStyleSize;
  255. ctx.strokeStyle = strokeStyleColor;
  256. ctx.stroke();
  257. }
  258. ctx.restore();
  259. }
  260. }
  261. const Canvas = new CANVAS(); // CONCATENATED MODULE: ./src/tools/index.ts // CONCATENATED MODULE: ./src/types/index.ts // CONCATENATED MODULE: ./src/index.ts
  262.  
  263. // const shortcut = new Shortcut();
  264. diep_Shortcut = __webpack_exports__;
  265. /******/
  266. })();
  267. //diepAPI end
  268.  
  269. _window.diep_Shortcut = diep_Shortcut;
  270. })();