NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript==
// @name Clean FPM
// @namespace https://openuserjs.org/scripts/unlinked.nickname/Clean_FPM
// @version 1.5.0
// @description No distractions FPM, with the support for a bigger scan and auto-rescan every 5 minutes
// @author unlinked.nickname
// @match https://fastpokemap.se/*
// @grant none
// @updateURL https://openuserjs.org/meta/unlinked.nickname/Clean_FPM.meta.js
// @homepageURL https://openuserjs.org/scripts/unlinked.nickname/Clean_FPM
// ==/UserScript==
(function(window, jQuery, _) {
'use strict';
var getDate = function () {
return '[' + new Date().toLocaleString() + ']';
};
var doBigScan = function (ev) {
window.clearTimeout(bigScanTimeout);
window.clearTimeout(activeScannerTimeout);
bigScanTimeout = window.setTimeout(function (ev) {
if (ev) {
window.circle.setLatLng(new L.LatLng(ev.latlng.lat, ev.latlng.lng));
}
var circleBounds = window.circle.getBounds();
var circleSize = {
lat: Math.abs(circleBounds._northEast.lat - circleBounds._southWest.lat),
lng: Math.abs(circleBounds._northEast.lng - circleBounds._southWest.lng)
};
var localQueue = [];
localQueue.push({
lat: circleBounds._northEast.lat,
lng: circleBounds._northEast.lng,
});
localQueue.push({
lat: circleBounds._northEast.lat,
lng: circleBounds._southWest.lng
});
localQueue.push({
lat: circleBounds._southWest.lat,
lng: circleBounds._northEast.lng
});
localQueue.push({
lat: circleBounds._southWest.lat,
lng: circleBounds._southWest.lng
});
localQueue.push({
lat: window.marker._latlng.lat - circleSize.lat,
lng: window.marker._latlng.lng
});
localQueue.push({
lat: window.marker._latlng.lat + circleSize.lat,
lng: window.marker._latlng.lng
});
localQueue.push({
lat: window.marker._latlng.lat,
lng: window.marker._latlng.lng - circleSize.lng
});
localQueue.push({
lat: window.marker._latlng.lat,
lng: window.marker._latlng.lng + circleSize.lng
});
localQueue.forEach(function (point) {
point.circle = new L.circle(point, {
color: 'red',
fillColor: '#f03',
fillOpacity: 0.25,
radius: 200
});
window.map.addLayer(point.circle);
});
localQueue = _.shuffle(localQueue);
queue = queue.concat(localQueue);
if (cleanFPMSettings.autoScanState) {
activeScannerTimeout = window.setTimeout(doRescan, cleanFPMSettings.autoRescanTime);
}
console.log(getDate(), 'Added to queue:', localQueue);
}, 1250, ev);
};
var doRescan = function () {
queue.push(window.marker._latlng);
doBigScan();
console.log(getDate(), 'Triggered rescan');
};
var consumeQueue = function () {
if (queue.length && !window.isScanning) {
window.isScanning = true;
if (!jQuery('.scan').hasClass('active')) {
jQuery('.scan').removeClass('success').removeClass('failed').addClass('active'); // Start spinning
}
var nextScanPoint = queue.shift();
window.getPokemon(nextScanPoint.lat, nextScanPoint.lng);
window.throttledLoadCache(nextScanPoint);
if (nextScanPoint.circle) {
window.setTimeout(function (circle) {
window.map.removeLayer(circle);
}, 5000, nextScanPoint.circle);
}
console.log(getDate(), 'Pushed to scan:', nextScanPoint);
}
};
var setupBigScanEvent = function () {
if (typeof window.map !== 'undefined') {
window.map.on('click', doBigScan);
window.map.on('locationfound', doBigScan);
jQuery('#autoscan').on('click', function () {
cleanFPMSettings.autoScanState = !cleanFPMSettings.autoScanState;
window.localStorage.setItem(localStorageKey, JSON.stringify(cleanFPMSettings));
jQuery('#autoscan').toggleClass('spin');
if (cleanFPMSettings.autoScanState) {
activeScannerTimeout = window.setTimeout(doRescan, cleanFPMSettings.autoRescanTime);
}
});
console.log(getDate(), 'Setup big scan event');
} else {
var setupBigScanTimeout = window.setTimeout(setupBigScanEvent, 100);
}
};
var bigScanTimeout;
var queue = [];
var removals = ['.desktop-header', '.mobile-header', '.adroom', '.slicknav_menu'];
var localStorageKey = 'cleanFPMSettings';
var cleanFPMSettings = localStorage.getItem(localStorageKey);
var minimumSettingsVersion = 0;
if (cleanFPMSettings === null || cleanFPMSettings.settingsVerion < minimumSettingsVersion) {
cleanFPMSettings = {
autoScanState: false,
settingsVerion: 0,
autoRescanTime: 300000,
};
} else {
cleanFPMSettings = JSON.parse(cleanFPMSettings);
}
removals.forEach(function (selector) {
jQuery(selector).remove();
console.log(getDate(), 'Removed element:', selector);
});
jQuery('.infowindow .close').click();
console.log(getDate(), 'Closed infoWindow');
jQuery('.right').append('<button class="autoscan" id="autoscan"><img src="img/scan.png" title="Autoscan"></button>');
L.DomEvent.disableClickPropagation(jQuery('#autoscan')[0]);
jQuery('<style>').prop('type', 'text/css').html('.spin {-webkit-animation:spin 1s linear infinite; -moz-animation:spin 1s linear infinite; animation:spin 1s linear infinite;}').appendTo('head');
jQuery('<style>').prop('type', 'text/css').html('#map {height: 100vh !important}').appendTo('head');
console.log(getDate(), 'Made map full-size');
if (cleanFPMSettings.autoScanState) {
jQuery('#autoscan').toggleClass('spin');
}
var activeScannerTimeout = window.setTimeout(doRescan, cleanFPMSettings.autoRescanTime);
var consumeQueueInterval = window.setInterval(consumeQueue, 750);
var setupBigScanTimeout = window.setTimeout(setupBigScanEvent, 100);
})(window, jQuery, _);