🏠 Home 

GymHuntr

This makes it easier to find what you're looking for, whether you're searching for which gyms particular people are in, or just checking on the state of a gym. In the pull-out menu on the left, you can list your friends and nemeses: these will be highlighted on the map and in the gym popups. Gym popups show all Pokémon in the gym at a glance - no more sideways scrolling.


Install this script?
// ==UserScript==
// @name         GymHuntr
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  This makes it easier to find what you're looking for, whether you're searching for which gyms particular people are in, or just checking on the state of a gym. In the pull-out menu on the left, you can list your friends and nemeses: these will be highlighted on the map and in the gym popups. Gym popups show all Pokémon in the gym at a glance - no more sideways scrolling.
// @author       Tim Jeanes
// @match        https://gymhuntr.com/*
// @grant        none
// ==/UserScript==
(function() {
'use strict';
var numByName = {
"Bulbasaur": 1, "Ivysaur": 2, "Venusaur": 3, "Charmander": 4, "Charmeleon": 5, "Charizard": 6, "Squirtle": 7, "Wartortle": 8, "Blastoise": 9, "Caterpie": 10, "Metapod": 11, "Butterfree": 12, "Weedle": 13, "Kakuna": 14, "Beedrill": 15, "Pidgey": 16, "Pidgeotto": 17, "Pidgeot": 18, "Rattata": 19, "Raticate": 20, "Spearow": 21, "Fearow": 22, "Ekans": 23, "Arbok": 24, "Pikachu": 25, "Raichu": 26, "Sandshrew": 27, "Sandslash": 28, "Nidoran♀": 29, "Nidoran ♀": 29, "Nidoran F": 29, "Nidoran (F)": 29, "Nidorina": 30, "Nidoqueen": 31, "Nidoran♂": 32, "Nidoran ♂": 32, "Nidoran M": 32, "Nidoran (M)": 32, "Nidorino": 33, "Nidoking": 34, "Clefairy": 35, "Clefable": 36, "Vulpix": 37, "Ninetales": 38, "Jigglypuff": 39, "Wigglytuff": 40, "Zubat": 41, "Golbat": 42, "Oddish": 43, "Gloom": 44, "Vileplume": 45, "Paras": 46, "Parasect": 47, "Venonat": 48, "Venomoth": 49, "Diglett": 50, "Dugtrio": 51, "Meowth": 52, "Persian": 53, "Psyduck": 54, "Golduck": 55, "Mankey": 56, "Primeape": 57, "Growlithe": 58, "Arcanine": 59, "Poliwag": 60, "Poliwhirl": 61, "Poliwrath": 62, "Abra": 63, "Kadabra": 64, "Alakazam": 65, "Machop": 66, "Machoke": 67, "Machamp": 68, "Bellsprout": 69, "Weepinbell": 70, "Victreebel": 71, "Tentacool": 72, "Tentacruel": 73, "Geodude": 74, "Graveler": 75, "Golem": 76, "Ponyta": 77, "Rapidash": 78, "Slowpoke": 79, "Slowbro": 80, "Magnemite": 81, "Magneton": 82, "Farfetch'd": 83, "Doduo": 84, "Dodrio": 85, "Seel": 86, "Dewgong": 87, "Grimer": 88, "Muk": 89, "Shellder": 90, "Cloyster": 91, "Gastly": 92, "Haunter": 93, "Gengar": 94, "Onix": 95, "Drowzee": 96, "Hypno": 97, "Krabby": 98, "Kingler": 99, "Voltorb": 100,
"Electrode": 101, "Exeggcute": 102, "Exeggutor": 103, "Cubone": 104, "Marowak": 105, "Hitmonlee": 106, "Hitmonchan": 107, "Lickitung": 108, "Koffing": 109, "Weezing": 110, "Rhyhorn": 111, "Rhydon": 112, "Chansey": 113, "Tangela": 114, "Kangaskhan": 115, "Horsea": 116, "Seadra": 117, "Goldeen": 118, "Seaking": 119, "Staryu": 120, "Starmie": 121, "Mr. Mime": 122, "Scyther": 123, "Jynx": 124, "Electabuzz": 125, "Magmar": 126, "Pinsir": 127, "Tauros": 128, "Magikarp": 129, "Gyarados": 130, "Lapras": 131, "Ditto": 132, "Eevee": 133, "Vaporeon": 134, "Jolteon": 135, "Flareon": 136, "Porygon": 137, "Omanyte": 138, "Omastar": 139, "Kabuto": 140, "Kabutops": 141, "Aerodactyl": 142, "Snorlax": 143, "Articuno": 144, "Zapdos": 145, "Moltres": 146, "Dratini": 147, "Dragonair": 148, "Dragonite": 149, "Mewtwo": 150, "Mew": 151, "Chikorita": 152, "Bayleef": 153, "Meganium": 154, "Cyndaquil": 155, "Quilava": 156, "Typhlosion": 157, "Totodile": 158, "Croconaw": 159, "Feraligatr": 160, "Sentret": 161, "Furret": 162, "Hoothoot": 163, "Noctowl": 164, "Ledyba": 165, "Ledian": 166, "Spinarak": 167, "Ariados": 168, "Crobat": 169, "Chinchou": 170, "Lanturn": 171, "Pichu": 172, "Cleffa": 173, "Igglybuff": 174, "Togepi": 175, "Togetic": 176, "Natu": 177, "Xatu": 178, "Mareep": 179, "Flaaffy": 180, "Ampharos": 181, "Bellossom": 182, "Marill": 183, "Azumarill": 184, "Sudowoodo": 185, "Politoed": 186, "Hoppip": 187, "Skiploom": 188, "Jumpluff": 189, "Aipom": 190, "Sunkern": 191, "Sunflora": 192, "Yanma": 193, "Wooper": 194, "Quagsire": 195, "Espeon": 196, "Umbreon": 197, "Murkrow": 198, "Slowking": 199, "Misdreavus": 200,
"Unown": 201, "Wobbuffet": 202, "Girafarig": 203, "Pineco": 204, "Forretress": 205, "Dunsparce": 206, "Gligar": 207, "Steelix": 208, "Snubbull": 209, "Granbull": 210, "Qwilfish": 211, "Scizor": 212, "Shuckle": 213, "Heracross": 214, "Sneasel": 215, "Teddiursa": 216, "Ursaring": 217, "Slugma": 218, "Magcargo": 219, "Swinub": 220, "Piloswine": 221, "Corsola": 222, "Remoraid": 223, "Octillery": 224, "Delibird": 225, "Mantine": 226, "Skarmory": 227, "Houndour": 228, "Houndoom": 229, "Kingdra": 230, "Phanpy": 231, "Donphan": 232, "Porygon2": 233, "Stantler": 234, "Smeargle": 235, "Tyrogue": 236, "Hitmontop": 237, "Smoochum": 238, "Elekid": 239, "Magby": 240, "Mil####": 241, "Blissey": 242, "Raikou": 243, "Entei": 244, "Suicune": 245, "Larvitar": 246, "Pupitar": 247, "Tyranitar": 248, "Lugia": 249, "Ho-oh": 250, "Celebi": 251, "Treecko": 252, "Grovyle": 253, "Sceptile": 254, "Torchic": 255, "Combusken": 256, "Blaziken": 257, "Mudkip": 258, "Marshtomp": 259, "Swampert": 260, "Poochyena": 261, "Mightyena": 262, "Zigzagoon": 263, "Linoone": 264, "Wurmple": 265, "Silcoon": 266, "Beautifly": 267, "Cascoon": 268, "Dustox": 269, "Lotad": 270, "Lombre": 271, "Ludicolo": 272, "Seedot": 273, "Nuzleaf": 274, "Shiftry": 275, "Taillow": 276, "Swellow": 277, "Wingull": 278, "Pelipper": 279, "Ralts": 280, "Kirlia": 281, "Gardevoir": 282, "Surskit": 283, "Masquerain": 284, "Shroomish": 285, "Breloom": 286, "Slakoth": 287, "Vigoroth": 288, "Slaking": 289, "Nincada": 290, "Ninjask": 291, "Shedinja": 292, "Whismur": 293, "Loudred": 294, "Exploud": 295, "Makuhita": 296, "Hariyama": 297, "Azurill": 298, "Nosepass": 299, "Skitty": 300,
"Delcatty": 301, "Sableye": 302, "Mawile": 303, "Aron": 304, "Lairon": 305, "Aggron": 306, "Meditite": 307, "Medicham": 308, "Electrike": 309, "Manectric": 310, "Plusle": 311, "Minun": 312, "Volbeat": 313, "Illumise": 314, "Roselia": 315, "Gulpin": 316, "Swalot": 317, "Carvanha": 318, "Sharpedo": 319, "Wailmer": 320, "Wailord": 321, "Numel": 322, "Camerupt": 323, "Torkoal": 324, "Spoink": 325, "Grumpig": 326, "Spinda": 327, "Trapinch": 328, "Vibrava": 329, "Flygon": 330, "Cacnea": 331, "Cacturne": 332, "Swablu": 333, "Altaria": 334, "Zangoose": 335, "Seviper": 336, "Lunatone": 337, "Solrock": 338, "Barboach": 339, "Whiscash": 340, "Corphish": 341, "Crawdaunt": 342, "Baltoy": 343, "Claydol": 344, "Lileep": 345, "Cradily": 346, "Anorith": 347, "Armaldo": 348, "Feebas": 349, "Milotic": 350, "Castform": 351, "Kecleon": 352, "Shuppet": 353, "Banette": 354, "Duskull": 355, "Dusclops": 356, "Tropius": 357, "Chimecho": 358, "Absol": 359, "Wynaut": 360, "Snorunt": 361, "Glalie": 362, "Spheal": 363, "Sealeo": 364, "Walrein": 365, "Clamperl": 366, "Huntail": 367, "Gorebyss": 368, "Relicanth": 369, "Luvdisc": 370, "Bagon": 371, "Shelgon": 372, "Salamence": 373, "Beldum": 374, "Metang": 375, "Metagross": 376, "Regirock": 377, "Regice": 378, "Registeel": 379, "Latias": 380, "Latios": 381, "Kyogre": 382, "Groudon": 383, "Rayquaza": 384, "Jirachi": 385, "Deoxys (N)": 386, "Deoxys (A)": 386.1, "Deoxys (D)": 386.2, "Deoxys (S)": 386.3, "Turtwig": 387, "Grotle": 388, "Torterra": 389, "Chimchar": 390, "Monferno": 391, "Infernape": 392, "Piplup": 393, "Prinplup": 394, "Empoleon": 395, "Starly": 396, "Staravia": 397, "Staraptor": 398, "Bidoof": 399, "Bibarel": 400,
"Kricketot": 401, "Kricketune": 402, "Shinx": 403, "Luxio": 404, "Luxray": 405, "Budew": 406, "Roserade": 407, "Cranidos": 408, "Rampardos": 409, "Shieldon": 410, "Bastiodon": 411, "Burmy": 412, "Wormadam (P)": 413, "Wormadam (S)": 413.1, "Wormadam (T)": 413.2, "Mothim": 414, "Combee": 415, "Vespiquen": 416, "Pachirisu": 417, "Buizel": 418, "Floatzel": 419, "Cherubi": 420, "Cherrim": 421, "Shellos": 422, "Gastrodon": 423, "Ambipom": 424, "Drifloon": 425, "Drifblim": 426, "Buneary": 427, "Lopunny": 428, "Mismagius": 429, "Honchkrow": 430, "Glameow": 431, "Purugly": 432, "Chingling": 433, "Stunky": 434, "Skun####": 435, "Bronzor": 436, "Bronzong": 437, "Bonsly": 438, "Mime Jr.": 439, "Happiny": 440, "Chatot": 441, "Spiritomb": 442, "Gible": 443, "Gabite": 444, "Garchomp": 445, "Munchlax": 446, "Riolu": 447, "Lucario": 448, "Hippopotas": 449, "Hippowdon": 450, "Skorupi": 451, "Drapion": 452, "Croagunk": 453, "Toxicroak": 454, "Carnivine": 455, "Finneon": 456, "Lumineon": 457, "Mantyke": 458, "Snover": 459, "Abomasnow": 460, "Weavile": 461, "Magnezone": 462, "Lickilicky": 463, "Rhyperior": 464, "Tangrowth": 465, "Electivire": 466, "Magmortar": 467, "Togekiss": 468, "Yanmega": 469, "Leafeon": 470, "Glaceon": 471, "Gliscor": 472, "Mamoswine": 473, "Porygon-Z": 474, "Gallade": 475, "Probopass": 476, "Dusknoir": 477, "Froslass": 478, "Rotom": 479, "Rotom (Heat)": 479.1, "Rotom (Wash)": 479.2, "Rotom (Frost)": 479.3, "Rotom (Spin)": 479.4, "Rotom (Cut)": 479.5, "Uxie": 480, "Mesprit": 481, "Azelf": 482, "Dialga": 483, "Palkia": 484, "Heatran": 485, "Regigigas": 486, "Giratina": 487, "Giratina (O)": 487.1, "Cresselia": 488, "Phione": 489, "Manaphy": 490, "Darkrai": 491, "Shaymin": 492, "Shaymin (S)": 492.1, "Arceus": 493, "Victini": 494, "Snivy": 495, "Servine": 496, "Serperior": 497, "Tepig": 498, "Pignite": 499, "Emboar": 500,
"Oshawott": 501, "Dewott": 502, "Samurott": 503, "Patrat": 504, "Watchog": 505, "Lillipup": 506, "Herdier": 507, "Stoutland": 508, "Purrloin": 509, "Liepard": 510, "Pansage": 511, "Simisage": 512, "Pansear": 513, "Simisear": 514, "Panpour": 515, "Simipour": 516, "Munna": 517, "Musharna": 518, "Pidove": 519, "Tranquill": 520, "Unfezant": 521, "Blitzle": 522, "Zebstrika": 523, "Roggenrola": 524, "Boldore": 525, "Gigalith": 526, "Woobat": 527, "Swoobat": 528, "Drilbur": 529, "Excadrill": 530, "Audino": 531, "Timburr": 532, "Gurdurr": 533, "Conkeldurr": 534, "Tympole": 535, "Palpitoad": 536, "Seismitoad": 537, "Throh": 538, "Sawk": 539, "Sewaddle": 540, "Swadloon": 541, "Leavanny": 542, "Venipede": 543, "Whirlipede": 544, "Scolipede": 545, "Cottonee": 546, "Whimsicott": 547, "Petilil": 548, "Lilligant": 549, "Basculin": 550, "Sandile": 551, "Krokorok": 552, "Krookodile": 553, "Darumaka": 554, "Darmanitan": 555, "Darmanitan (Z)": 555.1, "Maractus": 556, "Dwebble": 557, "Crustle": 558, "Scraggy": 559, "Scrafty": 560, "Sigilyph": 561, "Yamask": 562, "Cofagrigus": 563, "Tirtouga": 564, "Carracosta": 565, "Archen": 566, "Archeops": 567, "Trubbish": 568, "Garbodor": 569, "Zorua": 570, "Zoroark": 571, "Minccino": 572, "Cinccino": 573, "Gothita": 574, "Gothorita": 575, "Gothitelle": 576, "Solosis": 577, "Duosion": 578, "Reuniclus": 579, "Ducklett": 580, "Swanna": 581, "Vanillite": 582, "Vanillish": 583, "Vanilluxe": 584, "Deerling": 585, "Sawsbuck": 586, "Emolga": 587, "Karrablast": 588, "Escavalier": 589, "Foongus": 590, "Amoonguss": 591, "Frillish": 592, "Jellicent": 593, "Alomomola": 594, "Joltik": 595, "Galvantula": 596, "Ferroseed": 597, "Ferrothorn": 598, "Klink": 599, "Klang": 600,
"Klinklang": 601, "Tynamo": 602, "Eelektrik": 603, "Eelektross": 604, "Elgyem": 605, "Beheeyem": 606, "Litwick": 607, "Lampent": 608, "Chandelure": 609, "Axew": 610, "Fraxure": 611, "Haxorus": 612, "Cubchoo": 613, "Beartic": 614, "Cryogonal": 615, "Shelmet": 616, "Accelgor": 617, "Stunfisk": 618, "Mienfoo": 619, "Mienshao": 620, "Druddigon": 621, "Golett": 622, "Golurk": 623, "Pawniard": 624, "Bisharp": 625, "Bouffalant": 626, "Rufflet": 627, "Braviary": 628, "Vullaby": 629, "Mandibuzz": 630, "Heatmor": 631, "Durant": 632, "Deino": 633, "Zweilous": 634, "Hydreigon": 635, "Larvesta": 636, "Volcarona": 637, "Cobalion": 638, "Terrakion": 639, "Virizion": 640, "Tornadus": 641, "Thundurus": 642, "Reshiram": 643, "Zekrom": 644, "Landorus": 645, "Kyurem": 646, "Keldeo": 647, "Meloetta (A)": 648, "Meloetta (P)": 648.1, "Genesect": 649, "Chespin": 650, "Quilladin": 651, "Chesnaught": 652, "Fennekin": 653, "Braixen": 654, "Delphox": 655, "Froakie": 656, "Frogadier": 657, "Greninja": 658, "Bunnelby": 659, "Diggersby": 660, "Fletchling": 661, "Fletchinder": 662, "Talonflame": 663, "Scatterbug": 664, "Spewpa": 665, "Vivillon": 666, "Litleo": 667, "Pyroar": 668, "Flabébé": 669, "Floette": 670, "Florges": 671, "Skiddo": 672, "Gogoat": 673, "Pancham": 674, "Pangoro": 675, "Furfrou": 676, "Espurr": 677, "Meowstic": 678, "Honedge": 679, "Doublade": 680, "Aegislash": 681, "Spritzee": 682, "Aromatisse": 683, "Swirlix": 684, "Slurpuff": 685, "Inkay": 686, "Malamar": 687, "Binacle": 688, "Barbaracle": 689, "Skrelp": 690, "Dragalge": 691, "Clauncher": 692, "Clawitzer": 693, "Helioptile": 694, "Heliolisk": 695, "Tyrunt": 696, "Tyrantrum": 697, "Amaura": 698, "Aurorus": 699, "Sylveon": 700,
"Hawlucha": 701, "Dedenne": 702, "Carbink": 703, "Goomy": 704, "Sliggoo": 705, "Goodra": 706, "Klefki": 707, "Phantump": 708, "Trevenant": 709, "Pumpkaboo": 710, "Gourgeist": 711, "Bergmite": 712, "Avalugg": 713, "Noibat": 714, "Noivern": 715, "Xerneas": 716, "Yveltal": 717, "Zygarde": 718, "Diancie": 719, "Hoopa (C)": 720, "Hoopa (U)": 721, "Volcanion": 721, "Rowlet": 722, "Dartrix": 723, "Decidueye": 724, "Litten": 725, "Torracat": 726, "Incineroar": 727, "Popplio": 728, "Brionne": 729, "Primarina": 730, "Pikipek": 731, "Trumbeak": 732, "Toucannon": 733, "Yungoos": 734, "Gumshoos": 735, "Grubbin": 736, "Charjabug": 737, "Vikavolt": 738, "Crabrawler": 739, "Crabominable": 740, "Oricorio": 741, "Cutiefly": 742, "Ribombee": 743, "Rockruff": 744, "Lycanroc": 745, "Wishiwashi": 746, "Mareanie": 747, "Toxapex": 748, "Mudbray": 749, "Mudsdale": 750, "Dewpider": 751, "Araquanid": 752, "Fomantis": 753, "Lurantis": 754, "Morelull": 755, "Shiinotic": 756, "Salandit": 757, "Salazzle": 758, "Stufful": 759, "Bewear": 760, "Bounsweet": 761, "Steenee": 762, "Tsareena": 763, "Comfey": 764, "Oranguru": 765, "Passimian": 766, "Wimpod": 767, "Golisopod": 768, "Sandygast": 769, "Palossand": 770, "Pyukumuku": 771, "Type: Null": 772, "Silvally": 773, "Minior": 774, "Komala": 775, "Turtonator": 776, "Togedemaru": 777, "Mimikyu": 778, "Bruxish": 779, "Drampa": 780, "Dhelmise": 781, "Jangmo-o": 782, "Hakamo-o": 783, "Kommo-o": 784, "Tapu Koko": 785, "Tapu Lele": 786, "Tapu Bulu": 787, "Tapu Fini": 788, "Cosmog": 789, "Cosmoem": 790, "Solgaleo": 791, "Lunala": 792, "Nihilego": 793, "Buzzwole": 794, "Pheromosa": 795, "Xurkitree": 796, "Celesteela": 797, "Kartana": 798, "Guzzlord": 799, "Necrozma": 800, "Magearna": 801, "Marshadow": 802
};
var prestigeLevels = [2000, 2000, 4000, 4000, 4000, 4000, 10000, 10000, 10000];
var prestigeScale = 125;
var prestigeLevelSpace = '1px';
var prestigeMissingColor = '#ccc';
// Add new options to side menu
$('#menu ul.links').append('<li class="teedyay-trainer-list">My trainer name:<br/><input type="text" id="teedyay-me" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"></textarea>');
$('#menu ul.links').append('<li class="teedyay-trainer-list">My friends:<br/><textarea id="teedyay-friends" placeholder="Enter trainer names, each on a separate line." autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"></textarea>');
$('#menu ul.links').append('<li class="teedyay-trainer-list">My nemeses:<br/><textarea id="teedyay-nemeses" placeholder="Enter trainer names, each on a separate line." autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"></textarea>');
$('#menu ul.links').append('<li class="teedyay-trainer-list">Others I\'m watching:<br/><textarea id="teedyay-others" placeholder="Enter trainer names, each on a separate line." autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"></textarea>');
var trainerClassByName;
var readTrainerClassFromLocalStorage = function () {
var trainerClassByNameJson = localStorage.getItem("teedyay-trainerClass");
if (trainerClassByNameJson)
trainerClassByName = JSON.parse(trainerClassByNameJson);
else
trainerClassByName = {};
};
var saveTrainerClassToLocalStorage = function () {
var newTrainerClass = {};
var newOtherList = $('#teedyay-others').val().split('\n');
if (newOtherList)
for (var o in newOtherList) {
var other = $.trim(newOtherList[o]);
if (other)
newTrainerClass[other.toLowerCase()] = "other";
}
var newFriendList = $('#teedyay-friends').val().split('\n');
if (newFriendList)
for (var f in newFriendList) {
var friend = $.trim(newFriendList[f]);
if (friend)
newTrainerClass[friend.toLowerCase()] = "friend";
}
var newNemesisList = $('#teedyay-nemeses').val().split('\n');
if (newNemesisList)
for (var n in newNemesisList) {
var nemesis = $.trim(newNemesisList[n]);
if (nemesis)
newTrainerClass[nemesis.toLowerCase()] = "nemesis";
}
var newMe = $.trim($('#teedyay-me').val());
if (newMe)
newTrainerClass[newMe.toLowerCase()] = "me";
localStorage.setItem("teedyay-trainerClass", JSON.stringify(newTrainerClass));
readTrainerClassFromLocalStorage();
$('.teedyay-spotted-list').remove();
$('.teedyay-gym-done').removeClass('teedyay-gym-done');
};
// Populate the side menu
readTrainerClassFromLocalStorage();
var friends = '';
var nemeses = '';
var others = '';
for (var i in trainerClassByName) {
if (trainerClassByName[i] === 'me')
$('#teedyay-me').val(i);
else if (trainerClassByName[i] === 'friend') {
if (friends !== '')
friends = friends + '\n';
friends = friends + i;
}
else if (trainerClassByName[i] === 'nemesis') {
if (nemeses !== '')
nemeses = nemeses + '\n';
nemeses = nemeses + i;
}
else if (trainerClassByName[i] === 'other') {
if (others !== '')
others = others + '\n';
others = others + i;
}
}
$('#teedyay-friends').val(friends);
$('#teedyay-nemeses').val(nemeses);
$('#teedyay-others').val(others);
$('#teedyay-me').change(function () {
saveTrainerClassToLocalStorage();
});
$('.teedyay-trainer-list textarea').change(function () {
saveTrainerClassToLocalStorage();
});
var checkGymPopups = function () {
// This function restyles the gym popups to make them clearer
$('.sweet-alert .gym_pokemon').closest('.sweet-alert').each(function () {
var $popup = $(this);
var teamName = $.trim($popup.find('.gym_team').text());
$popup.find('.gym_team').remove();
$popup.removeClass('teedyay-team-mystic');
$popup.removeClass('teedyay-team-valor');
$popup.removeClass('teedyay-team-instinct');
$popup.addClass('teedyay-team-' + teamName.toLowerCase());
var ownerColor;
if (teamName === 'Mystic')
ownerColor = 'rgba(74, 138, 202, 0.67)';
else if (teamName === 'Valor')
ownerColor = 'rgba(240, 68, 58, 0.67)';
else if (teamName === 'Instinct')
ownerColor = 'rgba(254, 178, 0, 0.67)';
else
ownerColor = 'rgba(0, 0, 0, 0.67)';
var prestige = parseInt($popup.find('.gym_points').text().match(/\d/g).join(""), 10);
var $prestigeBar = $('<div class="prestigeBar" style="position: relative; z-index: -1; height: 20px; padding: 0; white-space: nowrap;"></div>');
var level = 0;
var remainingPrestigeInLevel = 0;
while (level < prestigeLevels.length && prestige > 0) {
var segmentLength = Math.min(prestige, prestigeLevels[level]);
var segmentPixels = segmentLength / prestigeScale;
var margin = '0';
if (segmentLength === prestigeLevels[level])
margin = prestigeLevelSpace;
$prestigeBar.append($('<div style="display: inline-block; height: 10px; margin: 0 ' + margin + ' 0 0; background-color: ' + ownerColor + '; width: ' + segmentPixels + 'px;"></div>'));
remainingPrestigeInLevel = prestigeLevels[level] - prestige;
prestige -= segmentLength;
level++;
}
if (remainingPrestigeInLevel > 0)
$prestigeBar.append($('<div style="display: inline-block; height: 10px; margin: 0 ' + prestigeLevelSpace + ' 0 0; background-color: ' + prestigeMissingColor + '; width: ' + (remainingPrestigeInLevel / prestigeScale) + 'px;"></div>'));
for (; level < prestigeLevels.length; level++)
$prestigeBar.append($('<div style="display: inline-block; height: 10px; margin: 0 ' + prestigeLevelSpace + ' 0 0; background-color: ' + prestigeMissingColor + '; width: ' + (prestigeLevels[level] / prestigeScale) + 'px;"></div>'));
$popup.find('.gym_points').after($prestigeBar);
var $list = $popup.find('.gym_pokemon_inner');
var $listItems = $list.children('.pokemon');
var $myList = $('<ul class="teedyay-pokemon-list" />');
$listItems.each(
function() {
var $listItem = $(this);
var $text = $listItem.contents().filter(function() {
return this.nodeType === 3; //Node.TEXT_NODE
});
var pokemonName = $.trim($text.text());
var pokemonNum = numByName[pokemonName];
var cp = $listItem.find('.cp').text();
var trainerName = $.trim($listItem.find('.name').text());
$myList.prepend($('<li class="teedyay-trainer-' + trainerClassByName[trainerName.toLowerCase()] + '">' +
'<div>' +
'<div class="teedyay-icon" title="' + pokemonName + '" style="background-position-x: -' + ((pokemonNum - 1) * 40) + 'px;"></div>' +
'<div class="teedyay-details">' +
'<div class="teedyay-cp">' + cp + '</div>' +
'<div class="teedyay-trainer">' + trainerName +
'</div>' +
'</div>' +
'</div>' +
'</li>'));
});
$popup.find('.gym_pokemon').replaceWith($myList);
$popup.css({ 'max-height': ($(window).height() - 20) + 'px' });
$popup.css({ 'margin-top': (-$popup.height() / 2) + 'px' });
});
setTimeout(checkGymPopups, 100);
};
// GymHuntr uses sweetalert for its popup. Override the swal function so we can intercept the data to be displayed.
var $huntingGym = null;
var originalSwal = swal;
swal = function (obj) {
// $huntingGym is the one our funciton did a fake click on. It's null when the user clicks a gym, so we show the popup as normal.
if ($huntingGym === null) {
return originalSwal.apply(this, arguments);
}
// Inspect the html that would have been displayed and use it to build the smaller on-map list of interesting trainers.
if ($huntingGym.find('.teedyay-spotted-list').size() > 0)
return;
var $html = $(obj.text);
var $trainers = $html.find('.gym_pokemon_inner .pokemon .name');
if ($trainers.size() > 0) {
var $list = $('<ul class="teedyay-spotted-list"></ul>');
$trainers.each(function () {
var trainerName = $.trim($(this).text());
var trainerClass = trainerClassByName[trainerName.toLowerCase()];
if (trainerClass)
$list.prepend('<li class="teedyay-trainer-' + trainerClass + '"><div>' + trainerName +
'</div></li>');
});
if ($list.children().size() > 0) {
$huntingGym.append($list);
}
$huntingGym.find('.gym').addClass('teedyay-gym-done');
}
};
// Sweetalert (aka swal) has some other properties on it. Copy those to our object so everything else still works as expected (the popup close button, etc.)
for (var fn in originalSwal)
swal[fn] = originalSwal[fn];
var huntGyms = function () {
// Look for gym icons on the map and do a fake click on each one to see who's in there.
var $gyms = $('.leaflet-marker-icon.leaflet-div-icon.leaflet-interactive > .gym:not(.teedyay-gym-done)').parent();
$gyms.each(function (i) {
$huntingGym = $(this);
$huntingGym.click();
$huntingGym = null;
});
setTimeout(huntGyms, 100);
};
$('body').append('<style type="text/css">' +
'ul.teedyay-spotted-list { position: absolute; top: 0; left: 30px; padding: 0; margin: 0; font-size: 8px; font-family: Lato, Arial, Verdana, sans-serif; box-shadow: 2px 4px 5px #888888; pointer-events: none; }' +
'ul.teedyay-spotted-list > li { list-style: none inside; padding: 0; margin: 0; }' +
'ul.teedyay-spotted-list > li > div { padding: 0 1px; }' +
'ul.teedyay-spotted-list .teedyay-trainer-me > div { background-color: rgba(0, 0, 0, 1.0); color: #eee; }' +
'ul.teedyay-spotted-list .teedyay-trainer-friend > div { background-color: rgba(186, 218, 85, 1.0); color: #222; }' +
'ul.teedyay-spotted-list .teedyay-trainer-nemesis > div { background-color: rgba(255, 128, 16, 1.0); color: #222; }' +
'ul.teedyay-spotted-list .teedyay-trainer-other > div { background-color: rgba(121, 121, 121, 1.0); color: #fff; }' +
'.sweet-alert h2 { padding-bottom: 10px !important; }' +
'.teedyay-team-mystic, .teedyay-team-valor, .teedyay-team-instinct { background-color: #fff; background-position: top center; background-repeat: no-repeat; }' +
'.teedyay-team-mystic { background-image: url(https://s3-eu-west-1.amazonaws.com/com.timjeanes/pogo/pokemongo-team-logos-mystic.png); }' +
'.teedyay-team-valor { background-image: url(https://s3-eu-west-1.amazonaws.com/com.timjeanes/pogo/pokemongo-team-logos-valor.png); }' +
'.teedyay-team-instinct { background-image: url(https://s3-eu-west-1.amazonaws.com/com.timjeanes/pogo/pokemongo-team-logos-instinct.png); }' +
'#teedyay-me { width: 100%; }' +
'ul.links li.teedyay-trainer-list { padding: 15px; }' +
'ul.links li.teedyay-trainer-list textarea { margin-top: 5px; font: inherit; display: block; min-height: 200px; width: 100%; }' +
'ul.teedyay-pokemon-list { background-color: rgba(255, 255, 255, 0.67); display: inline-block; padding: 0; margin: 16px auto; column-count: 2; column-gap: 10px; }' +
'ul.teedyay-pokemon-list > li { list-style: none inside; text-align: initial; margin: 2px; }' +
'ul.teedyay-pokemon-list > li > div { padding: 2px 10px 0 4px; }' +
'ul.teedyay-pokemon-list > li > div > div { display: inline-block; vertical-align: top; }' +
'ul.teedyay-pokemon-list .teedyay-trainer-me > div { background-color: rgba(0, 0, 0, 0.9); color: #eee; }' +
'ul.teedyay-pokemon-list .teedyay-trainer-friend > div { background-color: rgba(186, 218, 85, 0.9); color: #222; }' +
'ul.teedyay-pokemon-list .teedyay-trainer-nemesis > div { background-color: rgba(255, 128, 16, 0.9); color: #222; }' +
'ul.teedyay-pokemon-list .teedyay-trainer-other > div { background-color: rgba(121, 121, 121, 0.9); color: #fff; }' +
'ul.teedyay-pokemon-list .teedyay-trainer { font-size: 12px; }' +
'ul.teedyay-pokemon-list > li .teedyay-icon { width: 40px; height: 40px; padding: 0; margin: 0 10px 0 0; background-image: url(https://s3-eu-west-1.amazonaws.com/com.timjeanes/pogo/pokemon-icons-40.png); background-position: top left; background-repeat: no-repeat; }' +
'</style>');
// Start polling
checkGymPopups();
huntGyms();
})();