MH Maps Tweaker

Rearrange mice in the map

当前为 2015-06-29 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name MH Maps Tweaker
  3. // @description Rearrange mice in the map
  4. // @author Dusan Djordjevic
  5. // @include http://www.mousehuntgame.com/*
  6. // @include https://www.mousehuntgame.com/*
  7. // @include http://apps.facebook.com/mousehunt/*
  8. // @include https://apps.facebook.com/mousehunt/*
  9. // @version 1.20 - Revamped maps - new UI
  10. // @history 1.10 - No need to update script when new mice are out
  11. // @history 1.00 - Initial release
  12. // @namespace MH Tweaks
  13. // ==/UserScript==
  14.  
  15. VERSION = 1.20;
  16.  
  17. getLocations();
  18.  
  19. var LOCATIONS = {
  20. "Meadow": ["Field", "Flying", "Spotted", "Tiny"],
  21. "Town of Gnawnia": ["Brown", "Cowardly", "Dwarf", "Grey", "Master Burglar", "Nibbler", "White"],
  22. "Windmill": ["Spud"],
  23. "Harbour": ["Magic", "Pirate"],
  24. "Mountain": ["Black Widow", "Diamond", "Gold", "Silvertail"],
  25. "Slushy Shoreline": ["Living Ice", "Snow Soldier"],
  26. "Slushy Shoreline + Softserve charm": ["Yeti", "Icebreaker"],
  27. "King\'s Arms": [],
  28. "Tournament Hall": ["Lightning Rod"],
  29. "King\'s Gauntlet": [],
  30. "Calm Clearing": ["Bear", "Frog", "Moosker"],
  31. "Great Gnarled Tree": [],
  32. "Lagoon": ["Centaur", "Elven Princess", "Hydra", "Nomad", "Tiger"],
  33. "Claw Shot City": [],
  34. "Laboratory": ["Monster", "Steel"],
  35. "Town of Digby": ["Bionic", "Granite", "Zombie"],
  36. "Mousoleum": ["Bat", "Mummy", "Ravenous Zombie"],
  37. "Bazaar": ["Burglar"],
  38. "Training Grounds": ["Monk", "Ninja", "Worker"],
  39. "Dojo": ["Assassin", "Student of the Cheese Belt", "Student of the Cheese Claw", "Student of the Cheese Fang"],
  40. "Meditation Room": ["Hapless", "Master of the Cheese Belt", "Master of the Cheese Claw", "Master of the Cheese Fang"],
  41. "Pinnacle Chamber": ["Dojo Sensei", "Master of the Dojo"],
  42. "Catacombs": ["Giant Snail", "Keeper", "Ooze", "Scavenger", "Terror Knight"],
  43. "Forbidden Grove": ["Lycan", "Mutated Grey", "Mutated White", "Realm Ripper", "Vampire"],
  44. "Acolyte Realm": ["Acolyte", "Lich", "Spectre"],
  45. "S.S. Huntington III": ["Briegull", "Siren", "Swabbie", "Mermouse"],
  46. "Seasonal Garden": ["Harvest Harrier", "Icicle", "Puddlemancer", "Stinger"],
  47. "Zugzwang\'s Tower": ["Chess Master", "Mystic Bishop", "Mystic King", "Mystic Rook", "Technic Bishop", "Technic King", "Technic Rook"],
  48. "Crystal Library": ["Aether", "Effervescent", "Flutterby", "Infiltrator", "Pocketwatch", "Walker"],
  49. "Iceberg": ["Chipper", "General Drheller", "Iceblade", "Lady Coldsnap", "Living Salt", "Lord Splodington", "Polar Bear", "Princess Fist", "Snow Slinger", "Stickybomber"],
  50. "Iceberg - Hidden Depts": ["Frostwing Commander", "Frostlance Guard"],
  51. "Iceberg - Bombing Run": ["Heavy Blaster"],
  52. "Cape Clawed": ["Aged"],
  53. "Cape Clawed + Shell": ["Scout"],
  54. "Elub Shore": ["Mystic", "Pinchy", "Soothsayer"],
  55. "Elub Shore + Shell": ["Champion", "Protector", "Elub Chieftain"],
  56. "Nerg Plains": ["Chameleon", "Conjurer", "Conqueror", "Nerg Chieftain", "Finder", "Beast Tamer", "Alnilam"],
  57. "Derr Dunes": ["Derr Chieftain", "Mintaka", "Seer"],
  58. "Jungle of Dread": ["Chitinous", "Fetid Swamp", "Jurassic", "Magma Carrier", "Primal", "Pygmy Wrangler", "Stonework Warrior", "Swarm of Pygmy Mice", "Sylvan"],
  59. "Dracano": ["Draconic Warden", "Whelpling"],
  60. "Balack\'s Cove": ["Balack the Banished", "Brimstone", "Derr Lich", "Elub Lich", "Nerg Lich", "Riptide", "Twisted Fiend"],
  61. "Fiery Warpath": ["Magmarage", "Sand Cavalry", "Flame Ordnance", "Crimson Commander", "Caravan Guard"],
  62. "Fiery Warpath (Wave 3)": ["Crimson Titan"],
  63. "Muridae Market": ["Blacksmith", "Desert Architect", "Falling Carpet", "Mage Weaver", "Pie Thief", "Snake Charmer", "Spice Merchant", "Market Thief"],
  64. "Living Garden": ["Thirsty", "Thistle", "Strawberry Hotcakes", "Bark", "Calalilly", "Shroom", "Camoflower", "Carmine the Apothecary"],
  65. "Lost City": ["Cursed", "Essence Collector", "Ethereal Enchanter", "Ethereal Engineer", "Ethereal Librarian", "Ethereal Thief"],
  66. "Sand Dunes": ["Dunehopper", "Grubling", "Grubling Herder", "Quesodillo", "Sand Pilgrim", "Spiky Devil"],
  67. "Twisted Garden": ["Dehydrated", "Thorn", "Twisted Hotcakes", "Barkshell", "Twisted Lilly", "Fungal Spore", "Camofusion", "Twisted Carmine"],
  68. "Cursed City": ["Essence Guardian", "Cursed Enchanter", "Corrupt", "Cursed Engineer", "Cursed Thief", "Cursed Librarian"],
  69. "Sand Crypts": ["Sarcophamouse", "Sand Colossus", "Serpentine", "Scarab", "King Grub"],
  70. "Festive Snow Fort": ["Snowflake", "Nutcracker", "Candy Cane", "Snow Scavenger", "Snowglobe", "Ridiculous Sweater", "Triple Lutz", "Destructoy", "Snowblower", "Elf", "Missile Toe", "Wreath Thief", "Snow Fort", "Stocking"],
  71. "Gnawnian Express Station": ["Farrier", "Cute Crate Carrier", "Parlour Player", "Stoutgear", "Travelling Barber", "Crate Camo"],
  72. "Gnawnia Rift": [""],
  73. "Burroughs Rift": ["Lycanoid", "Portable Generator", "Assassin Beast"],
  74. "Whisker Woods Rift": ["Grizzled Silth", "Gilded Leaf", "Cherry Sprite", "Tree Troll"],
  75. "Whisker Woods Rift - Yellow": ["Lambent"],
  76. "Whisker Woods Rift - Red + Polluted parmesan": ["The Menace of the Rift"],
  77. "Fungal Cavern": ["Crystalline Slasher", "Splintered Stone Sentry", "Bitter Root", "Spore Muncher", "Crystal Queen", "Crystalback", "Dirt Thing"],
  78. "Sunken City - Carnivore Cove": ["Carnivore"],
  79. "Sunken City - Pearl Patch": ["Pearl Diver"]
  80. };
  81. var miceRows = {},
  82. miceMap = [],
  83. miceOrdered = '',
  84. remainingMice = '',
  85. locationsLoaded = false;
  86. var mapButton = document.getElementsByClassName('treasureMap')[0];
  87. mapButton.addEventListener('click', doMap, false);
  88.  
  89. function doMap() {
  90. var loaded = (document.getElementsByClassName('treasureMapPopup-mice-group-header').length == 0) ? false : true;
  91. if(loaded && locationsLoaded) {
  92. prepareMice();
  93. rearrangeMice();
  94. } else {
  95. setTimeout(doMap, 1000);
  96. }
  97. }
  98.  
  99. function prepareMice() {
  100. var miceContainer = document.getElementsByClassName('treasureMapPopup-miceBlockRow')[0],
  101. mice = miceContainer.getElementsByClassName('mice')[0],
  102. miceContent = mice.getElementsByClassName('treasureMapPopup-leftBlock-content')[0],
  103. miceContentDefault = miceContent.getElementsByClassName('treasureMapPopup-leftBlock-content-default')[0],
  104. uncaughtmice = miceContentDefault.getElementsByClassName('uncaughtmice')[0],
  105. miceGroupContainer = uncaughtmice.getElementsByClassName('treasureMapPopup-mice-group-miceContainer')[0],
  106. miceMapUncaugth = miceGroupContainer.getElementsByClassName('treasureMapPopup-mice-group-mouse');
  107.  
  108. miceRows = {};
  109. miceMap = [];
  110. for(var i=0; i<miceMapUncaugth.length; i++) {
  111. var mouseUncaughtElement = miceMapUncaugth[i],
  112. mouseName = mouseUncaughtElement.getAttribute("data-name");
  113. miceRows[mouseName] = mouseUncaughtElement.innerHTML;
  114. miceMap.push(mouseName);
  115. }
  116. miceOrdered = '';
  117. remainingMice = '';
  118. }
  119. function rearrangeMice() {
  120. for(loc in LOCATIONS) {
  121. var mice = LOCATIONS[loc], miceList = '';
  122. for(key in mice) {
  123. var mouse = mice[key];
  124. if(arrayContains(miceMap, mouse)) {
  125. var mouseHtml = miceRows[mouse],
  126. index = miceMap.indexOf(mouse);
  127. miceList += '<div onmouseout="app.views.TreasureMapView.map.removeHighlight(); return false;" onmouseover="app.views.TreasureMapView.map.highlightMouse(this);" data-name="'+mouse+'" class="treasureMapPopup-mice-group-mouse treasureMapPopup-searchIndex">'+mouseHtml+'</div>';
  128. //miceList += '<div class="treasureMap-mice-group-row">'+mouseHtml+'</div>';
  129. miceMap.splice(index, 1);
  130. }
  131. }
  132. if(miceList.length > 0) {
  133. miceOrdered += '<div class="treasureMapPopup-mice-group-header" style="margin-top:10px">'+loc+'</div>'+miceList;
  134. }
  135. }
  136. for(var i=0; i<miceMap.length; i++) {
  137. var mouse = miceMap[i];
  138. //remainingMice += '<div class="treasureMap-mice-group-row">'+miceRows[mouse]+'</div>';
  139. remainingMice += '<div onmouseout="app.views.TreasureMapView.map.removeHighlight(); return false;" onmouseover="app.views.TreasureMapView.map.highlightMouse(this);" data-name="'+mouse+'" class="treasureMapPopup-mice-group-mouse treasureMapPopup-searchIndex">'+miceRows[mouse]+'</div>';
  140. }
  141. if(remainingMice != '') {
  142. miceOrdered += '<div class="treasureMapPopup-mice-group-header" style="margin-top:10px">Uncaught Mice</div>'+remainingMice;
  143. }
  144.  
  145. var firstMiceGroup = document.getElementsByClassName('uncaughtmice')[0];
  146. firstMiceGroup.innerHTML = miceOrdered;
  147. }
  148.  
  149. function arrayContains(a, obj) {
  150. var i = a.length;
  151. while(i--) {
  152. if(a[i] === obj) {
  153. return true;
  154. }
  155. }
  156. return false;
  157. }
  158.  
  159. function getLocations() {
  160. var protocol = location.protocol,
  161. url = protocol + '//igrajtenis.net/mousehunt/maps_tweaker.php',
  162. request = new XMLHttpRequest();
  163. request.onreadystatechange = function () {
  164. if(request.readyState == 4) {
  165. if(request.status == 200) {
  166. var result = eval('('+request.responseText+')');
  167. if(result.status == 'ok') {
  168. LOCATIONS = result.data;
  169. }
  170. }
  171. locationsLoaded = true;
  172. }
  173. }
  174. request.open("GET", url, true);
  175. request.send();
  176. }