AX Bots

AX Bots - Powerline.io

  1. // ==UserScript==
  2. // @name AX Bots
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.2
  5. // @description AX Bots - Powerline.io
  6. // @match *://powerline.io/*
  7. // @grant none
  8. // @author https://discord.gg/zJafSX57Rc
  9. // ==/UserScript==
  10.  
  11. (function(){'use strict';const Version="1.2";let WEBSOCKET_SERVER_URL='';let botCount=100;const originalWebSocket=window.WebSocket;window.WebSocket=function(...args){const ws=new originalWebSocket(...args);if(!WEBSOCKET_SERVER_URL){const url=new URL(args[0]);WEBSOCKET_SERVER_URL=`${url.hostname}:${url.port || 80}`}
  12. return ws};const style=document.createElement('style');style.innerHTML=`
  13. body {
  14. font-family: Arial, sans-serif;
  15. background-color: #f7f7f7;
  16. }
  17. .button-container {
  18. position: fixed;
  19. top: 10px;
  20. left: 10px;
  21. z-index: 100;
  22. display: flex;
  23. flex-direction: column;
  24. gap: 10px;
  25. width: 150px;
  26. background: rgba(0,0,0,0.5);
  27. padding: 10px;
  28. border-radius: 5px;
  29. border: 2px solid;
  30. }
  31. .rgb-text {
  32. font-size: larger;
  33. text-align: center;
  34. }
  35. .rgb-text-qn {
  36. font-size: 10px;
  37. text-align: center;
  38. }
  39. button {
  40. padding: 10px;
  41. border: none;
  42. border-radius: 5px;
  43. font-size: 1rem;
  44. cursor: pointer;
  45. transition: background-color 0.3s ease;
  46. width: 100%;
  47. }
  48. #toggleButton {
  49. background-color: green;
  50. color: white;
  51. }
  52. #toggleButton.active {
  53. background-color: red;
  54. }
  55. input {
  56. width: 100%;
  57. padding: 5px;
  58. border-radius: 5px;
  59. }
  60. #message {
  61. color: white;
  62. text-align: center;
  63. font-family: monospace;
  64. }
  65. .switch-container {
  66. display: flex;
  67. justify-content: space-between;
  68. }
  69. .switch {
  70. flex-grow: 1;
  71. background: rgba(0, 0, 0, 0.5);
  72. color: white;
  73. text-align: center;
  74. padding: 5px;
  75. border-radius: 5px;
  76. cursor: pointer;
  77. }
  78. .switch.active {
  79. background-color: #4caf50;
  80. }
  81. `;document.head.appendChild(style);const container=document.createElement('div');container.id='draggable-container';container.className='button-container';container.innerHTML=`
  82. <div id="rgb-text" class="rgb-text" style="font-family:monospace">AX Bots</div>
  83. <div id="message">Connected bots: 0</div>
  84. <div id="rgb-text" class="rgb-text-qn" style="font-family:monospace">Quantity:</div>
  85. <div class="switch-container">
  86. <div id="switchLow" class="switch active">Low</div>
  87. <div id="switchMed" class="switch">Med</div>
  88. <div id="switchHigh" class="switch">High</div>
  89. </div>
  90. <input type="text" id="nickname-input" placeholder="Bots nick" value="AX Bots" maxlength="15">
  91. <button id="toggleButton">Start Bots</button>
  92. `;document.body.appendChild(container);const dragItem=container;let active=!1;let currentX,currentY,initialX,initialY,xOffset=0,yOffset=0;dragItem.addEventListener('mousedown',dragStart,!1);window.addEventListener('mouseup',dragEnd,!1);window.addEventListener('mousemove',drag,!1);function dragStart(e){initialX=e.clientX-xOffset;initialY=e.clientY-yOffset;active=!0}
  93. function dragEnd(){initialX=currentX;initialY=currentY;active=!1}
  94. function drag(e){if(active){e.preventDefault();currentX=e.clientX-initialX;currentY=e.clientY-initialY;xOffset=currentX;yOffset=currentY;dragItem.style.transform=`translate3d(${currentX}px, ${currentY}px, 0)`}}
  95. let red=0,green=0,blue=0;let redDirection=1,greenDirection=1,blueDirection=1;function changeColor(){const elems=document.querySelectorAll('#rgb-text, #message');const elemBorder=document.getElementById('draggable-container');elems.forEach(elem=>elem.style.color=`rgb(${red}, ${green}, ${blue})`);elemBorder.style.borderColor=`rgb(${red}, ${green}, ${blue})`;if(red>=255)redDirection=-1;if(red<=0)redDirection=1;if(green>=255)greenDirection=-1;if(green<=0)greenDirection=1;if(blue>=255)blueDirection=-1;if(blue<=0)blueDirection=1;red+=redDirection*5;green+=greenDirection*7;blue+=blueDirection*11}
  96. setInterval(changeColor,50);let configSocket;let botsRunning=!1;let shouldReconnect=!0;function generateUniqueId(){return Math.random().toString(36).substr(2,9)}
  97. function toggleBots(){if(botsRunning){stopBots()}else{startBots()}}
  98. function startBots(){const nickname=document.getElementById('nickname-input').value;configSocket=new WebSocket('wss://a.ctx.cl:8443');configSocket.addEventListener('open',function(){const config={action:'start',server:WEBSOCKET_SERVER_URL,nickname:nickname,bots:botCount,version:Version};configSocket.send(JSON.stringify(config));botsRunning=!0;document.getElementById('toggleButton').innerHTML="Stop Bots";document.getElementById('toggleButton').classList.add("active")});configSocket.addEventListener('message',function(event){const message=JSON.parse(event.data);if(message.type==='status'&&message.message.startsWith('Connected bots:')){document.getElementById('message').textContent=message.message}else if(message.type==='error'){alert(message.message);if(message.message==='Bots in use, Please wait'){shouldReconnect=!1}}});configSocket.addEventListener('close',function(){console.log('Disconnected.')})}
  99. function stopBots(){if(configSocket){const stopSignal={action:'stop',version:Version};configSocket.send(JSON.stringify(stopSignal));configSocket.close()}
  100. botsRunning=!1;document.getElementById('toggleButton').innerHTML="Start Bots";document.getElementById('toggleButton').classList.remove("active")}
  101. document.getElementById('toggleButton').addEventListener('click',function(){shouldReconnect=!0;toggleBots()});document.getElementById('switchLow').addEventListener('click',function(){botCount=100;updateSwitchActiveState('Low')});document.getElementById('switchMed').addEventListener('click',function(){botCount=300;updateSwitchActiveState('Med')});document.getElementById('switchHigh').addEventListener('click',function(){botCount=700;updateSwitchActiveState('High')});function updateSwitchActiveState(activeLabel){const switches=document.querySelectorAll('.switch');switches.forEach(switchElem=>{if(switchElem.innerText===activeLabel){switchElem.classList.add('active')}else{switchElem.classList.remove('active')}})}})()