Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name PokevisionMod
- // @namespace PokeMod
- // @description Pokevision Mod
- // @include https://pokevision.com/*
- // @version 1.1
- // @grant none
- // ==/UserScript==
- window.addEventListener('load', function() {
- //POKEVISION AFK MOD - Take 2 22/07/2016
- console.log("%cLOADING POKEVISION MOD","color:lightblue");
- console.log("- Big thanks to ffejmania for the distance calculator");
- /*Sound effects, in case the narrator bugs up (happens a lot)
- Hopefully these guys don't mind we're using their sound :)
- http://ionden.com/a/plugins/ion.sound/static/sounds/button_tiny.mp3
- */
- var audio = new Audio('http://ionden.com/a/plugins/ion.sound/static/sounds/button_tiny.mp3');
- function blip() {
- audio.play();
- }
- //Clean that side bar. Sorry website owners.
- $(".home-sidebar p:not(.home-sidebar-social), .home-sidebar ol, .home-sidebar h3").remove();
- $(".home-sidebar").append(`
- <h1>That lazy afk mod</h1>
- <p>Sit back, relax and it'll let you know when it's worth going outside :)<p>
- <h3 id="distanceheader">Alert distance <1000m</h3>
- <input id="searchdistance" type="range" min="10" max="1000" value="1000"></input>
- <h3>Pokemon</h3>
- <p><button id="deselectall">Deselect All</button><button id="selectall">Select All</button></p>
- <ol id="alertlist" type="1">
- </ol>
- `);
- $(".home-map-scan").remove();
- var pokemonAlertList = { //Choose which pokemon you want to be alerted about!
- "Bulbasaur": true,
- "Ivysaur":true,
- "Venusaur":true,
- "Charmander":true,
- "Charmeleon":true,
- "Charizard":true,
- "Squirtle":true,
- "Wartortle":true,
- "Blastoise":true,
- "Caterpie":false,
- "Metapod":false,
- "Butterfree":true,
- "Weedle":false,
- "Kakuna":false,
- "Beedrill":true,
- "Pidgey":false, //Hell no
- "Pidgeotto":false,
- "Pidgeot":true,
- "Rattata":false,
- "Raticate":false,
- "Spearow":false,
- "Fearow":true,
- "Ekans":false,
- "Arbok":true,
- "Pikachu":true,
- "Raichu":true,
- "Sandshrew":true,
- "Sandslash":true,
- "Nidoran♀":false,
- "Nidorina":false,
- "Nidoqueen":true,
- "Nidoran♂":false,
- "Nidorino":false,
- "Nidoking":true,
- "Clefairy":false,
- "Clefable":true,
- "Vulpix":true,
- "Ninetales":true,
- "Jigglypuff":false,
- "Wigglytuff":true,
- "Zubat":false, //Hell no
- "Golbat":true,
- "Oddish":false,
- "Gloom":false,
- "Vileplume":true,
- "Paras":false,
- "Parasect":false,
- "Venonat":false,
- "Venomoth":true,
- "Diglett":true,
- "Dugtrio":true,
- "Meowth":false,
- "Persian":false,
- "Psyduck":false,
- "Golduck":true,
- "Mankey":false,
- "Primeape":true,
- "Growlithe":true,
- "Arcanine":true,
- "Poliwag":false,
- "Poliwhirl":true,
- "Poliwrath":true,
- "Abra":false,
- "Kadabra":true,
- "Alakazam":true,
- "Machop":true,
- "Machoke":true,
- "Machamp":true,
- "Bellsprout":false,
- "Weepinbell":false,
- "Victreebel":true,
- "Tentacool":false,
- "Tentacruel":true,
- "Geodude":false,
- "Graveler":true,
- "Golem":true,
- "Ponyta":true,
- "Rapidash":true,
- "Slowpoke":true,
- "Slowbro":true,
- "Magnemite":false,
- "Magneton":true,
- "Farfetch'd":true,
- "Doduo":false,
- "Dodrio":false,
- "Seel":false,
- "Dewgong":false,
- "Grimer":false,
- "Muk":true,
- "Shellder":false,
- "Cloyster":true,
- "Gastly":false,
- "Haunter":false,
- "Gengar":true,
- "Onix":true,
- "Drowzee":false,
- "Hypno":false,
- "Krabby":false,
- "Kingler":false,
- "Voltorb":false,
- "Electrode":true,
- "Exeggcute":false,
- "Exeggutor":true,
- "Cubone":false,
- "Marowak":true,
- "Hitmonlee":true,
- "Hitmonchan":true,
- "Lickitung":true,
- "Koffing":true,
- "Weezing":true,
- "Rhyhorn":false,
- "Rhydon":true,
- "Chansey":false,
- "Tangela":false,
- "Kangaskhan":true,
- "Horsea":false,
- "Seadra":false,
- "Goldeen":false,
- "Seaking":false,
- "Staryu":false,
- "Starmie":true,
- "Mr. Mime":true,
- "Scyther":true,
- "Jynx":false,
- "Electabuzz":true,
- "Magmar":true,
- "Pinsir":true,
- "Tauros":true,
- "Magikarp":false,
- "Gyarados":true,
- "Lapras":true,
- "Ditto":true,
- "Eevee":false,
- "Vaporeon":true,
- "Jolteon":true,
- "Flareon":true,
- "Porygon":true,
- "Omanyte":true,
- "Omastar":true,
- "Kabuto":true,
- "Kabutops":true,
- "Aerodactyl":true,
- "Snorlax":true,
- "Articuno":true,
- "Zapdos":true,
- "Moltres":true,
- "Dratini":true,
- "Dragonair":true,
- "Dragonite":true,
- "Mewtwo":true,
- "Mew":true, //The dream
- };
- var searchdistance = 1000; //Are they worth the walk?
- var showUnwanted = true; //If it's not on the alert list should it be shown? This isn't a feature just yet...
- //Add pokemon to the list
- for (var key in pokemonAlertList) {
- var isChecked = pokemonAlertList[key]? "checked" : "";
- $("#alertlist").append('<li><input type="checkbox" '+isChecked+'></input> '+key+'</li>');
- }
- //Bind events to the list items
- $("#selectall").click(function(){
- console.log("selectall");
- $("#alertlist li").each(function(e){
- $(this).find("input").prop("checked",true);
- var name = $(this).text().replace(/\s+/g, '');
- pokemonAlertList[name] = true;
- });
- });
- $("#deselectall").click(function(){
- console.log("deselectall");
- $("#alertlist li").each(function(e){
- $(this).find("input").prop("checked",false);
- var name = $(this).text().replace(/\s+/g, '');
- pokemonAlertList[name] = false;
- });
- });
- $("#searchdistance").mousemove(function(e){
- var dis = $(this).val();
- searchdistance = dis;
- if (dis < 1000) {
- $("#distanceheader").text("Alert distance <" + dis + "m");
- } else {
- $("#distanceheader").text("No limit");
- }
- });
- $("#alertlist li input").click(function(e){
- var name = $(this).parent().text().replace(/\s+/g, '');
- var state = $(this).is(":checked");
- console.log(name,state);
- pokemonAlertList[name] = state; //Update the variable
- });
- //The cool stuff
- App.home.updateMarkers = function() {
- e = App.home;
- if (!e.map) {
- return;
- }
- for (var i in e.pokemon) {
- var t = e.pokemon[i],
- o = t.expiration_time - Math.floor(+new Date() / 1000),
- n = e.markers['pokemon-' + i];
- if (o <= 0) {
- if (n) {
- e.map.removeLayer(n);
- delete e.markers['pokemon-' + i];
- }
- delete e.pokemon[i];
- continue;
- }
- if (!n) { //Check if it's on the alert list and if its wanted
- n = e.createMarker(i, t);
- foundPokemon(e.pokedex[t.pokemonId], getDistanceMetres(App.home.latitude, App.home.longitude, n._latlng.lat, n._latlng.lng));
- }
- n.updateLabel(e.secondsToString(o));
- }
- };
- function search () {
- console.log("Scanning...");
- App.home.findNearbyPokemon(App.home.latitude, App.home.longitude, !0);
- setTimeout(search,App.home.TIMER_SCAN_DELAY); //Scans at websites desired delay, please don't change this!
- }
- function foundPokemon(pokemon,d) {
- console.log("FOUND POKEMON!" + pokemon + " " + d + " metres away");
- if (pokemonAlertList[pokemon] && (d <= searchdistance || searchdistance === "1000")) { //If it's within range
- console.log("Alerting user!");
- blip();
- App.success(
- 'There is a ' + pokemon + ' ' + d + ' metres away! Go catch it!' //Pop up
- );
- return;
- }
- }
- //Big thanks to ffejmania (and Lolologist) :)
- function getDistanceMetres(lat1,lon1,lat2,lon2) {
- var R = 6371; // Radius of the earth in km
- var dLat = deg2rad(lat2-lat1); // deg2rad below
- var dLon = deg2rad(lon2-lon1);
- var a =
- Math.sin(dLat/2) * Math.sin(dLat/2) +
- Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) *
- Math.sin(dLon/2) * Math.sin(dLon/2)
- ;
- var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
- var d = Math.floor(R * c * 1000); // Distance in m
- return d;
- }
- function deg2rad(deg) {
- return deg * (Math.PI/180);
- }
- //Start the repeating search function
- search();
- App.success(
- 'The mod has started running! It will automatically refresh the search every 30 seconds' //Pop up
- );
- }, false);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement