🏠 Home 

pokehuntr_auto-refresh

refresh pokehuntr map


Install this script?
  1. // ==UserScript==
  2. // @name pokehuntr_auto-refresh
  3. // @namespace niu541412
  4. // @version 0.63
  5. // @icon http://img.informer.com/icons_mac/png/128/400/400605.png
  6. // @description refresh pokehuntr map
  7. // @author niu541412@gmail.com
  8. // @license MIT License
  9. // @match *://*.pokehuntr.com/*
  10. // @match *://*.gymhuntr.com/*
  11. // @match *://*.pokefetch.com/*
  12. // @grant none
  13. // @run-at document-end
  14. // ==/UserScript==
  15. (function() {
  16. 'use strict';
  17. //full screen button
  18. document.getElementsByClassName("controls")[0].insertAdjacentHTML('beforeend', '<button id="fullscreen" class="botton button-circle" title="Toggle fullscreen" onclick="toggleFullScreen()"><span class="inner"><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABoAAAAaCAQAAAADQ4RFAAAAUklEQVR4AWOgGhgF/8HwPIrYeYgoIU0OKGIOxGm6jyJ2n5Cm8wwOQEUGKGIGQBEHoAwB0AA0FwEbSAgOBBwWmggHBOVBTjhyKU9GhBMslcAoAABPu2Hh6JIyeQAAAABJRU5ErkJggg==" style="opacity:0.6;"></span></button>');
  19. document.getElementById('fullscreen').addEventListener('click', toggleFullScreen, false);
  20. //full screen, from mozilla.org
  21. function toggleFullScreen() {
  22. var doc = window.document;
  23. var docEl = doc.documentElement;
  24. var requestFullScreen = docEl.requestFullscreen || docEl.mozRequestFullScreen || docEl.webkitRequestFullScreen || docEl.msRequestFullscreen;
  25. var cancelFullScreen = doc.exitFullscreen || doc.mozCancelFullScreen || doc.webkitExitFullscreen || doc.msExitFullscreen;
  26. if (!doc.fullscreenElement && !doc.mozFullScreenElement && !doc.webkitFullscreenElement && !doc.msFullscreenElement) {
  27. requestFullScreen.call(docEl);
  28. } else {
  29. cancelFullScreen.call(doc);
  30. }
  31. }
  32. var place = location.hash.match(/[-]*[0-9]*\.[0-9]*/g);
  33. var lttd_ctr = parseFloat(place[0]);
  34. var lgtd_ctr = parseFloat(place[1]);
  35. var ofst = 0.005;
  36. var num_of_side = 5; // scanning_region_num = num_of_side^2, if you want to change the scanning size, modify this parameter, one sacnning_region is about 0.5 km^2.
  37. function scan(lttd, lgtd, index) {
  38. setTimeout(function() {
  39. var frame = document.createElement("iframe");
  40. frame.src = "https://pokehuntr.com/#" + lttd + "," + lgtd;
  41. frame.style.visibility = "hidden";
  42. //frame.style.position = "fixed";
  43. frame.id = "Y" + lttd + "X" + lgtd;
  44. document.body.appendChild(frame);
  45. setTimeout(function() {
  46. //console.log(document.getElementById(frame.id).contentWindow.document.location.href);
  47. document.getElementById(frame.id).contentWindow.document.getElementById("scan").click();
  48. document.body.removeChild(document.getElementById(frame.id));
  49. }, 2000 + (Math.random() * 2 - 1) * 10);
  50. }, 10000 * index);
  51. }
  52. function scan_region(lttd_ctr, lgtd_ctr, num) {
  53. var index = 0;
  54. var n = (num - 1) / 2;
  55. for (var i = -n; i <= n; i++) {
  56. for (var j = -n; j <= n; j++) {
  57. var lttd = lttd_ctr + ofst * (i + (Math.random() * 2 - 1) / 1000);
  58. var lgtd = lgtd_ctr + ofst * (j + (Math.random() * 2 - 1) / 1000);
  59. scan(lttd, lgtd, index);
  60. index++;
  61. }
  62. }
  63. }
  64. document.getElementsByClassName("leaflet-control-attribution leaflet-control")[0].style.visibility = "hidden";
  65. document.getElementsByClassName("scan")[0].style.visibility = "hidden";
  66. document.getElementById("search").style.display = "none";
  67. if (document.domain == "pokehuntr.com") {
  68. scan_region(lttd_ctr, lgtd_ctr, num_of_side);
  69. setInterval(function() {
  70. //console.log(new Date());
  71. scan_region(lttd_ctr, lgtd_ctr, num_of_side);
  72. }, 420000);
  73. } else if (document.domain == "pokefetch.com") {
  74. document.querySelectorAll('a.button.button-circle')[0].style.display = "none";
  75. }
  76. })();