Bot panel

Bot Panel for gartic.io

  1. // ==UserScript==
  2. // @name Bot panel
  3. // @name:tr made by frio
  4. // @name:az hello
  5. // @description Bot Panel for gartic.io
  6. // @description:tr Bot Panel for gartic.io (in Turkish)
  7. // @description:az Bot Panel for gartic.io (in Azerbaijani)
  8. // @version 1.1
  9. // @author frio
  10. // @license MIT
  11. // @match *://gartic.io/*
  12. // @match *://*/*?__cpo=aHR0cHM6Ly9nYXJ0aWMuaW8
  13. // @icon https://cdn.discordapp.com/attachments/1124451069204910161/1177654466523189360/MOSHED-2023-11-24-13-55-23.jpg?ex=65734b30&is=6560d630&hm=1b42ff32759ea222cc3b1eac33cb7852209358d47e44c560b10efe0f8f230752&
  14. // @grant GM_setValue
  15. // @grant GM_getValue
  16. // @grant GM_addValueChangeListener
  17. // @grant GM_addStyle
  18. // @namespace https://greasyfork.org/users/1220697
  19. // ==/UserScript==
  20.  
  21. let m_s, a_i, m_a, m_z, m_b;
  22.  
  23. const f = x => document.querySelector(x),
  24. sendMessage = (inputSelector, mesaj) => {
  25. a_i = document.querySelector(inputSelector);
  26. m_a = a_i.value;
  27. a_i.value = mesaj + m_a;
  28. m_z = new Event("input", { bubbles: !0 });
  29. m_z.simulated = !0;
  30. m_b = new Event("submit", { bubbles: !0 });
  31. m_b.simulated = !0;
  32. m_s = a_i._valueTracker;
  33. m_s && m_s.setValue(m_a);
  34. a_i.dispatchEvent(m_z);
  35. a_i.form.dispatchEvent(m_b);
  36. },
  37. rand = x => Math.floor(Math.random() * 1000000),
  38. GM_onMessage = (label, cb) => GM_addValueChangeListener(label, (_, __, data) => cb(...data)),
  39. GM_sendMessage = (label, ...data) => GM_setValue(label, data);
  40.  
  41. GM_onMessage('ucur', (atılacak, _) => {
  42. atılacak && document.querySelectorAll(".nick").forEach(nick => {
  43. nick.innerText === atılacak && (nick.click(), f(".ic-votekick")?.click())
  44. })
  45. });
  46. GM_onMessage('msg', (i, w, _) => {
  47. sendMessage(i, w)
  48. })
  49. GM_onMessage('report', (_, __) => {
  50. let reportButton = document.evaluate('//*[@id="canvas"]/button', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  51. if (reportButton) {
  52. reportButton.click();
  53. let confirmButton = document.evaluate('//*[@id="popUp"]/div[1]/div/div[3]/button[2]', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  54. if (confirmButton) {
  55. confirmButton.click();
  56. }
  57. }
  58. });
  59. GM_onMessage('exit', (_, __) => {
  60. let exitButton = document.evaluate('//*[@id="exit"]', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  61. if (exitButton) {
  62. setTimeout(function () {
  63. exitButton.click();
  64. let confirmButton = document.evaluate('//*[@id="popUp"]/div[1]/div/div[3]/button[2]', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  65. if (confirmButton) {
  66. confirmButton.click();
  67. }
  68. }, 0); // Delay of 1 second
  69. }
  70. });
  71.  
  72. // Additional code for kicking users by WebSocket message
  73. let thisisabigofthing = 0;
  74.  
  75. function kickUserById(userId) {
  76. // Implement the logic to kick the user by sending a WebSocket message
  77. const kickMessage = '42[45,' + window.wsId + ',[' + userId + ',true]]';
  78. window.wsObj.send(kickMessage);
  79. }
  80.  
  81. function kickUserByNickname(nickname) {
  82. const user = window.roomusers.find(user => user.nick === nickname);
  83. if (user) {
  84. kickUserById(user.id);
  85. }
  86. }
  87.  
  88. // Listen for changes in the kickle value
  89. GM_addValueChangeListener("kickle", function(n, o, nv, r) {
  90. let username = nv.split("..")[0];
  91. usersinroom.forEach(x => {
  92. if (x.nick == username) {
  93. let userid = x.id;
  94. wss.forEach(ws => {
  95. x.nick.split("‏").join("") != "REDbot" ?
  96. typeof (userid) == "string" ?
  97. ws.ws.send('42[45,' + ws.id + ',["' + userid + '",true]]') :
  98. ws.ws.send('42[45,' + ws.id + ',[' + userid + ',true]]') :
  99. 0;
  100. });
  101. }
  102. });
  103. });
  104.  
  105. window.onload = function () {
  106. const container = document.createElement("div");
  107. container.style = "width:120px;height:auto;z-index:99;position:fixed;top:10px;left:10px;display:flex;flex-direction:column;align-items:center;gap:5px;background-color:#333333;border:2px solid #FFD700;border-radius:10px;padding:5px;box-shadow:5px 5px 5px rgba(0,0,0,0.5);";
  108. document.body.appendChild(container);
  109.  
  110. const answerInput = createInput("100px", "20px");
  111. container.appendChild(answerInput);
  112.  
  113. const answer = createButton("100px", "25px", "Respost", () => {
  114. let message = answerInput.value;
  115. if (message) {
  116. GM_sendMessage('msg', 'input[name=answer]', message, rand());
  117. }
  118. });
  119. container.appendChild(answer);
  120.  
  121. const chatInput = createInput("100px", "20px");
  122. container.appendChild(chatInput);
  123.  
  124. const chat = createButton("100px", "25px", "Chat", () => {
  125. let message = chatInput.value;
  126. if (message) {
  127. GM_sendMessage('msg', 'input[name=chat]', message, rand());
  128. }
  129. });
  130. container.appendChild(chat);
  131.  
  132. const exit = createButton("100px", "25px", "Exit", () => {
  133. GM_sendMessage('exit', rand(), rand());
  134. });
  135. container.appendChild(exit);
  136.  
  137. const report = createButton("100px", "25px", "Report", () => {
  138. GM_sendMessage('report', rand(), rand());
  139. });
  140. container.appendChild(report);
  141.  
  142. const kickInput = createInput("100px", "20px");
  143. container.appendChild(kickInput);
  144.  
  145. const kick = createButton("100px", "25px", "Kick", () => {
  146. let user = kickInput.value;
  147. if (user) {
  148. GM_sendMessage('ucur', user, rand());
  149. }
  150. });
  151. container.appendChild(kick);
  152.  
  153. const broadcastInput = createInput("100px", "20px");
  154. container.appendChild(broadcastInput);
  155.  
  156. const broadcast = createButton("100px", "25px", "Broadcast", () => {
  157. let message = broadcastInput.value;
  158. if (message) {
  159. GM_sendMessage('msg', 'input[name=answer]', message, rand());
  160. GM_sendMessage('msg', 'input[name=chat]', message, rand());
  161. }
  162. });
  163. container.appendChild(broadcast);
  164.  
  165. const roomConsole = document.createElement("div");
  166. roomConsole.style = "color:#FFD700;margin-top:5px;";
  167. container.appendChild(roomConsole);
  168.  
  169. let currentGarticRoom;
  170.  
  171. // Function to check if the current page is a gartic.io room
  172. function getGarticRoom() {
  173. let garticRegex = /gartic\.io\/(.+)$/;
  174. let match = window.location.href.match(garticRegex);
  175. if (match && match[1]) {
  176. return match[1];
  177. }
  178. return null;
  179. }
  180.  
  181. // Function to update the current gartic.io room
  182. function updateCurrentRoom() {
  183. let room = getGarticRoom();
  184. if (room !== currentGarticRoom) {
  185. currentGarticRoom = room;
  186. roomConsole.innerText = `Current Room: ${currentGarticRoom || 'No room found'}`;
  187. }
  188. }
  189.  
  190. // Update the room initially
  191. updateCurrentRoom();
  192.  
  193. // Check for room changes every 5 seconds
  194. setInterval(updateCurrentRoom, 5000);
  195. };
  196.  
  197. function createInput(width, height) {
  198. const input = document.createElement("input");
  199. input.style = `width:${width};height:${height};border-radius:5px;padding:5px;border:1px solid #FFD700;background-color:#333333;color:#FFD700;`;
  200. return input;
  201. }
  202.  
  203. function createButton(width, height, text, clickHandler) {
  204. const button = document.createElement("button");
  205. button.style = `width:${width};height:${height};background-color:#FFD700;color:black;border-radius:5px;border:1px solid black;margin-top:5px;`;
  206. button.textContent = text;
  207. button.addEventListener("mousedown", clickHandler);
  208. return button;
  209. }