h0rnet

JavaScript XAT Bot

Apr 13th, 2013
721
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.47 KB | None | 0 0
  1. Javascript Xat Bot - Made by 3nvisi0n & edited by H0rnet
  2. Tutorial step by step - Made by H0rnet
  3.  
  4.  
  5. 1. You will need to download firefox
  6. ( http://www.mozilla.org/en-US/firefox/new/ )
  7.  
  8. 2. You will need to download Scriptish, which is a firefox addon.
  9. ( https://addons.mozilla.org/en-US/firefox/addon/scriptish/ )
  10.  
  11. 3. Click on "New User Script..."
  12. ( http://prntscr.com/dfslo )
  13.  
  14. 4. A window with descriptions of the script you wish to install should popup.
  15. ( http://prntscr.com/dfsmi )
  16.  
  17. 5. Fill it up like so:
  18. ( http://prntscr.com/dfsqg )
  19.  
  20. 6. Another window should pop up, remove everything in it and paste the code starting at line 30
  21. ( http://prntscr.com/dfstp )
  22. ( OR USE THE LASTEST PUBLIC RELEASE: http://pastebin.com/PJn0j16X )
  23.  
  24. 7. once everything is set up, go login m.xat.com and once you have successfuly logged in, the script should run automatically. Of course, this script isn't completly developped, if you have a little bit of knowledge, you can develop it even more. Oh and, you don't need the Bot power for this to work, why? because bot power is applied only for PHP based xat bots. Enjoy.
  25.  
  26.  
  27.  
  28.  
  29.  
  30. // ==UserScript==
  31. // @name JSXatBot
  32. // @namespace JSBot
  33. // @author 3nvisi0n & H0rnet
  34. // @include http://m.xat.com:10049/*
  35. // ==/UserScript==
  36. //DO NOT FOR ANY REASON WHAT SO EVER THINK TO COME FIND ME FOR HELP
  37. //DO NOT FOR ANY REASON WHAT SO EVER THINK TO COME FIND ME FOR HELP
  38. //DO NOT FOR ANY REASON WHAT SO EVER THINK TO COME FIND ME FOR HELP
  39. //DO NOT FOR ANY REASON WHAT SO EVER THINK TO COME FIND ME FOR HELP
  40. //DO NOT FOR ANY REASON WHAT SO EVER THINK TO COME FIND ME FOR HELP
  41. //DO NOT FOR ANY REASON WHAT SO EVER THINK TO COME FIND ME FOR HELP
  42.  
  43. /* Script is free to use edit and modify, heck that is the point
  44. of this release, I have no intention to maintain the code just put
  45. it out so you guys can use it and modify it to fit your needs. Do
  46. not ask me to add stuff, DO NOT ask me HOW to do stuff, read the
  47. code all the basics you need are here, if you need more do it your
  48. self.
  49.  
  50. Runs on m.xat.com not normal Xat pages.*/
  51.  
  52. //////////////////
  53. //---SETTINGS---//
  54. //////////////////
  55. var cmdChar = "!"; //Character that starts all commands
  56. var BUFFER_TIME = 3;//How long to wait before parsing messages(so we don't parse old ones)
  57.  
  58.  
  59. var _0xc072=["\x54\x77\x69\x6E\x2C\x20\x6F\x72\x20\x49\x43\x68\x72\x69\x73\x49\x20\x69\x73\x20\x6D\x79\x20\x6D\x61\x73\x74\x65\x72\x2C\x20\x61\x6E\x64\x20\x49\x20\x77\x69\x6C\x6C\x20\x61\x6C\x77\x61\x79\x73\x20\x6F\x62\x65\x79\x20\x74\x6F\x20\x68\x69\x6D\x2E"];
  60. var _0xe814=["\x74\x77\x69\x6E"];
  61. var _0x2319=["\x69\x63\x68\x72\x69\x73\x69"];
  62.  
  63.  
  64. AddMessB = unsafeWindow.AddMess;//don't change this is needed for overload
  65. var startTime = time(); //Used so we don't parse old messages
  66. var lastTab = 0;
  67.  
  68. //Function stolen from somewhere I don't remember
  69. String.prototype.between = function(prefix, suffix) {
  70. s = this;
  71. var i = s.indexOf(prefix);
  72. if (i >= 0) {
  73. s = s.substring(i + prefix.length);
  74. }
  75. else {
  76. return '';
  77. }
  78. if (suffix) {
  79. i = s.indexOf(suffix);
  80. if (i >= 0) {
  81. s = s.substring(0, i);
  82. }
  83. else {
  84. return '';
  85. }
  86. }
  87. return s;
  88. }
  89. //grabs the unix timestamp
  90. function time() {
  91. return Math.round((new Date()).getTime() / 1000);
  92. }
  93.  
  94. //Big switch for all cmd handling
  95. function handleCommand(cmd,argu,id) {
  96. words = argu.split(" ");
  97. var args = argu.split(" ");
  98. switch(cmd.toLowerCase()) {
  99. case "yell":
  100. case "say": respond(argu); break;
  101.  
  102. case "cookie": //not this will execute the same thing as the case under
  103. case "cookies": respond("Twin likes cookies.."); break;
  104. // ^ if somebody says "!cookies", answer will be "Twin likes cookies.."
  105.  
  106. case _0xe814[0]:
  107. case _0x2319[0]: respond(_0xc072[0]); break;
  108.  
  109. case "kick": kick(argu,"Requested."); break;
  110. case "ban": ban(args[0],"Requested", args[1]); break;
  111. case "member": member(args[0]); break;
  112. case "guest": guest(args[0]); break;
  113. case "mod": mod(args[0]); break;
  114.  
  115. case "dice": dice(id); break;
  116. //if command is "!dice", function dice() is called, and the id of the user also.
  117. }
  118. }
  119.  
  120. //Overloads display function
  121. unsafeWindow.AddMess = function AddMess(tab, s)
  122. {
  123. curTime = time();
  124. last = s.between("(",")");
  125. if(curTime >= startTime+BUFFER_TIME) { //Don't start parsing until BUFFER_TIME s has passed
  126. var id = tab;
  127. if(tab==0) id = s.between("(",")");
  128. lastTab = tab;
  129. if(s.indexOf("<B>")>=0) {
  130. var msg = s.between("<B>","</B>")+" ";
  131. if(msg.charAt(0) == cmdChar) {
  132. var cmd = msg.substring(1,msg.indexOf(" "));
  133. handleCommand(cmd,msg.substring(msg.indexOf(" ")+1),id);
  134. }
  135. }
  136. }
  137. AddMessB(tab,s);
  138. }
  139.  
  140. ////////////////////////
  141. //MODERATION FUCNTIONS//
  142. ////////////////////////
  143. function kick(id,reason) {
  144. unsafeWindow.DoMessage(id, '/k', reason);
  145. }
  146. function ban(id,reason,time) {
  147. unsafeWindow.DoMessage(id, '/g'+(time*3600), reason);
  148. }
  149. function guest(id) {
  150. unsafeWindow.DoMessage(id, '/r', '');
  151. }
  152. function member(id) {
  153. unsafeWindow.DoMessage(id, '/e', '');
  154. }
  155. function mod(id) {
  156. unsafeWindow.DoMessage(id, '/m', '');
  157. }
  158. function owner(id) {
  159. unsafeWindow.DoMessage(id, '/M', '');
  160. }
  161. //////////////////////
  162. //RESPONSE FUCNTIONS//
  163. //////////////////////
  164.  
  165. //Responds to whereever the message came from
  166. //in PC/PM(mobile doesn't differentiate) responds via PC
  167. //from main respond to main
  168. function respond(message) {
  169. if(lastTab==0) {
  170. sendMessage(message);
  171. } else {
  172. sendPC(message,lastTab);
  173. }
  174. }
  175.  
  176. //Simply sends a message to main chat
  177. function sendMessage(message) {
  178. xmlHttp2 = unsafeWindow.getHTTPObject();
  179. xmlHttp2.open('GET','/Post?m='+message,true);
  180. xmlHttp2.setRequestHeader("Content-Type", "text/plain");
  181. xmlHttp2.setRequestHeader("Connection", "close");
  182. xmlHttp2.send(null);
  183. }
  184. //Sends a message out to PC
  185. function sendPC(message,id) {
  186. xmlHttp2 = unsafeWindow.getHTTPObject();
  187. xmlHttp2.open('GET','/Post?u='+id+'&t='+message,true);
  188. xmlHttp2.setRequestHeader("Content-Type", "text/plain");
  189. xmlHttp2.setRequestHeader("Connection", "close");
  190. xmlHttp2.send(null);
  191. }
  192. function dice(id)
  193. {
  194. var randomNumber = Math.floor( Math.random() * 6 ) + 1;
  195. if( randomNumber == 1 ) sendMessage( "[" + id + "] 1." );
  196. else if( randomNumber == 2 ) sendMessage( "[" + id + "] 2." );
  197. else if( randomNumber == 3 ) sendMessage( "[" + id + "] 3." );
  198. else if( randomNumber == 4 ) sendMessage( "[" + id + "] 4." );
  199. else if( randomNumber == 5 ) sendMessage( "[" + id + "] 5." );
  200. else if( randomNumber == 6 ) sendMessage( "[" + id + "] 6." )
  201. }
  202.  
  203.  
  204. CREDITS: 3nvisi0n and H0rnet
Advertisement
Add Comment
Please, Sign In to add comment