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!

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 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;
}