Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- 1. Press F12 to open the debug console.
- 2. Paste this code to the console and press ENTER.
- 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).
- 4. F5 will stop the script. If you want to rerun it, start again from step 1.
- Enjoy!
- nguyenvlm
- */
- function CPRun(mode) {
- var captureBtnList = document.querySelectorAll('a.button.capture'),
- pirateFortress = document.querySelector('#js_CityPosition17Link'),
- progressTime = document.querySelector('#missionProgressTime'),
- captcha = document.querySelector('img.captchaImage');
- if (progressTime != null) {
- var ptime = progressTime.innerText.replace(' ', '').replace(/\D/g,' ').trim().split(' ').map(Number);
- if (ptime.length == 3) {
- ptime = ptime[0]*3600 + ptime[1]*60 + ptime[2];
- }
- else if (ptime.length == 2) {
- ptime = ptime[0]*60 + ptime[1];
- }
- else {
- ptime = ptime[0];
- }
- // alert(ptime);
- setTimeout(CPRun, Math.floor(ptime+Math.random()*5)*1000, mode);
- }
- else if (pirateFortress.title == "Free Building Ground") {
- alert("Pirate fortress hasn't been built in this town!")
- setTimeout(CPRun, 10*1000, mode);
- }
- else {
- if (captureBtnList.length == 0) {
- click(pirateFortress);
- setTimeout(CPRun, 4*1000, mode);
- }
- else if (mode >= captureBtnList.length) {
- alert("Your pirate fortress hasn't reached the required level to access to this run (mode="+mode+")");
- setTimeout(CPRun, 10*1000, mode);
- }
- else {
- var captureBtn = captureBtnList[mode]
- if (captcha != null) {
- var captchaInput = document.querySelector('input#captcha'),
- captchaSubmitBtn = document.querySelector('input.button[value="Capture"]');
- var noti = new Audio("https://notificationsounds.com/soundfiles/c6e19e830859f2cb9f7c8f8cacb8d2a6/file-sounds-1128-beyond-doubt-2.mp3");
- if (noti != null) noti.play();
- setTimeout(CPRun, 5*1000, mode);
- }
- else if (captureBtn != null) {
- click(captureBtn);
- setTimeout(CPRun, Math.floor(Math.random()*5)*1000, mode);
- }
- else if (pirateFortress != null) {
- click(pirateFortress);
- setTimeout(CPRun, Math.floor(Math.random()*5)*1000, mode);
- }
- else {
- setTimeout(CPRun, Math.floor(Math.random()*5)*1000, mode);
- }
- }
- }
- return 0;
- }
- function click(node) {
- var rect = node.getBoundingClientRect();
- var x = rect.x + Math.floor(Math.random()*rect.width), y = rect.y + Math.floor(Math.random()*rect.height);
- var ev = new MouseEvent('click', {
- 'view': window,
- 'bubbles': true,
- 'cancelable': true,
- 'screenX': x + Math.floor(Math.random()*100),
- 'screenY': y + Math.floor(Math.random()*50),
- 'clientX': x,
- 'clientY': y,
- 'pageX': x,
- 'pageY': y,
- });
- node.dispatchEvent(ev);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement