Advertisement
Maxouille

Random Team Battle

May 19th, 2021 (edited)
346
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.65 KB | None | 0 0
  1. // ==UserScript==
  2. // @name RandomTeamBattle
  3. // @namespace customcommandsps
  4. // @description Utility userscript to add custom commands in PS! client
  5. // @include http://play.pokemonshowdown.com/
  6. // @include https://play.pokemonshowdown.com/
  7. // @include http://play.pokemonshowdown.com/*
  8. // @include https://play.pokemonshowdown.com/*
  9. // @include http://*.psim.us/
  10. // @include https://*.psim.us/
  11. // @include http://*.psim.us/*
  12. // @include https://*.psim.us/*
  13. // @version 1.0.3
  14. // @grant GM_xmlhttpRequest
  15. // @require https://unpkg.com/@pkmn/sets/build/production.min.js
  16. // ==/UserScript==
  17.  
  18. var teams = {};
  19. //OU
  20. teams['gen1ou'] = "https://drive.google.com/uc?id=1jOsfGOSacLKeK76ppB6yc4MUz5sN6RwZ";
  21. teams['gen2ou'] = "https://drive.google.com/uc?id=1teLltGkmVNpL_KQ45BePs_0jjkHwj0m1";
  22. teams['gen3ou'] = "https://drive.google.com/uc?id=1AUrmwku-O_fZzSVuP30kCY3QiR3FFr8w";
  23. teams['gen4ou'] = "https://drive.google.com/uc?id=1lawJs1LtxdfP10r5AbIarO0c3LMxTIfk";
  24. teams['gen5ou'] = "https://drive.google.com/uc?id=1ZDmnM60KXUHwKE2-LRARtNu0YdW3fWQa";
  25. teams['gen6ou'] = "https://drive.google.com/uc?id=12LaN-6Lfsbz35YZeKJ25RZNCWVGgKssk";
  26. teams['gen7ou'] = "https://drive.google.com/uc?id=1FK3xxHlSlE7vvOZN6y2-DRTbWIGsAQ6p";
  27. teams['gen8ou'] = "https://drive.google.com/uc?id=1recOD4JW8pYHIRNcKTswYguPevIFv9qw";
  28. //RBY
  29. teams['gen1ubers'] = "https://drive.google.com/uc?id=14PJVqKZBjCy6mPkPytlNEoFilzpBcVuf";
  30. teams['gen1uu'] = "https://drive.google.com/uc?id=1BM_16iwFKTbgXZ4X3XUBGOwUoOcVYnw6";
  31. teams['gen1nu'] = "https://drive.google.com/uc?id=1SLOKA1zyr0c2RcYTDld_PxRplFboJtI6";
  32. teams['gen1lc'] = "https://drive.google.com/uc?id=1Kz9t6GBf5HJx5upxUwsZleogTtewH7xv";
  33. //GSC
  34. teams['gen2nu'] = "https://drive.google.com/uc?id=13yehX4SE9jLzO3FO4RDFi5ChDb5p12F-";
  35. teams['gen2pu'] = "https://drive.google.com/uc?id=1Ntp_3ACulc11KQTL5oRbw49T2Hqut6Tb";
  36. teams['gen2zu'] = "https://drive.google.com/uc?id=11GgjSBIzdcWO1Ea-FMZLWghIAAKNtetr";
  37. teams['gen2ubers'] = "https://drive.google.com/uc?id=1zE1bnR18te74Gn1ULCmtGyaOsjiz9rkw";
  38. teams['gen2uu'] = "https://drive.google.com/uc?id=1uesjTBh--PZSk1MZ1MM9oC9Fi4hTjC8C";
  39. //ADV
  40. teams['gen3ubers'] = "https://drive.google.com/uc?id=16_EO2pK60pc5SqPzbuzm7JU5o6VUU-Zz";
  41. teams['gen3uu'] = "https://drive.google.com/uc?id=1bZk5QnxxvrgjJG7sFvVz56c-Z-4-xMgp";
  42. teams['gen3nu'] = "https://drive.google.com/uc?id=1TVrgYER8XkJ8abwz6f0-ZDI19KiJYdmG";
  43. teams['gen3zu'] = "https://drive.google.com/uc?id=1oQ3NBROdf9yR_SU2AN9CfVLDPGmmaujp";
  44. //DPP
  45. teams['gen4ubers'] = "https://drive.google.com/uc?id=1yYWYbjxKse6-Xe-RbnhN2p69Bwkrp2Ie";
  46. teams['gen4uu'] = "https://drive.google.com/uc?id=1NAsq39JbTaSihDXZ4wUV48YTB8kybpYh";
  47. teams['gen4nu'] = "https://drive.google.com/uc?id=1vpU4PaPsGD9NATQwiodji22A7uIHavNX";
  48. teams['gen4pu'] = "https://drive.google.com/uc?id=128Iqkq7LtTp1T2EPLpKo6sFZAo2devqW";
  49. teams['gen4zu'] = "https://drive.google.com/uc?id=1nURG41VPpSpGXIILE0ppwTqIALAU4qME";
  50. teams['gen4lc'] = "https://drive.google.com/uc?id=1Mhm-i_veMMJAWMupy03ivxYCECKL-J8N";
  51. //BW2
  52. teams['gen5doublesou'] = "https://drive.google.com/uc?id=1bFX0unqTqGpAGEoHMC7nSGp6sr56YBv3";
  53. teams['gen5ubers'] = "https://drive.google.com/uc?id=1LG7uWf8Nn3IF8dhoMvQs4L5TjqUVYcQ1";
  54. teams['gen5uu'] = "https://drive.google.com/uc?id=1Rr149h7Y5xv0cvZkvZWV2ArYjy0oGm8I";
  55. teams['gen5ru'] = "https://drive.google.com/uc?id=1fVnQhIYvP2jT3vx3_iAlL2tLiOyu3EBz";
  56. teams['gen5nu'] = "https://drive.google.com/uc?id=1BQw3prOfU5p2vnlrRfiT-kfnfDgXdmHy";
  57. teams['gen5pu'] = "https://drive.google.com/uc?id=17X1ywIONnk7bgJmiXpDmremIYe4KQv5s";
  58. teams['gen5lc'] = "https://drive.google.com/uc?id=1CZweSHde9V0Ii9Sw8HRhpDUfjgCSlTuF";
  59. //ORAS
  60. teams['gen6anythinggoes'] = "https://drive.google.com/uc?id=1ig0gURP30ZQTLMBX22zorXaM3h_2e4EA";
  61. teams['gen6ubers'] = "https://drive.google.com/uc?id=1q0cd1cx1a7Kt30doOTbgDv5HDILocA_N";
  62. teams['gen6uu'] = "https://drive.google.com/uc?id=1HwBnBRUgW9LuNOT_d0YRdbGf4d93Ggb0";
  63. teams['gen6ru'] = "https://drive.google.com/uc?id=154TU1TmlIujhb2ucTtt_qGWLjiZqhsv5";
  64. teams['gen6nu'] = "https://drive.google.com/uc?id=1BdlohACiABuH98_uCXyTmPbj9sOlz7-s";
  65. teams['gen6pu'] = "https://drive.google.com/uc?id=1OzJsMkvW6fCPZvP13COUZBSDoGLdtOev";
  66. teams['gen6zu'] = "https://drive.google.com/uc?id=1rLDhA84F0EQbyca_X-hQXM3JspwSfyoI";
  67. teams['gen6lc'] = "https://drive.google.com/uc?id=1qCSKcKgOyM_aWtVmEBKc3NnFA0r7TE1o";
  68. teams['gen6monotype'] = "https://drive.google.com/uc?id=1d3m2JANGtqHTsWCNIUFVrKw4-cmBNBW7";
  69. teams['gen6doublesou'] = "https://drive.google.com/uc?id=1vKR_-1xjknLiAFcwmD_ahJKjgNjB6fki";
  70. //USUM
  71. teams['gen7ag'] = "https://drive.google.com/uc?id=1pdAeph8vFhRM7oPobQvdg6L4w6xqMybM";
  72. teams['gen7cap'] = "https://drive.google.com/uc?id=1I2kwmLV_1KTOfUWhhC6tn2KF1uY3PkHf";
  73. teams['gen7doublesou'] = "https://drive.google.com/uc?id=1zZDMpjCkY5Nm9sBc7h8jVXFvjOESGj1b";
  74. teams['gen7doublesubers'] = "https://drive.google.com/uc?id=1PCxqnrrL_wYBZExK4KTGfX5-t29zjx7R";
  75. teams['gen7lc'] = "https://drive.google.com/uc?id=1X_uv4CbXkjh4L487Vfk9qNVf14cUZytw";
  76. teams['gen7lgpeou'] = "https://drive.google.com/uc?id=1r8sB2GBEP3_bYU8hNUxIM30HjhDIqM6h";
  77. teams['gen7monotype'] = "https://drive.google.com/uc?id=1xECWHZ0-Guk9WDmJ83RrPfJV1T-yFRpJ";
  78. teams['gen7nfe'] = "https://drive.google.com/uc?id=1a1aDXNUuP1eTB5lN6_Qh_Tzj0kECwIzN";
  79. teams['gen7nu'] = "https://drive.google.com/uc?id=1MOchNy2-uXlxtIvLR_1Vh7OEWdAC4iVm";
  80. teams['gen7pu'] = "https://drive.google.com/uc?id=1moZlTGanvLjPivbF556OfNAUJewFh3M4";
  81. teams['gen7ph'] = "https://drive.google.com/uc?id=1djiauplDQwp3gnwCBGi0bQUi5FcWP-NV";
  82. teams['gen7ru'] = "https://drive.google.com/uc?id=1KZGK1PfKuKgJ3o8T0wB8PBFeqKcCLSj5";
  83. teams['gen7ubers'] = "https://drive.google.com/uc?id=1QXfXnG9PCrtG7I5znlMYzn74cQ07Vt0P";
  84. teams['gen7uu'] = "https://drive.google.com/uc?id=1qewEegDckuR80gILgqQwB9TpdOI4L2gq";
  85. teams['gen7zu'] = "https://drive.google.com/uc?id=1Olbfq8NubVRY_mtuvrtab7fSV9ofj6MI";
  86. teams['gen7bss'] = "https://drive.google.com/uc?id=1mILVgye7JgqZtwHNYAHS3jEdWoHppEeg";
  87. //SS
  88. teams['dou'] = "https://drive.google.com/uc?id=1cCAYdpBNSJfoOSFqufT_7IdATqooTBWb";
  89. teams['natdexmonotype'] = "https://drive.google.com/uc?id=1OtIs8G9RHrgAxB9pCR6A7-XLhX49ybWA";
  90. teams['gen8natdexuu'] = "https://drive.google.com/uc?id=1ZtDMfIycz0HCmKrIDZuhD3ZMxTsMa7Ix";
  91. teams['gen8bss'] = "https://drive.google.com/uc?id=12wQxFADIpbsj3N1puYlzWQKzAk0Wyt56";
  92. teams['duu'] = "https://drive.google.com/uc?id=1W0o3boP7qOtSv3XD9pLFHYx-Owp0VP8O";
  93. teams['lc'] = "https://drive.google.com/uc?id=1VoJReISY5tjRkSgM2phFuuPMKQxPZRXe";
  94. teams['monotype'] = "https://drive.google.com/uc?id=1BfGKBANTg6-2liEovm85c5UsCLK1iv46";
  95. teams['natdex'] = "https://drive.google.com/uc?id=1iDXFvSKNLuzd1YR0mmEKDSebaaBSDfVw";
  96. teams['natdexag'] = "https://drive.google.com/uc?id=1vAWX6lRPjCX2GO83D3kQ2F6GBLDfLjiX";
  97. teams['nfe'] = "https://drive.google.com/uc?id=1RWezbtM-rdYcn32L1LYnlF2UTpKO-Wnq";
  98. teams['nu'] = "https://drive.google.com/uc?id=1CDOE7DFTkxUZqwlKCHYON9aMyBBl8GCr";
  99. teams['pu'] = "https://drive.google.com/uc?id=1tPXHEmUlZ2U0VFNTKx_yWmsbExHqyeWH";
  100. teams['ru'] = "https://drive.google.com/uc?id=10TT7A65p60w0nNKQvrMdbJZYsLcNP6mi";
  101. teams['ubers'] = "https://drive.google.com/uc?id=10itsyg3eUzFkY2dlCMk34USlggcDvl40";
  102. teams['uu'] = "https://drive.google.com/uc?id=1FjxGDoaYRNF0dQN7eg_Bpwvi2f2gS_t5";
  103. teams['zu'] = "https://drive.google.com/uc?id=1UWaUWR6ESYcMFg6WQvJdYwapEIKPkWTx";
  104. teams['gen8bdspou'] = "https://drive.google.com/uc?id=1Pt_Mev8VWqwYPQpWrMQdWSzeJfZ8jwbA";
  105. //OM
  106. teams['aaa'] = "https://drive.google.com/uc?id=1NuiXcOjJ7f4RCQ7vBCXL3X_6qo5KFb-3";
  107. teams['bh'] = "https://drive.google.com/uc?id=1eemY8bv7ZHqQzdg7uGBTkEBfUyG8_xRK";
  108. teams['camomons'] = "https://drive.google.com/uc?id=19LiUeolOSbuwOIDrKg14JoJldFU9DxD-";
  109. teams['gen8mnm'] = "https://drive.google.com/uc?id=101756U9tIYkemXRiDgKjvje5YZl8i7X_";
  110. teams['natdexbh'] = "https://drive.google.com/uc?id=13hCSSkS-XX7kjRvZeiHZ6vA-KX0Ydmfs";
  111. teams['stabmons'] = "https://drive.google.com/uc?id=1C_qDplncOT7QvrN-ISIn6DZ7nASaDaTD";
  112. teams['gen7abilitiesasmoves'] = "https://drive.google.com/uc?id=1jKz5WC-iWtN4jJjyu1UN36m68CwOwTns";
  113. teams['gen7anythinggoesmixandmega'] = "https://drive.google.com/uc?id=18buudvGsBdeKszsnifRAWjvbwofi9NjI";
  114. teams['gen7aaa'] = "https://drive.google.com/uc?id=1r_-OcHwpFJDHKmAdRV9dRLNIXzInbsNo";
  115. teams['gen7bh'] = "https://drive.google.com/uc?id=1rc1o_wos0rvfSrZg3Myg1Tmmbyy-IEJX";
  116. teams['gen7camomons'] = "https://drive.google.com/uc?id=1jRt1sE1mgSlg_VqCluAqAjXo3MPR2yRK";
  117. teams['gen7crossevolution'] = "https://drive.google.com/uc?id=1hlmV56TMXZPOHTTIOiG2bVVzygV3LDYh";
  118. teams['gen7followtheleader'] = "https://drive.google.com/uc?id=1UdjbjpCJJPKwBCMhs8x52lziwTubKK1f";
  119. teams['gen7fortemons'] = "https://drive.google.com/uc?id=1P1X-M4c0LhBbPUkgJhb3dDrZ8JiO_rov";
  120. teams['gen7godsandfollowers'] = "https://drive.google.com/uc?id=1PDCzTfedn1JiOX1ZZphk-P9KGPIS55cN";
  121. teams['gen7inheritance'] = "https://drive.google.com/uc?id=11_PI2TVBbkDOrrRWWMNt07QrREpNN2LI";
  122. teams['gen7linked'] = "https://drive.google.com/uc?id=1rQziu2qL8yZY9H6S7pYz8Ei6VVmdSa6d";
  123. teams['gen7megamons'] = "https://drive.google.com/uc?id=1L3rrk0i36bilktcfPPYY_vp7XkYy3vek";
  124. teams['gen7mergemons'] = "https://drive.google.com/uc?id=1pTwiTbszU90swX-BMMAikVZnK9kk9vdK";
  125. teams['gen7mnm'] = "https://drive.google.com/uc?id=1uf7ez0Rc61dexAZczuJMOUp10G7cC7AL";
  126. teams['gen7natureswap'] = "https://drive.google.com/uc?id=1T-CF41qdsJeXS8vltVgo-mf1qsOQ1Ftt";
  127. teams['gen7partnersincrime'] = "https://drive.google.com/uc?id=1x55_oxLKnBtDEVUi5F1hAW099IdueHgL";
  128. teams['gen7stabmons'] = "https://drive.google.com/uc?id=1jNhuJmp2Z2CcHQa4ihUDfJk3IHc_lQGC";
  129. teams['gen7ultimatez'] = "https://drive.google.com/uc?id=1WZxmp7PWmEajdfybiOALGiA-2ufHeZqb";
  130. teams['gen7trademarked'] = "https://drive.google.com/uc?id=1fduf_4v15QAnPs16WV_izmhGiNAz2YGi";
  131. //1v1&2v2
  132. teams['gen31v1'] = "https://drive.google.com/uc?id=1VUkMpS1_ebVCnTBKaokVD1xSK2IzJkVd";
  133. teams['gen41v1'] = "https://drive.google.com/uc?id=1euYzaTQsErTWWq97mFMifNsIAtruryhv";
  134. teams['gen51v1'] = "https://drive.google.com/uc?id=1n-ryAd2ZFlgtU_3beNn9y4RMnRTi-FxI";
  135. teams['gen52v2'] = "https://drive.google.com/uc?id=1Zhfzmdi5s3OMbNqsvHMibgbDxns3iAW_";
  136. teams['gen61v1'] = "https://drive.google.com/uc?id=1oHpuqst4u-V-iadDtpKWOqbzP2vmA6ZJ";
  137. teams['gen71v1'] = "https://drive.google.com/uc?id=1iNNxLj8VgI9UL95A9sYDIO71TR-9bucC";
  138. teams['gen72v2'] = "https://drive.google.com/uc?id=1lW34-E3mumdMrDaA6efLfF2PrVh9ZzSn";
  139. teams['1v1'] = "https://drive.google.com/uc?id=1KW3qNHO1B1S4BfJFhI0mKTO-ggNw_A7I";
  140. teams['2v2'] = "https://drive.google.com/uc?id=19m15-Z-xQW78ypm2LHmehYf1C1QM5yKq";
  141.  
  142. var pack = "";
  143.  
  144. function getRandom(min, max) {
  145. let random = (Math.floor(Math.random() * max/2)+ min/2) * 2;
  146. return random;
  147. };
  148. window.addEventListener('load', function() {
  149. console.log("TEST");
  150. app.send('/code RANDOMIZABLE FORMATS: \n' + Object.keys(teams));
  151. ConsoleRoom.prototype.customCommands = {};
  152. ConsoleRoom.prototype.customCommands['rtb'] = function(Self, Tier) {
  153. console.log(Tier)
  154. GM_xmlhttpRequest({
  155. method : "GET",
  156. // from other domain than the @match one (.org / .com):
  157. url : teams[Tier],
  158. onload: function(response) {
  159. var myteams = response.responseText.split("===");
  160. var n = getRandom(2, myteams.length);
  161. var team = myteams[n];
  162. team = team.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
  163. team = PokemonTeams.importTeam(team);
  164. //app.curRoom.send("/clear");
  165. app.curRoom.send("/code " + team);
  166. pack = PokemonTeams.packTeam(team);
  167. console.log(pack);
  168. }})
  169. app.send('/utm ' + pack + '\n' + '/battle! ' + Tier);
  170. };
  171. ConsoleRoom.prototype.customCommands['rtc'] = function(Self, Tier, User) {
  172. GM_xmlhttpRequest({
  173. method : "GET",
  174. // from other domain than the @match one (.org / .com):
  175. url : teams[Tier],
  176. onload: function(response) {
  177. var myteams = response.responseText.split("===");
  178. var n = getRandom(2, myteams.length);
  179. var team = myteams[n];
  180. team = team.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
  181. team = PokemonTeams.importTeam(team);
  182. app.curRoom.send("/code " + team);
  183. pack = PokemonTeams.packTeam(team);
  184. console.log(pack);
  185. }});
  186. app.send('/utm ' + pack);
  187. app.send('/challenge ' + User + ", " + Tier);
  188. };
  189. ConsoleRoom.prototype.parseCommandOrig = ConsoleRoom.prototype.parseCommand;
  190. ConsoleRoom.prototype.parseCommand = function(Text) {
  191. var cmd = '';
  192. var target = '';
  193. var user = '';
  194. var noSpace = false;
  195. if (Text.substr(0, 2) !== '//' && Text.substr(0, 3) === '/rt') {
  196. app.send('/utm');
  197. var spaceIndex = Text.indexOf(' ');
  198. var commaIndex = Text.indexOf(',');
  199. if (commaIndex > 0) {
  200. Text = Text.split(",")
  201. cmd = Text[0].substr(1, spaceIndex - 1);
  202. console.log("//CMD");
  203. console.log(cmd);
  204. target = Text[0].substr(spaceIndex + 1).toLowerCase();
  205. console.log("//TARGET");
  206. console.log(target);
  207. user = Text[1]
  208. console.log("//user");
  209. console.log(user);
  210. }
  211. else if (spaceIndex > 0) {
  212. cmd = Text.substr(1, spaceIndex - 1);
  213. console.log("//CMD");
  214. console.log(cmd);
  215. target = Text.substr(spaceIndex + 1).toLowerCase();
  216. console.log("//TARGET");
  217. console.log(target);
  218. } else {
  219. console.log("//CMD");
  220. cmd = Text.substr(1);
  221. console.log(cmd)
  222. target = '';
  223. noSpace = true;
  224. }
  225. }
  226. if (this.customCommands[cmd.toLowerCase()]) return this.customCommands[cmd.toLowerCase()](this, target, user);
  227. return this.parseCommandOrig(Text);
  228. };
  229. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement