Advertisement
Guest User

Ikariam Piracy

a guest
Feb 22nd, 2020
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  
  3. 1. Press F12 to open the debug console.
  4. 2. Paste this code to the console and press ENTER.
  5. 3. Type CPRun(mode) to the console and press ENTER to start the script with the mode you want (0: 2m30s, 1: 7m30s, 2: 15m, 3: 30m, and so on).
  6. 4. F5 will stop the script. If you want to rerun it, start again from step 1.
  7.  
  8. Enjoy!
  9. nguyenvlm
  10.  
  11.  */
  12.  
  13.  
  14. function CPRun(mode) {
  15.     var captureBtnList = document.querySelectorAll('a.button.capture'),
  16.         pirateFortress = document.querySelector('#js_CityPosition17Link'),
  17.         progressTime = document.querySelector('#missionProgressTime'),
  18.         captcha = document.querySelector('img.captchaImage');
  19.     if (progressTime != null) {
  20.         var ptime = progressTime.innerText.replace(' ', '').replace(/\D/g,' ').trim().split(' ').map(Number);
  21.         if (ptime.length == 3) {
  22.             ptime = ptime[0]*3600 + ptime[1]*60 + ptime[2];
  23.         }
  24.         else if (ptime.length == 2) {
  25.             ptime = ptime[0]*60 + ptime[1];
  26.         }
  27.         else {
  28.             ptime = ptime[0];
  29.         }
  30.         // alert(ptime);
  31.         setTimeout(CPRun, Math.floor(ptime+Math.random()*5)*1000, mode);
  32.     }
  33.     else if (pirateFortress.title == "Free Building Ground") {
  34.         alert("Pirate fortress hasn't been built in this town!")
  35.         setTimeout(CPRun, 10*1000, mode);
  36.     }
  37.     else {
  38.         if (captureBtnList.length == 0) {
  39.             click(pirateFortress);
  40.             setTimeout(CPRun, 4*1000, mode);
  41.         }
  42.         else if (mode >= captureBtnList.length) {
  43.             alert("Your pirate fortress hasn't reached the required level to access to this run (mode="+mode+")");
  44.             setTimeout(CPRun, 10*1000, mode);
  45.         }
  46.         else {
  47.             var captureBtn = captureBtnList[mode]
  48.             if (captcha != null) {
  49.                 var captchaInput = document.querySelector('input#captcha'),
  50.                     captchaSubmitBtn = document.querySelector('input.button[value="Capture"]');
  51.                 var noti = new Audio("https://notificationsounds.com/soundfiles/c6e19e830859f2cb9f7c8f8cacb8d2a6/file-sounds-1128-beyond-doubt-2.mp3");
  52.                 if (noti != null) noti.play();
  53.                 setTimeout(CPRun, 5*1000, mode);
  54.             }
  55.             else if (captureBtn != null) {
  56.                 click(captureBtn);
  57.                 setTimeout(CPRun, Math.floor(Math.random()*5)*1000, mode);
  58.             }
  59.             else if (pirateFortress != null) {
  60.                 click(pirateFortress);
  61.                 setTimeout(CPRun, Math.floor(Math.random()*5)*1000, mode);
  62.             }
  63.             else {
  64.                 setTimeout(CPRun, Math.floor(Math.random()*5)*1000, mode);
  65.             }
  66.         }
  67.     }
  68.     return 0;
  69. }
  70.  
  71.  
  72. function click(node) {
  73.     var rect = node.getBoundingClientRect();
  74.     var x = rect.x + Math.floor(Math.random()*rect.width), y = rect.y + Math.floor(Math.random()*rect.height);
  75.     var ev = new MouseEvent('click', {
  76.         'view': window,
  77.         'bubbles': true,
  78.         'cancelable': true,
  79.         'screenX': x + Math.floor(Math.random()*100),
  80.         'screenY': y + Math.floor(Math.random()*50),
  81.         'clientX': x,
  82.         'clientY': y,
  83.         'pageX': x,
  84.         'pageY': y,
  85.     });
  86.     node.dispatchEvent(ev);
  87.     return 0;
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement