Ikariam Auto Piracy test

Automatically click capture button, though you need to input verification code from time to time. Please note the beta versions are still not functioning!

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        Ikariam Auto Piracy test
// @namespace   ikariam
// @description Automatically click capture button, though you need to input verification code from time to time. Please note the beta versions are still not functioning!
// @include     http://*-*.ikariam.gameforge.com/
// @version     beta 0.1
// @grant       none
// ==/UserScript==

function click_townView(){
var townView=document.evaluate("//a[@title='Inspect the selected town']", document.body, null, 9, null).singleNodeValue;   
if ( townView ){ delay = getRandomInt (1000, 2000); townView.click(); }
} //eof

function click_pirateFort(){
var pirateFort=document.evaluate("//a[contains(@title,'Pirate Fortress')]", document.body, null, 9, null).singleNodeValue;   
if ( pirateFort ){ pirateFort.click(); }
else{ delay = getRandomInt (1000, 2000); click_townView(); }
} //eof

/* click_captureSmuglersBtn() is the function that keep clicking "Capture" button
   every 2.5 minutes.
   But if we are thrown out of the pirate fort, we need to get back into Town View,
   and then into the Pirate Fort, so we have click_townView() and click_pirateFort() too
*/

function click_captureSmuglersBtn(){
var captureSmuglersBtn=document.evaluate("//a[contains(@class,'button capture')]", document.body, null, 9, null).singleNodeValue;   
if ( captureSmuglersBtn  ){ captureSmuglersBtn.click();
//setTimeout( clickBtn, 1500 );  // go to next city
window.clearInterval(int1);
setTimeout( myPause, 151000 ); // pause for 2.5 minutes and 1 sec
}
else{ delay = getRandomInt (1000, 2000); click_pirateFort(); }
} //eof

var delay = getRandomInt (1000, 3000);

function myPause(){  int1=setInterval( click_captureSmuglersBtn, delay); }

var int1=setInterval( click_captureSmuglersBtn, delay);

//************  calculate random delays  **************
function getRandomInt (min, max) {
    return Math.floor(Math.random() * (max - min + 1)) + min;
}