Advertisement
Sharley

Untitled

Aug 1st, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.56 KB | None | 0 0
  1. // ==UserScript==
  2. // @name auto zapraszanie na kolos
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description try to take over the world!
  6. // @author Sharley
  7. // @match http://hutena.margonem.pl/
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. g.loadQueue.push({
  12. fun: () => {
  13. if(!localStorage.getItem(`invitePos`))
  14. {
  15. let tmpObj = {
  16. x: 0,
  17. y: 0
  18. };
  19. localStorage.setItem(`invitePos`, JSON.stringify(tmpObj));
  20. };
  21.  
  22. const squad = []
  23. let inviteInterval
  24. let coords = JSON.parse(localStorage.getItem(`invitePos`));
  25. if(!localStorage.getItem(`inviteInput`)) localStorage.setItem('inviteInput','Wypisz kogo zapraszać');
  26.  
  27.  
  28. const startGetPlayers = () => {
  29. inviteInterval = setInterval(getPlayers, 2000)
  30. }
  31.  
  32. const getPlayers = () => {
  33. for(n in g.other){
  34. if ((Math.abs(hero.x - g.other[n].x) <= 1 && Math.abs(hero.y - g.other[n].y) <= 1) && !isset(g.party[n]) && squad.includes(g.other[n].nick)){
  35. _g("party&a=inv&id="+n)
  36. }
  37. }
  38. }
  39.  
  40. const stopAction = () => {
  41. clearInterval(inviteInterval)
  42. }
  43.  
  44. if(squad == null)
  45. {
  46. squad = [];
  47. };
  48.  
  49. const inviteMenu = document.createElement('div')
  50. inviteMenu.style.position = 'absolute';
  51. inviteMenu.style.left = `${coords.x}px`;
  52. inviteMenu.style.top = `${coords.y}px`;
  53. inviteMenu.style.background = '#333';
  54. inviteMenu.style.width = `300px`;
  55. inviteMenu.style.height = `200px`;
  56. inviteMenu.style.border = 'none';
  57.  
  58. const input = document.createElement('input')
  59. input.id = 'invite-input'
  60. input.value = localStorage.getItem(`inviteInput`)
  61.  
  62. const button = document.createElement('button')
  63. button.textContent = 'Zapraszaj'
  64.  
  65. const buttonOff = document.createElement('button')
  66. buttonOff.textContent = 'Wyłącz'
  67.  
  68. input.addEventListener('input', (e) => {
  69. localStorage.setItem('inviteInput', e.target.value);
  70. squad.push(e.target.value);
  71. })
  72.  
  73. button.addEventListener('click', () => {
  74. message('Odpalam')
  75. startGetPlayers()
  76. })
  77.  
  78. buttonOff.addEventListener('click', () => {
  79. message('Wylaczam zapraszanie')
  80. stopAction()
  81. })
  82.  
  83.  
  84. document.body.appendChild(inviteMenu)
  85. inviteMenu.appendChild(button)
  86. inviteMenu.appendChild(buttonOff)
  87.  
  88. $(inviteMenu).draggable({
  89. stop: () => {
  90. let tmpObj = {
  91. x: parseInt(inviteMenu.style.left),
  92. y: parseInt(inviteMenu.style.top)
  93. };
  94. localStorage.setItem(`invitePos`, JSON.stringify(tmpObj));
  95. message(`Zapisano pozycję`);
  96. }
  97. });
  98. }
  99. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement