Swordz.io Clean Up + AI Spam Bot + Toggle UI

Hides junk in the homescreen, other boxes on the top left, the coins display, adds an AI Spam Bot, and provides a toggle UI at the bottom left

  1. // ==UserScript==
  2. // @name Swordz.io Clean Up + AI Spam Bot + Toggle UI
  3. // @namespace intuxs
  4. // @version 1.3
  5. // @description Hides junk in the homescreen, other boxes on the top left, the coins display, adds an AI Spam Bot, and provides a toggle UI at the bottom left
  6. // @author intuxs
  7. // @match *.swordz.io
  8. // @grant none
  9. // ==/UserScript==
  10. // ==========================================
  11. // Ad and UI Cleanup Functionality
  12. // ==========================================
  13.  
  14. var hideBoxesEnabled = false; // Toggle hide boxes on/off
  15. var showPauseEnabled = false; // Toggle show pause on/off
  16. var showCoinsEnabled = false; // Toggle show coins on/off
  17.  
  18. // Store original styles for elements
  19. const originalStyles = new Map();
  20.  
  21. // Function to hide ads
  22. function hideAds() {
  23. if (!hideBoxesEnabled) return; // Only hide ads if hideBoxesEnabled is true
  24. const ads = document.querySelectorAll('div[style*="background-color"], iframe, img[src*="ads"]');
  25. ads.forEach(ad => {
  26. if (ad.offsetWidth > 0 && ad.offsetHeight > 0 && !ad.classList.contains('custom-ui')) { // Skip custom UI elements
  27. originalStyles.set(ad, { display: ad.style.display, visibility: ad.style.visibility });
  28. ad.style.display = 'none';
  29. console.log('Ad hidden:', ad);
  30. }
  31. });
  32. }
  33.  
  34. // Function to hide the logo
  35. function hideLogo() {
  36. if (!hideBoxesEnabled) return; // Only hide logo if hideBoxesEnabled is true
  37.  
  38. const logo = document.querySelector('img[src="https://playem.io/cache/swordzio/client/img/logo.png"]');
  39. if (logo && !logo.classList.contains('custom-ui')) { // Skip custom UI elements
  40. originalStyles.set(logo, { display: logo.style.display, visibility: logo.style.visibility });
  41. logo.style.display = 'none';
  42. console.log('Logo hidden:', logo);
  43. }
  44. }
  45.  
  46. // Function to hide specific elements on the top left
  47. function hideTopLeftElements() {
  48. if (!hideBoxesEnabled) return; // Only hide elements if hideBoxesEnabled is true
  49. const elementsToHide = [
  50. { id: 'buttonFullscreenImage', type: 'img' },
  51. { id: 'buttonFullscreen', type: 'div' },
  52. { id: 'buttonMusicImage', type: 'img' },
  53. { id: 'buttonMusic', type: 'div' },
  54. { id: 'buttonPauseImage', type: 'img' },
  55. { id: 'buttonPause', type: 'div' },
  56. { id: 'buttonSoundImage', type: 'img' },
  57. { id: 'buttonSound', type: 'div' }
  58. ];
  59.  
  60. elementsToHide.forEach(element => {
  61. const el = document.getElementById(element.id);
  62. if (el && !el.classList.contains('custom-ui')) { // Skip custom UI elements
  63. originalStyles.set(el, { display: el.style.display, visibility: el.style.visibility });
  64. el.style.visibility = 'hidden';
  65. }
  66. });
  67. }
  68.  
  69. // Function to hide the coins display
  70. function hideCoinsDisplay() {
  71. if (!hideBoxesEnabled) return; // Only hide coins if hideBoxesEnabled is true
  72. const coinsText = document.getElementById('coinsText');
  73. if (coinsText && !coinsText.classList.contains('custom-ui')) { // Skip custom UI elements
  74. originalStyles.set(coinsText, { display: coinsText.style.display, visibility: coinsText.style.visibility });
  75. coinsText.style.visibility = 'hidden';
  76. }
  77.  
  78. const coinsIcon = document.querySelector('img[src*="coins.png"]');
  79. if (coinsIcon && !coinsIcon.classList.contains('custom-ui')) { // Skip custom UI elements
  80. originalStyles.set(coinsIcon, { display: coinsIcon.style.display, visibility: coinsIcon.style.visibility });
  81. coinsIcon.style.visibility = 'hidden';
  82. }
  83. }
  84.  
  85. // Function to hide the YouTube wrapper and big box on the bottom right
  86. function hideYouTubeWrapperAndBigBox() {
  87. if (!hideBoxesEnabled) return; // Only hide if hideBoxesEnabled is true
  88.  
  89. // Hide YouTube wrapper
  90. const youtubeWrapper = document.querySelector('.youtube-wrapper'); // Adjust selector if needed
  91. if (youtubeWrapper && !youtubeWrapper.classList.contains('custom-ui')) { // Skip custom UI elements
  92. originalStyles.set(youtubeWrapper, { display: youtubeWrapper.style.display, visibility: youtubeWrapper.style.visibility });
  93. youtubeWrapper.style.visibility = 'hidden';
  94. }
  95.  
  96. // Hide big box on the bottom right
  97. const bigBox = document.querySelector('.big-box'); // Adjust selector if needed
  98. if (bigBox && !bigBox.classList.contains('custom-ui')) { // Skip custom UI elements
  99. originalStyles.set(bigBox, { display: bigBox.style.display, visibility: bigBox.style.visibility });
  100. bigBox.style.visibility = 'hidden';
  101. }
  102. }
  103.  
  104. // Function to show hidden elements
  105. function showHiddenElements() {
  106. // Restore original styles for all elements except the UI we created
  107. originalStyles.forEach((styles, element) => {
  108. if (element && !element.classList.contains('custom-ui')) { // Skip custom UI elements
  109. element.style.display = styles.display;
  110. element.style.visibility = styles.visibility;
  111. }
  112. });
  113.  
  114. // Clear the original styles map
  115. originalStyles.clear();
  116. }
  117.  
  118. // Function to toggle pause button visibility
  119. function togglePauseButton() {
  120. const buttonPause = document.getElementById('buttonPause');
  121. const buttonPauseImage = document.getElementById('buttonPauseImage');
  122.  
  123. if (buttonPause && buttonPauseImage) {
  124. if (showPauseEnabled) {
  125. buttonPause.style.visibility = 'visible';
  126. buttonPauseImage.style.visibility = 'visible';
  127. } else {
  128. buttonPause.style.visibility = 'hidden';
  129. buttonPauseImage.style.visibility = 'hidden';
  130. }
  131. }
  132. }
  133.  
  134. // Function to toggle coins visibility
  135. function toggleCoinsDisplay() {
  136. const coinsText = document.getElementById('coinsText');
  137. const coinsIcon = document.querySelector('img[src*="coins.png"]');
  138.  
  139. if (coinsText && coinsIcon) {
  140. if (showCoinsEnabled) {
  141. coinsText.style.visibility = 'visible';
  142. coinsIcon.style.visibility = 'visible';
  143. } else {
  144. coinsText.style.visibility = 'hidden';
  145. coinsIcon.style.visibility = 'hidden';
  146. }
  147. }
  148. }
  149.  
  150. // ==========================================
  151. // AI Spam Bot Functionality
  152. // ==========================================
  153.  
  154. var spam = false; // Toggle spam on/off
  155. var spamMessage = "Subscribe to richupi YT!"; // Default spam message
  156.  
  157. // Function to send spam messages
  158. function spamChat() {
  159. if (spam) {
  160. const message = input.value.trim() !== '' ? input.value : spamMessage;
  161. console.log('Sending message:', message);
  162.  
  163. try {
  164. socket.emit('keyPressX', {
  165. inputId: 'chatMessage',
  166. state: message
  167. });
  168. console.log('Message sent successfully!');
  169. } catch (error) {
  170. console.error('Error sending message:', error);
  171. }
  172. }
  173. }
  174.  
  175. // ==========================================
  176. // Toggle UI Functionality
  177. // ==========================================
  178.  
  179. // Create a UI container at the bottom left
  180. const uiContainer = document.createElement('div');
  181. uiContainer.style.position = 'fixed';
  182. uiContainer.style.bottom = '10px';
  183. uiContainer.style.left = '10px';
  184. uiContainer.style.zIndex = '9999';
  185. uiContainer.style.backgroundColor = 'rgba(0, 0, 0, 0.7)';
  186. uiContainer.style.padding = '10px';
  187. uiContainer.style.borderRadius = '10px';
  188. uiContainer.style.color = '#fff';
  189. uiContainer.style.fontFamily = 'Montserrat, Arial, sans-serif';
  190. uiContainer.style.transition = 'transform 0.3s ease';
  191. uiContainer.classList.add('custom-ui'); // Add a class to identify our custom UI
  192. document.body.appendChild(uiContainer);
  193.  
  194. // Create an arrow button to hide/show the UI
  195. const arrowButton = document.createElement('div');
  196. arrowButton.textContent = '◄'; // Arrow pointing left
  197. arrowButton.style.position = 'fixed';
  198. arrowButton.style.bottom = '20px';
  199. arrowButton.style.left = '10px';
  200. arrowButton.style.zIndex = '10000';
  201. arrowButton.style.backgroundColor = 'rgba(0, 0, 0, 0.7)';
  202. arrowButton.style.color = 'lightblue'; // Changed from white to light blue
  203. arrowButton.style.padding = '10px';
  204. arrowButton.style.borderRadius = '50%';
  205. arrowButton.style.cursor = 'pointer';
  206. arrowButton.style.userSelect = 'none';
  207. arrowButton.style.transition = 'transform 0.3s ease';
  208. arrowButton.classList.add('custom-ui'); // Add a class to identify our custom UI
  209. document.body.appendChild(arrowButton);
  210.  
  211. // Toggle UI visibility
  212. let uiVisible = true;
  213. arrowButton.addEventListener('click', () => {
  214. uiVisible = !uiVisible;
  215. if (uiVisible) {
  216. uiContainer.style.transform = 'translateX(0)';
  217. arrowButton.style.transform = 'rotate(0deg)';
  218. arrowButton.textContent = '◄'; // Arrow pointing left
  219. } else {
  220. uiContainer.style.transform = 'translateX(-110%)';
  221. arrowButton.style.transform = 'rotate(180deg)';
  222. arrowButton.textContent = '►'; // Arrow pointing right
  223. }
  224. });
  225.  
  226. // Spam Bot Toggle
  227. const spamBotLabel = document.createElement('div');
  228. spamBotLabel.textContent = 'Spam Bot [1]';
  229. spamBotLabel.style.color = '#ffa500'; // Orange when off
  230. spamBotLabel.style.fontSize = '14px';
  231. spamBotLabel.style.fontWeight = 'bold';
  232. spamBotLabel.style.marginBottom = '10px';
  233. spamBotLabel.style.cursor = 'pointer';
  234. uiContainer.appendChild(spamBotLabel);
  235.  
  236. // Hide Boxes Toggle
  237. const hideBoxesLabel = document.createElement('div');
  238. hideBoxesLabel.textContent = 'Hide Boxes [2]';
  239. hideBoxesLabel.style.color = '#ffa500'; // Orange when off
  240. hideBoxesLabel.style.fontSize = '14px';
  241. hideBoxesLabel.style.fontWeight = 'bold';
  242. hideBoxesLabel.style.marginBottom = '10px';
  243. hideBoxesLabel.style.cursor = 'pointer';
  244. uiContainer.appendChild(hideBoxesLabel);
  245.  
  246. // Show Pause Toggle
  247. const showPauseLabel = document.createElement('div');
  248. showPauseLabel.textContent = 'Show Pause [3]';
  249. showPauseLabel.style.color = '#ffa500'; // Orange when off
  250. showPauseLabel.style.fontSize = '14px';
  251. showPauseLabel.style.fontWeight = 'bold';
  252. showPauseLabel.style.marginBottom = '10px';
  253. showPauseLabel.style.cursor = 'pointer';
  254. uiContainer.appendChild(showPauseLabel);
  255.  
  256. // Show Coins Toggle
  257. const showCoinsLabel = document.createElement('div');
  258. showCoinsLabel.textContent = 'Show Coins [4]';
  259. showCoinsLabel.style.color = '#ffa500'; // Orange when off
  260. showCoinsLabel.style.fontSize = '14px';
  261. showCoinsLabel.style.fontWeight = 'bold';
  262. showCoinsLabel.style.marginBottom = '10px';
  263. showCoinsLabel.style.cursor = 'pointer';
  264. uiContainer.appendChild(showCoinsLabel);
  265.  
  266. // Input for custom spam message
  267. const input = document.createElement('input');
  268. input.style.width = '100%';
  269. input.style.marginTop = '10px';
  270. input.style.height = '25px';
  271. input.style.borderRadius = '5px';
  272. input.style.backgroundColor = '#222';
  273. input.style.color = '#fff';
  274. input.style.border = '1px solid #555';
  275. input.style.padding = '5px';
  276. input.placeholder = 'Enter spam message';
  277. uiContainer.appendChild(input);
  278.  
  279. // Toggle Spam Bot with '1' key
  280. document.addEventListener('keydown', function (e) {
  281. if (e.key === '1') { // '1' key to toggle spam bot
  282. spam = !spam;
  283. spamBotLabel.textContent = `Spam Bot [1] ${spam ? 'ON' : 'OFF'}`;
  284. spamBotLabel.style.color = spam ? '#32CD32' : '#ffa500'; // Lime green when on, orange when off
  285. console.log(`Spam Bot ${spam ? 'enabled' : 'disabled'}`);
  286. }
  287. });
  288.  
  289. // Toggle Hide Boxes with '2' key
  290. document.addEventListener('keydown', function (e) {
  291. if (e.key === '2') { // '2' key to toggle hide boxes
  292. hideBoxesEnabled = !hideBoxesEnabled;
  293. hideBoxesLabel.textContent = `Hide Boxes [2] ${hideBoxesEnabled ? 'ON' : 'OFF'}`;
  294. hideBoxesLabel.style.color = hideBoxesEnabled ? '#32CD32' : '#ffa500'; // Lime green when on, orange when off
  295. console.log(`Hide Boxes ${hideBoxesEnabled ? 'enabled' : 'disabled'}`);
  296.  
  297. if (hideBoxesEnabled) {
  298. hideAds();
  299. hideLogo(); // Call the new function
  300. hideTopLeftElements();
  301. hideCoinsDisplay();
  302. hideYouTubeWrapperAndBigBox();
  303. } else {
  304. showHiddenElements();
  305. }
  306. }
  307. });
  308.  
  309. // Toggle Show Pause with '3' key
  310. document.addEventListener('keydown', function (e) {
  311. if (e.key === '3') { // '3' key to toggle show pause
  312. showPauseEnabled = !showPauseEnabled;
  313. showPauseLabel.textContent = `Show Pause [3] ${showPauseEnabled ? 'ON' : 'OFF'}`;
  314. showPauseLabel.style.color = showPauseEnabled ? '#32CD32' : '#ffa500'; // Lime green when on, orange when off
  315. console.log(`Show Pause ${showPauseEnabled ? 'enabled' : 'disabled'}`);
  316. togglePauseButton();
  317. }
  318. });
  319.  
  320. // Toggle Show Coins with '4' key
  321. document.addEventListener('keydown', function (e) {
  322. if (e.key === '4') { // '4' key to toggle show coins
  323. showCoinsEnabled = !showCoinsEnabled;
  324. showCoinsLabel.textContent = `Show Coins [4] ${showCoinsEnabled ? 'ON' : 'OFF'}`;
  325. showCoinsLabel.style.color = showCoinsEnabled ? '#32CD32' : '#ffa500'; // Lime green when on, orange when off
  326. console.log(`Show Coins ${showCoinsEnabled ? 'enabled' : 'disabled'}`);
  327. toggleCoinsDisplay();
  328. }
  329. });
  330.  
  331. // Continuously send spam messages
  332. setInterval(spamChat, 1000);