Chat Spam Control with Player Info

Chat spamming control with UI elements and player info

  1. // ==UserScript==
  2. // @name Chat Spam Control with Player Info
  3. // @namespace http://tampermonkey.net/
  4. // @version 2.1
  5. // @description Chat spamming control with UI elements and player info
  6. // @author You
  7. // @match https://craftnite.io/*
  8. // @grant none
  9. // @license LOVEJL
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. let cheatnite = {};
  16. let spamInterval = null;
  17. let isInputVisible = true;
  18. let playerInfo = {}; // To store IP address and coordinates for each player
  19.  
  20. // Add spam control UI elements
  21. const chatBox = document.createElement('div');
  22. chatBox.style.position = 'fixed';
  23. chatBox.style.top = '50%';
  24. chatBox.style.left = '50%';
  25. chatBox.style.transform = 'translate(-50%, -50%)';
  26. chatBox.style.zIndex = '1000';
  27. chatBox.style.backgroundColor = 'rgba(0, 0, 0, 0.8)';
  28. chatBox.style.padding = '10px';
  29. chatBox.style.borderRadius = '10px';
  30. chatBox.style.display = 'flex';
  31. chatBox.style.flexDirection = 'column';
  32. chatBox.style.alignItems = 'center';
  33.  
  34. const inputField = document.createElement('input');
  35. inputField.type = 'text';
  36. inputField.placeholder = 'Enter your message';
  37. inputField.style.marginBottom = '10px';
  38. inputField.style.padding = '5px';
  39.  
  40. const spamButton = document.createElement('button');
  41. spamButton.innerText = 'Spam';
  42. spamButton.style.marginBottom = '5px';
  43. spamButton.onclick = () => {
  44. const message = inputField.value.trim();
  45. if (message) {
  46. // Stop any existing spam
  47. if (spamInterval) {
  48. clearInterval(spamInterval);
  49. spamInterval = null;
  50. }
  51. // Start new spam
  52. spamInterval = setInterval(() => {
  53. var e = new a201();
  54. e.msg = message;
  55. if (G.socket && typeof G.socket.send === 'function') {
  56. G.socket.send(e.a614());
  57. }
  58. }, 60);
  59. }
  60. };
  61.  
  62. const stopButton = document.createElement('button');
  63. stopButton.innerText = 'Stop';
  64. stopButton.style.marginBottom = '5px';
  65. stopButton.onclick = () => {
  66. if (spamInterval) {
  67. clearInterval(spamInterval);
  68. spamInterval = null;
  69. }
  70. };
  71.  
  72. const clearButton = document.createElement('button');
  73. clearButton.innerText = 'Clear';
  74. clearButton.style.marginBottom = '5px';
  75. clearButton.onclick = () => {
  76. inputField.value = '';
  77. };
  78.  
  79. const playerButton = document.createElement('button');
  80. playerButton.innerText = 'Players';
  81. playerButton.style.marginBottom = '5px';
  82. playerButton.onclick = () => {
  83. startPlayerInfoSpam();
  84. };
  85.  
  86. chatBox.appendChild(inputField);
  87. chatBox.appendChild(spamButton);
  88. chatBox.appendChild(stopButton);
  89. chatBox.appendChild(clearButton);
  90. chatBox.appendChild(playerButton);
  91. document.body.appendChild(chatBox);
  92.  
  93. function startPlayerInfoSpam() {
  94. if (spamInterval) {
  95. clearInterval(spamInterval);
  96. }
  97. spamInterval = setInterval(() => {
  98. let players = getOtherPlayers();
  99. players.forEach(player => {
  100. if (player.name && player.name.toLowerCase() === "unnamed") {
  101. if (!playerInfo[player.hitbox.uuid]) {
  102. playerInfo[player.hitbox.uuid] = {
  103. ip: `192.168.${Math.floor(Math.random() * 255)}.${Math.floor(Math.random() * 255)}`,
  104. coords: `${(Math.random() * 180 - 90).toFixed(6)}, ${(Math.random() * 360 - 180).toFixed(6)}`
  105. };
  106. }
  107. let playerWorldPosition = new THREE.Vector3();
  108. player.a240.getWorldPosition(playerWorldPosition);
  109. var e = new a201();
  110. e.msg = `Player: ${player.name}, Location: ${playerWorldPosition.toArray()}, IP: ${playerInfo[player.hitbox.uuid].ip}, Coordinates: ${playerInfo[player.hitbox.uuid].coords}`;
  111. if (G.socket && typeof G.socket.send === 'function') {
  112. G.socket.send(e.a614());
  113. }
  114. }
  115. });
  116. }, 1000); // Send player information as message every second
  117. }
  118.  
  119. function getOtherPlayers() {
  120. return G.othera822ers.filter(player => player && player.a240).map(player => {
  121. if (!player.hitbox) {
  122. var hitbox = new THREE.Mesh(
  123. new THREE.BoxGeometry(3, 10, 3),
  124. new THREE.MeshBasicMaterial({ visible: true }) // Make hitboxes visible
  125. );
  126. player.hitbox = hitbox;
  127. player.a240.add(hitbox);
  128. }
  129. return player;
  130. });
  131. }
  132.  
  133. // Prevent default WASD, space, and other keys when input field is focused
  134. inputField.addEventListener('keydown', (event) => {
  135. console.log(`Key pressed: ${event.key}`); // Log pressed key to console
  136.  
  137. // Allow all alphanumeric keys and control shortcuts
  138. if (!event.ctrlKey && (event.key.length === 1 && event.key.match(/[a-z0-9]/i) || event.key === ' ')) {
  139. // Prevent game actions but allow typing
  140. event.preventDefault();
  141. event.stopPropagation();
  142. inputField.value += event.key;
  143. }
  144. });
  145.  
  146. // Enable paste functionality
  147. inputField.addEventListener('paste', (event) => {
  148. // Allow default paste behavior
  149. setTimeout(() => {
  150. const pastedText = inputField.value;
  151. console.log(`Pasted text: ${pastedText}`);
  152. }, 0);
  153. });
  154.  
  155. // Hide and show input box with key '7'
  156. document.addEventListener('keydown', (event) => {
  157. if (event.key === '7') {
  158. isInputVisible = !isInputVisible;
  159. chatBox.style.display = isInputVisible ? 'flex' : 'none';
  160. }
  161. });
  162.  
  163. // G.socket.onmessage error handling
  164. if (G.socket) {
  165. G.socket.onmessage = function(event) {
  166. try {
  167. // Existing logic
  168. } catch (error) {
  169. console.error('Error processing message:', error);
  170. }
  171. };
  172. } else {
  173. console.error('G.socket is null or undefined');
  174. }
  175. })();