Custom Crosshairs for Krunker, 1v1.lol, and Anything Else.

Custom Crosshiars For Literally ANYTHING--Hide The Menu Using "P"

  1. // ==UserScript==
  2. // @name Custom Crosshairs for Krunker, 1v1.lol, and Anything Else.
  3. // @namespace http://tampermonkey.net/
  4. // @version 3.1
  5. // @description Custom Crosshiars For Literally ANYTHING--Hide The Menu Using "P"
  6. // @author LCM
  7. // @match *://*/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. // Create a container for the menu
  15. const menuContainer = document.createElement('div');
  16. menuContainer.style.position = 'fixed';
  17. menuContainer.style.top = '10px';
  18. menuContainer.style.left = '10px';
  19. menuContainer.style.zIndex = '10000';
  20. menuContainer.style.backgroundColor = 'black';
  21. menuContainer.style.padding = '50px'; // Increased padding for more space
  22. menuContainer.style.borderRadius = '10px';
  23. menuContainer.style.display = 'flex'; // Use flexbox for better layout control
  24. menuContainer.style.flexDirection = 'column'; // Align buttons vertically
  25. menuContainer.style.userSelect = 'none'; // Disable text selection
  26.  
  27. // Make the menu draggable
  28. makeDraggable(menuContainer);
  29.  
  30. // Make the menu resizable
  31. makeResizable(menuContainer);
  32.  
  33. // Create an "Authors" title
  34. const authorsTitle = document.createElement('div');
  35. authorsTitle.innerText = 'Made By - LCM';
  36. authorsTitle.style.color = 'white';
  37. authorsTitle.style.fontWeight = 'bold';
  38. authorsTitle.style.marginBottom = '10px';
  39. menuContainer.appendChild(authorsTitle);
  40.  
  41. // Create buttons to toggle different shapes
  42. const shapeButtons = ['Square', 'Circle', 'ESP Rectangle'].map(createShapeButton);
  43.  
  44. // Create shape elements
  45. const shapes = {
  46. Square: createShape('20px', '20px', '2px solid white'),
  47. Circle: createShape('20px', '20px', '2px solid white', '50%', '50%'),
  48. 'ESP Rectangle': createShape('60px', '30px', '2px solid white', '0deg', '50%', '50%'),
  49. };
  50.  
  51. // Append the shapes to the body
  52. Object.values(shapes).forEach(shape => document.body.appendChild(shape));
  53.  
  54. // Append the menu container to the body
  55. document.body.appendChild(menuContainer);
  56.  
  57. // Append the buttons to the menu container
  58. shapeButtons.forEach(button => menuContainer.appendChild(button));
  59.  
  60. // Add buttons for Red, Blue, Green, Purple, White Crosshairs
  61. const redCrosshairsButton = createColorButton('Red Crosshairs', 'red');
  62. const blueCrosshairsButton = createColorButton('Blue Crosshairs', 'blue');
  63. const greenCrosshairsButton = createColorButton('Green Crosshairs', 'green');
  64. const purpleCrosshairsButton = createColorButton('Purple Crosshairs', 'purple');
  65. const whiteCrosshairsButton = createColorButton('White Crosshairs', 'white');
  66. menuContainer.appendChild(redCrosshairsButton);
  67. menuContainer.appendChild(blueCrosshairsButton);
  68. menuContainer.appendChild(greenCrosshairsButton);
  69. menuContainer.appendChild(purpleCrosshairsButton);
  70. menuContainer.appendChild(whiteCrosshairsButton);
  71.  
  72. // Hotkey to toggle menu visibility
  73. document.addEventListener('keydown', (event) => {
  74. if (event.key === 'p' || event.key === 'P') {
  75. toggleMenuVisibility();
  76. }
  77. });
  78.  
  79. // Function to toggle the display of the menu
  80. function toggleMenuVisibility() {
  81. if (menuContainer.style.display === 'none') {
  82. menuContainer.style.display = 'flex';
  83. } else {
  84. menuContainer.style.display = 'none';
  85. }
  86. }
  87.  
  88. // Function to make an element draggable
  89. function makeDraggable(element) {
  90. let offsetX, offsetY;
  91. let isDragging = false;
  92.  
  93. element.addEventListener('mousedown', (event) => {
  94. isDragging = true;
  95. offsetX = event.clientX - element.getBoundingClientRect().left;
  96. offsetY = event.clientY - element.getBoundingClientRect().top;
  97. });
  98.  
  99. document.addEventListener('mousemove', (event) => {
  100. if (isDragging) {
  101. element.style.left = event.clientX - offsetX + 'px';
  102. element.style.top = event.clientY - offsetY + 'px';
  103. }
  104. });
  105.  
  106. document.addEventListener('mouseup', () => {
  107. isDragging = false;
  108. });
  109. }
  110.  
  111. // Function to make an element resizable
  112. function makeResizable(element) {
  113. const handle = document.createElement('div');
  114. handle.style.position = 'absolute';
  115. handle.style.width = '10px';
  116. handle.style.height = '10px';
  117. handle.style.background = 'white';
  118. handle.style.right = '0';
  119. handle.style.bottom = '0';
  120. handle.style.cursor = 'se-resize';
  121.  
  122. handle.addEventListener('mousedown', (event) => {
  123. event.preventDefault();
  124. const startX = event.clientX;
  125. const startY = event.clientY;
  126. const startWidth = parseInt(document.defaultView.getComputedStyle(element).width, 10);
  127. const startHeight = parseInt(document.defaultView.getComputedStyle(element).height, 10);
  128.  
  129. function handleMouseMove(e) {
  130. const newWidth = startWidth + e.clientX - startX;
  131. const newHeight = startHeight + e.clientY - startY;
  132. element.style.width = `${newWidth}px`;
  133. element.style.height = `${newHeight}px`;
  134. }
  135.  
  136. function handleMouseUp() {
  137. document.removeEventListener('mousemove', handleMouseMove);
  138. document.removeEventListener('mouseup', handleMouseUp);
  139. }
  140.  
  141. document.addEventListener('mousemove', handleMouseMove);
  142. document.addEventListener('mouseup', handleMouseUp);
  143. });
  144.  
  145. element.appendChild(handle);
  146. }
  147.  
  148. // Function to create a button for a shape
  149. function createShapeButton(shape) {
  150. const button = document.createElement('button');
  151. button.innerText = `Toggle ${shape}`;
  152. button.style.marginBottom = '10px'; // Adjust the margin
  153. button.style.width = '100%';
  154. button.addEventListener('click', () => toggleShape(shape));
  155. return button;
  156. }
  157.  
  158. // Function to toggle the display of a shape
  159. function toggleShape(shape) {
  160. const currentShape = shapes[shape];
  161. if (currentShape.style.display === 'none') {
  162. currentShape.style.display = 'block';
  163. } else {
  164. currentShape.style.display = 'none';
  165. }
  166. }
  167.  
  168. // Function to create a button for a color
  169. function createColorButton(label, color) {
  170. const button = document.createElement('button');
  171. button.innerText = label;
  172. button.style.marginTop = '10px'; // Adjusted margin to separate from other buttons
  173. button.style.width = '100%';
  174. button.style.height = '40px'; // Set the height for a square button
  175. button.style.backgroundColor = color;
  176. button.addEventListener('click', () => toggleColorCrosshairs(color));
  177. return button;
  178. }
  179.  
  180. // Function to toggle the color of all shapes to the specified color
  181. function toggleColorCrosshairs(color) {
  182. Object.values(shapes).forEach(shape => {
  183. shape.style.borderColor = color;
  184. });
  185. }
  186.  
  187. // Function to create a basic shape element
  188. function createShape(width, height, border, borderRadius = '0', positionTop = '50%', positionLeft = '50%', transform = '0') {
  189. const shape = document.createElement('div');
  190. shape.style.position = 'fixed';
  191. shape.style.top = positionTop;
  192. shape.style.left = positionLeft;
  193. shape.style.transform = `translate(-${positionLeft}, -${positionTop}) rotate(${transform})`;
  194. shape.style.width = width;
  195. shape.style.height = height;
  196. shape.style.border = border;
  197. shape.style.borderRadius = borderRadius;
  198. shape.style.boxSizing = 'border-box';
  199. shape.style.zIndex = '9999';
  200. shape.style.display = 'none';
  201. return shape;
  202. }
  203. })();