Maxouille

Untitled

May 11th, 2021
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.50 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Custom commands PS!
  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. console.log("TEST")
  19.  
  20. var teams = {};
  21. teams['gen1ou'] = "https://drive.google.com/uc?id=1jOsfGOSacLKeK76ppB6yc4MUz5sN6RwZ";
  22. teams['gen2ou'] = "https://drive.google.com/uc?id=1teLltGkmVNpL_KQ45BePs_0jjkHwj0m1";
  23. teams['gen3ou'] = "https://drive.google.com/uc?id=1AUrmwku-O_fZzSVuP30kCY3QiR3FFr8w";
  24. teams['gen4ou'] = "https://drive.google.com/uc?id=1lawJs1LtxdfP10r5AbIarO0c3LMxTIfk";
  25. teams['gen5ou'] = "https://drive.google.com/uc?id=1ZDmnM60KXUHwKE2-LRARtNu0YdW3fWQa";
  26. teams['gen6ou'] = "https://drive.google.com/uc?id=12LaN-6Lfsbz35YZeKJ25RZNCWVGgKssk";
  27. teams['gen7ou'] = "https://drive.google.com/uc?id=1FK3xxHlSlE7vvOZN6y2-DRTbWIGsAQ6p";
  28. teams['gen8ou'] = "https://drive.google.com/uc?id=1recOD4JW8pYHIRNcKTswYguPevIFv9qw";
  29.  
  30. var pack = "";
  31.  
  32. function getRandom(min, max) {
  33. let random = Math.floor(Math.random() * max) + min;
  34. if (random % 2 !== 0) {
  35. if ((random + 1) > max)
  36. random--;
  37. else
  38. random++
  39. };
  40.  
  41. return random;
  42. };
  43.  
  44. window.addEventListener('load', function() {
  45. console.log("TEST2")
  46. ConsoleRoom.prototype.customCommands = {};
  47. ConsoleRoom.prototype.customCommands['rtb'] = function(Self, Tier) {
  48. GM_xmlhttpRequest({
  49. method : "GET",
  50. // from other domain than the @match one (.org / .com):
  51. url : teams[Tier],
  52. onload: function(response) {
  53. var myteams = response.responseText.split("===");
  54. var n = getRandom(2, myteams.length);
  55. var team = myteams[n];
  56. console.log("1)");
  57. console.log(team);
  58. //var team_members = team.replace(/^\s\s*/, '').replace(/\s\s*$/, '').split("\r\n\r\n");
  59. team = team.replace(/^\s\s*/, '').replace(/\s\s*$/, '')
  60. team = PokemonTeams.importTeam(team)
  61. pack = PokemonTeams.packTeam(team);
  62. console.log("2)");
  63. console.log(pack);
  64. }});
  65. app.send('/utm ' + pack)
  66. app.send('/battle! ' + Tier)
  67. };
  68. ConsoleRoom.prototype.parseCommandOrig = ConsoleRoom.prototype.parseCommand;
  69. ConsoleRoom.prototype.parseCommand = function(Text) {
  70. var cmd = '';
  71. var target = '';
  72. var noSpace = false;
  73. if (Text.substr(0, 2) !== '//' && Text.charAt(0) === '/') {
  74. var spaceIndex = Text.indexOf(' ');
  75. if (spaceIndex > 0) {
  76. cmd = Text.substr(1, spaceIndex - 1);
  77. console.log("//CMD");
  78. console.log(cmd);
  79. target = Text.substr(spaceIndex + 1);
  80. console.log("//TARGET");
  81. console.log(target);
  82. } else {
  83. console.log("//CMD");
  84. cmd = Text.substr(1);
  85. console.log(cmd)
  86. target = '';
  87. noSpace = true;
  88. }
  89. }
  90. if (this.customCommands[cmd.toLowerCase()]) return this.customCommands[cmd.toLowerCase()](this, target);
  91. return this.parseCommandOrig(Text);
  92. };
  93. });
Advertisement
Add Comment
Please, Sign In to add comment