Advertisement
Guest User

Untitled

a guest
Jan 20th, 2020
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.21 KB | None | 0 0
  1. // ==UserScript==
  2. // @name antyantyAR + odświeżenie podczas laga
  3. // @version 21.37
  4. // @author Żug(ale adi)
  5. // @match http://*.margonem.pl/
  6. // @grant none
  7. // ==/UserScript==
  8.  
  9. !function(_parseInput) {
  10. var idleTime = 0;
  11. var firstTime = true;
  12. parseInput = function(a, b, c) {
  13. _parseInput(a, b, c);
  14. if (firstTime) {
  15. setInterval(function() {
  16. idleTime++;
  17. if (idleTime > 5) {
  18. idleTime = 0;
  19. window.location.reload();
  20. }
  21. }, 2000);
  22. firstTime = false;
  23. }
  24. idleTime = 0;
  25. }
  26. }(parseInput);
  27.  
  28. (() => {
  29. const a = window.hero,
  30. b = "last-coordinates-anty-stasis",
  31. c = JSON.parse(localStorage.getItem(b)) || {
  32. x: null,
  33. y: null,
  34. name: null
  35. },
  36. d = () => {
  37. const {
  38. x: d,
  39. y: e
  40. } = a, {
  41. name: f
  42. } = window.map;
  43. Object.assign(c, {
  44. x: d,
  45. y: e,
  46. name: f
  47. }), localStorage.setItem(b, JSON.stringify(c))
  48. },
  49. e = () => {
  50. Object.assign(c, {
  51. x: null,
  52. y: null,
  53. name: null
  54. }), localStorage.setItem(b, JSON.stringify(c))
  55. },
  56. f = (a, b) => {
  57. const {
  58. x: d,
  59. y: e
  60. } = c;
  61. return null === d && null === e ? 0 : Math.hypot(a - d, b - e)
  62. },
  63. g = (a, b, c = !1) => {
  64. if (c) return "0" !== window.map.col[b * window.map.x + a];
  65. const d = window.map.nodes.getNode(a, b);
  66. return !(d && d.hasOwnProperty("blocked")) || d.blocked
  67. },
  68. h = (b = !1) => {
  69. const c = [],
  70. {
  71. x: d,
  72. y: e
  73. } = a;
  74. return c.push({
  75. x: d + 1,
  76. y: e
  77. }), c.push({
  78. x: d - 1,
  79. y: e
  80. }), c.push({
  81. x: d,
  82. y: e + 1
  83. }), c.push({
  84. x: d,
  85. y: e - 1
  86. }), b ? c : c.filter(({
  87. x: a,
  88. y: b
  89. }) => !g(a, b))
  90. },
  91. i = () => {
  92. if (0 !== window.map.col.length) {
  93. const {
  94. name: a
  95. } = c;
  96. null !== a && a !== window.map.name && e();
  97. const b = h();
  98. if (0 < b.length) {
  99. const {
  100. x: a,
  101. y: e
  102. } = c;
  103. if (null === a || null === e) {
  104. const [{
  105. x: a,
  106. y: c
  107. }] = b;
  108. d(), window.road = [{
  109. x: a,
  110. y: c
  111. }]
  112. } else if (b.some(({
  113. x: b,
  114. y: c
  115. }) => a === b && e === c)) d(), window.road = [{
  116. x: a,
  117. y: e
  118. }];
  119. else {
  120. const a = b.map(({
  121. x: a,
  122. y: b
  123. }) => ({
  124. x: a,
  125. y: b,
  126. distance: f(a, b)
  127. })),
  128. c = a.sort((a, b) => a.distance - b.distance),
  129. [{
  130. x: d,
  131. y: e
  132. }] = c;
  133. window.road = [{
  134. x: d,
  135. y: e
  136. }]
  137. }
  138. } else {
  139. const a = h(!0),
  140. b = a.filter(({
  141. x: a,
  142. y: b
  143. }) => !g(a, b, !0)),
  144. c = b.map(({
  145. x: a,
  146. y: b
  147. }) => ({
  148. x: a,
  149. y: b,
  150. distance: f(a, b)
  151. })),
  152. e = c.sort((a, b) => a.distance - b.distance),
  153. [{
  154. x: i,
  155. y: j
  156. }] = e;
  157. d(), window.road = [{
  158. x: i,
  159. y: j
  160. }]
  161. }
  162. }
  163. },
  164. j = window.parseInput;
  165. window.parseInput = (b, ...c) => {
  166. b.h && 1 === b.h.stasis && (Object.assign(a, b.h), i());
  167. const d = j(b, ...c);
  168. return b.cl && 1 === a.stasis && i(), d
  169. }
  170. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement