Advertisement
Guest User

Untitled

a guest
Jul 24th, 2016
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.39 KB | None | 0 0
  1. // ==UserScript==
  2. // @name PokevisionMod
  3. // @namespace PokeMod
  4. // @description Pokevision Mod
  5. // @include https://pokevision.com/*
  6. // @version 1.1
  7. // @grant none
  8. // ==/UserScript==
  9.  
  10. window.addEventListener('load', function() {
  11. //POKEVISION AFK MOD - Take 2 22/07/2016
  12. console.log("%cLOADING POKEVISION MOD","color:lightblue");
  13. console.log("- Big thanks to ffejmania for the distance calculator");
  14.  
  15. /*Sound effects, in case the narrator bugs up (happens a lot)
  16. Hopefully these guys don't mind we're using their sound :)
  17. http://ionden.com/a/plugins/ion.sound/static/sounds/button_tiny.mp3
  18. */
  19. var audio = new Audio('http://ionden.com/a/plugins/ion.sound/static/sounds/button_tiny.mp3');
  20. function blip() {
  21. audio.play();
  22. }
  23. //Clean that side bar. Sorry website owners.
  24. $(".home-sidebar p:not(.home-sidebar-social), .home-sidebar ol, .home-sidebar h3").remove();
  25. $(".home-sidebar").append(`
  26. <h1>That lazy afk mod</h1>
  27. <p>Sit back, relax and it'll let you know when it's worth going outside :)<p>
  28. <h3 id="distanceheader">Alert distance <1000m</h3>
  29. <input id="searchdistance" type="range" min="10" max="1000" value="1000"></input>
  30. <h3>Pokemon</h3>
  31. <p><button id="deselectall">Deselect All</button><button id="selectall">Select All</button></p>
  32. <ol id="alertlist" type="1">
  33. </ol>
  34. `);
  35. $(".home-map-scan").remove();
  36.  
  37. var pokemonAlertList = { //Choose which pokemon you want to be alerted about!
  38. "Bulbasaur": true,
  39. "Ivysaur":true,
  40. "Venusaur":true,
  41. "Charmander":true,
  42. "Charmeleon":true,
  43. "Charizard":true,
  44. "Squirtle":true,
  45. "Wartortle":true,
  46. "Blastoise":true,
  47. "Caterpie":false,
  48. "Metapod":false,
  49. "Butterfree":true,
  50. "Weedle":false,
  51. "Kakuna":false,
  52. "Beedrill":true,
  53. "Pidgey":false, //Hell no
  54. "Pidgeotto":false,
  55. "Pidgeot":true,
  56. "Rattata":false,
  57. "Raticate":false,
  58. "Spearow":false,
  59. "Fearow":true,
  60. "Ekans":false,
  61. "Arbok":true,
  62. "Pikachu":true,
  63. "Raichu":true,
  64. "Sandshrew":true,
  65. "Sandslash":true,
  66. "Nidoran♀":false,
  67. "Nidorina":false,
  68. "Nidoqueen":true,
  69. "Nidoran♂":false,
  70. "Nidorino":false,
  71. "Nidoking":true,
  72. "Clefairy":false,
  73. "Clefable":true,
  74. "Vulpix":true,
  75. "Ninetales":true,
  76. "Jigglypuff":false,
  77. "Wigglytuff":true,
  78. "Zubat":false, //Hell no
  79. "Golbat":true,
  80. "Oddish":false,
  81. "Gloom":false,
  82. "Vileplume":true,
  83. "Paras":false,
  84. "Parasect":false,
  85. "Venonat":false,
  86. "Venomoth":true,
  87. "Diglett":true,
  88. "Dugtrio":true,
  89. "Meowth":false,
  90. "Persian":false,
  91. "Psyduck":false,
  92. "Golduck":true,
  93. "Mankey":false,
  94. "Primeape":true,
  95. "Growlithe":true,
  96. "Arcanine":true,
  97. "Poliwag":false,
  98. "Poliwhirl":true,
  99. "Poliwrath":true,
  100. "Abra":false,
  101. "Kadabra":true,
  102. "Alakazam":true,
  103. "Machop":true,
  104. "Machoke":true,
  105. "Machamp":true,
  106. "Bellsprout":false,
  107. "Weepinbell":false,
  108. "Victreebel":true,
  109. "Tentacool":false,
  110. "Tentacruel":true,
  111. "Geodude":false,
  112. "Graveler":true,
  113. "Golem":true,
  114. "Ponyta":true,
  115. "Rapidash":true,
  116. "Slowpoke":true,
  117. "Slowbro":true,
  118. "Magnemite":false,
  119. "Magneton":true,
  120. "Farfetch'd":true,
  121. "Doduo":false,
  122. "Dodrio":false,
  123. "Seel":false,
  124. "Dewgong":false,
  125. "Grimer":false,
  126. "Muk":true,
  127. "Shellder":false,
  128. "Cloyster":true,
  129. "Gastly":false,
  130. "Haunter":false,
  131. "Gengar":true,
  132. "Onix":true,
  133. "Drowzee":false,
  134. "Hypno":false,
  135. "Krabby":false,
  136. "Kingler":false,
  137. "Voltorb":false,
  138. "Electrode":true,
  139. "Exeggcute":false,
  140. "Exeggutor":true,
  141. "Cubone":false,
  142. "Marowak":true,
  143. "Hitmonlee":true,
  144. "Hitmonchan":true,
  145. "Lickitung":true,
  146. "Koffing":true,
  147. "Weezing":true,
  148. "Rhyhorn":false,
  149. "Rhydon":true,
  150. "Chansey":false,
  151. "Tangela":false,
  152. "Kangaskhan":true,
  153. "Horsea":false,
  154. "Seadra":false,
  155. "Goldeen":false,
  156. "Seaking":false,
  157. "Staryu":false,
  158. "Starmie":true,
  159. "Mr. Mime":true,
  160. "Scyther":true,
  161. "Jynx":false,
  162. "Electabuzz":true,
  163. "Magmar":true,
  164. "Pinsir":true,
  165. "Tauros":true,
  166. "Magikarp":false,
  167. "Gyarados":true,
  168. "Lapras":true,
  169. "Ditto":true,
  170. "Eevee":false,
  171. "Vaporeon":true,
  172. "Jolteon":true,
  173. "Flareon":true,
  174. "Porygon":true,
  175. "Omanyte":true,
  176. "Omastar":true,
  177. "Kabuto":true,
  178. "Kabutops":true,
  179. "Aerodactyl":true,
  180. "Snorlax":true,
  181. "Articuno":true,
  182. "Zapdos":true,
  183. "Moltres":true,
  184. "Dratini":true,
  185. "Dragonair":true,
  186. "Dragonite":true,
  187. "Mewtwo":true,
  188. "Mew":true, //The dream
  189. };
  190.  
  191. var searchdistance = 1000; //Are they worth the walk?
  192. var showUnwanted = true; //If it's not on the alert list should it be shown? This isn't a feature just yet...
  193.  
  194. //Add pokemon to the list
  195. for (var key in pokemonAlertList) {
  196. var isChecked = pokemonAlertList[key]? "checked" : "";
  197. $("#alertlist").append('<li><input type="checkbox" '+isChecked+'></input> '+key+'</li>');
  198. }
  199.  
  200. //Bind events to the list items
  201. $("#selectall").click(function(){
  202. console.log("selectall");
  203. $("#alertlist li").each(function(e){
  204. $(this).find("input").prop("checked",true);
  205. var name = $(this).text().replace(/\s+/g, '');
  206. pokemonAlertList[name] = true;
  207. });
  208. });
  209. $("#deselectall").click(function(){
  210. console.log("deselectall");
  211. $("#alertlist li").each(function(e){
  212. $(this).find("input").prop("checked",false);
  213. var name = $(this).text().replace(/\s+/g, '');
  214. pokemonAlertList[name] = false;
  215. });
  216. });
  217. $("#searchdistance").mousemove(function(e){
  218. var dis = $(this).val();
  219. searchdistance = dis;
  220. if (dis < 1000) {
  221. $("#distanceheader").text("Alert distance <" + dis + "m");
  222. } else {
  223. $("#distanceheader").text("No limit");
  224. }
  225. });
  226. $("#alertlist li input").click(function(e){
  227. var name = $(this).parent().text().replace(/\s+/g, '');
  228. var state = $(this).is(":checked");
  229. console.log(name,state);
  230. pokemonAlertList[name] = state; //Update the variable
  231. });
  232.  
  233. //The cool stuff
  234. App.home.updateMarkers = function() {
  235. e = App.home;
  236. if (!e.map) {
  237. return;
  238. }
  239. for (var i in e.pokemon) {
  240. var t = e.pokemon[i],
  241. o = t.expiration_time - Math.floor(+new Date() / 1000),
  242. n = e.markers['pokemon-' + i];
  243. if (o <= 0) {
  244. if (n) {
  245. e.map.removeLayer(n);
  246. delete e.markers['pokemon-' + i];
  247. }
  248. delete e.pokemon[i];
  249. continue;
  250. }
  251. if (!n) { //Check if it's on the alert list and if its wanted
  252. n = e.createMarker(i, t);
  253. foundPokemon(e.pokedex[t.pokemonId], getDistanceMetres(App.home.latitude, App.home.longitude, n._latlng.lat, n._latlng.lng));
  254. }
  255. n.updateLabel(e.secondsToString(o));
  256. }
  257. };
  258.  
  259. function search () {
  260. console.log("Scanning...");
  261. App.home.findNearbyPokemon(App.home.latitude, App.home.longitude, !0);
  262. setTimeout(search,App.home.TIMER_SCAN_DELAY); //Scans at websites desired delay, please don't change this!
  263. }
  264.  
  265. function foundPokemon(pokemon,d) {
  266. console.log("FOUND POKEMON!" + pokemon + " " + d + " metres away");
  267. if (pokemonAlertList[pokemon] && (d <= searchdistance || searchdistance === "1000")) { //If it's within range
  268. console.log("Alerting user!");
  269. blip();
  270. App.success(
  271. 'There is a ' + pokemon + ' ' + d + ' metres away! Go catch it!' //Pop up
  272. );
  273. return;
  274. }
  275. }
  276.  
  277. //Big thanks to ffejmania (and Lolologist) :)
  278. function getDistanceMetres(lat1,lon1,lat2,lon2) {
  279. var R = 6371; // Radius of the earth in km
  280. var dLat = deg2rad(lat2-lat1); // deg2rad below
  281. var dLon = deg2rad(lon2-lon1);
  282. var a =
  283. Math.sin(dLat/2) * Math.sin(dLat/2) +
  284. Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) *
  285. Math.sin(dLon/2) * Math.sin(dLon/2)
  286. ;
  287. var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
  288. var d = Math.floor(R * c * 1000); // Distance in m
  289. return d;
  290. }
  291. function deg2rad(deg) {
  292. return deg * (Math.PI/180);
  293. }
  294.  
  295. //Start the repeating search function
  296. search();
  297. App.success(
  298. 'The mod has started running! It will automatically refresh the search every 30 seconds' //Pop up
  299. );
  300. }, false);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement