Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Custom commands PS!
- // @namespace customcommandsps
- // @description Utility userscript to add custom commands in PS! client
- // @include http://play.pokemonshowdown.com/
- // @include https://play.pokemonshowdown.com/
- // @include http://play.pokemonshowdown.com/*
- // @include https://play.pokemonshowdown.com/*
- // @include http://*.psim.us/
- // @include https://*.psim.us/
- // @include http://*.psim.us/*
- // @include https://*.psim.us/*
- // @version 1.0.3
- // @grant GM_xmlhttpRequest
- // @require https://unpkg.com/@pkmn/sets/build/production.min.js
- // ==/UserScript==
- console.log("TEST")
- var teams = {};
- teams['gen1ou'] = "https://drive.google.com/uc?id=1jOsfGOSacLKeK76ppB6yc4MUz5sN6RwZ";
- teams['gen2ou'] = "https://drive.google.com/uc?id=1teLltGkmVNpL_KQ45BePs_0jjkHwj0m1";
- teams['gen3ou'] = "https://drive.google.com/uc?id=1AUrmwku-O_fZzSVuP30kCY3QiR3FFr8w";
- teams['gen4ou'] = "https://drive.google.com/uc?id=1lawJs1LtxdfP10r5AbIarO0c3LMxTIfk";
- teams['gen5ou'] = "https://drive.google.com/uc?id=1ZDmnM60KXUHwKE2-LRARtNu0YdW3fWQa";
- teams['gen6ou'] = "https://drive.google.com/uc?id=12LaN-6Lfsbz35YZeKJ25RZNCWVGgKssk";
- teams['gen7ou'] = "https://drive.google.com/uc?id=1FK3xxHlSlE7vvOZN6y2-DRTbWIGsAQ6p";
- teams['gen8ou'] = "https://drive.google.com/uc?id=1recOD4JW8pYHIRNcKTswYguPevIFv9qw";
- var pack = "";
- function getRandom(min, max) {
- let random = Math.floor(Math.random() * max) + min;
- if (random % 2 !== 0) {
- if ((random + 1) > max)
- random--;
- else
- random++
- };
- return random;
- };
- window.addEventListener('load', function() {
- console.log("TEST2")
- ConsoleRoom.prototype.customCommands = {};
- ConsoleRoom.prototype.customCommands['rtb'] = function(Self, Tier) {
- GM_xmlhttpRequest({
- method : "GET",
- // from other domain than the @match one (.org / .com):
- url : teams[Tier],
- onload: function(response) {
- var myteams = response.responseText.split("===");
- var n = getRandom(2, myteams.length);
- var team = myteams[n];
- console.log("1)");
- console.log(team);
- //var team_members = team.replace(/^\s\s*/, '').replace(/\s\s*$/, '').split("\r\n\r\n");
- team = team.replace(/^\s\s*/, '').replace(/\s\s*$/, '')
- team = PokemonTeams.importTeam(team)
- pack = PokemonTeams.packTeam(team);
- console.log("2)");
- console.log(pack);
- }});
- app.send('/utm ' + pack)
- app.send('/battle! ' + Tier)
- };
- ConsoleRoom.prototype.parseCommandOrig = ConsoleRoom.prototype.parseCommand;
- ConsoleRoom.prototype.parseCommand = function(Text) {
- var cmd = '';
- var target = '';
- var noSpace = false;
- if (Text.substr(0, 2) !== '//' && Text.charAt(0) === '/') {
- var spaceIndex = Text.indexOf(' ');
- if (spaceIndex > 0) {
- cmd = Text.substr(1, spaceIndex - 1);
- console.log("//CMD");
- console.log(cmd);
- target = Text.substr(spaceIndex + 1);
- console.log("//TARGET");
- console.log(target);
- } else {
- console.log("//CMD");
- cmd = Text.substr(1);
- console.log(cmd)
- target = '';
- noSpace = true;
- }
- }
- if (this.customCommands[cmd.toLowerCase()]) return this.customCommands[cmd.toLowerCase()](this, target);
- return this.parseCommandOrig(Text);
- };
- });
Advertisement
Add Comment
Please, Sign In to add comment