Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name antyantyAR + odświeżenie podczas laga
- // @version 21.37
- // @author Żug(ale adi)
- // @match http://*.margonem.pl/
- // @grant none
- // ==/UserScript==
- !function(_parseInput) {
- var idleTime = 0;
- var firstTime = true;
- parseInput = function(a, b, c) {
- _parseInput(a, b, c);
- if (firstTime) {
- setInterval(function() {
- idleTime++;
- if (idleTime > 5) {
- idleTime = 0;
- window.location.reload();
- }
- }, 2000);
- firstTime = false;
- }
- idleTime = 0;
- }
- }(parseInput);
- (() => {
- const a = window.hero,
- b = "last-coordinates-anty-stasis",
- c = JSON.parse(localStorage.getItem(b)) || {
- x: null,
- y: null,
- name: null
- },
- d = () => {
- const {
- x: d,
- y: e
- } = a, {
- name: f
- } = window.map;
- Object.assign(c, {
- x: d,
- y: e,
- name: f
- }), localStorage.setItem(b, JSON.stringify(c))
- },
- e = () => {
- Object.assign(c, {
- x: null,
- y: null,
- name: null
- }), localStorage.setItem(b, JSON.stringify(c))
- },
- f = (a, b) => {
- const {
- x: d,
- y: e
- } = c;
- return null === d && null === e ? 0 : Math.hypot(a - d, b - e)
- },
- g = (a, b, c = !1) => {
- if (c) return "0" !== window.map.col[b * window.map.x + a];
- const d = window.map.nodes.getNode(a, b);
- return !(d && d.hasOwnProperty("blocked")) || d.blocked
- },
- h = (b = !1) => {
- const c = [],
- {
- x: d,
- y: e
- } = a;
- return c.push({
- x: d + 1,
- y: e
- }), c.push({
- x: d - 1,
- y: e
- }), c.push({
- x: d,
- y: e + 1
- }), c.push({
- x: d,
- y: e - 1
- }), b ? c : c.filter(({
- x: a,
- y: b
- }) => !g(a, b))
- },
- i = () => {
- if (0 !== window.map.col.length) {
- const {
- name: a
- } = c;
- null !== a && a !== window.map.name && e();
- const b = h();
- if (0 < b.length) {
- const {
- x: a,
- y: e
- } = c;
- if (null === a || null === e) {
- const [{
- x: a,
- y: c
- }] = b;
- d(), window.road = [{
- x: a,
- y: c
- }]
- } else if (b.some(({
- x: b,
- y: c
- }) => a === b && e === c)) d(), window.road = [{
- x: a,
- y: e
- }];
- else {
- const a = b.map(({
- x: a,
- y: b
- }) => ({
- x: a,
- y: b,
- distance: f(a, b)
- })),
- c = a.sort((a, b) => a.distance - b.distance),
- [{
- x: d,
- y: e
- }] = c;
- window.road = [{
- x: d,
- y: e
- }]
- }
- } else {
- const a = h(!0),
- b = a.filter(({
- x: a,
- y: b
- }) => !g(a, b, !0)),
- c = b.map(({
- x: a,
- y: b
- }) => ({
- x: a,
- y: b,
- distance: f(a, b)
- })),
- e = c.sort((a, b) => a.distance - b.distance),
- [{
- x: i,
- y: j
- }] = e;
- d(), window.road = [{
- x: i,
- y: j
- }]
- }
- }
- },
- j = window.parseInput;
- window.parseInput = (b, ...c) => {
- b.h && 1 === b.h.stasis && (Object.assign(a, b.h), i());
- const d = j(b, ...c);
- return b.cl && 1 === a.stasis && i(), d
- }
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement