noname/game/phantom.js

30 lines
812 B
JavaScript
Raw Normal View History

2017-11-06 05:55:03 +00:00
var fs = require('fs');
var webpage = require('webpage')
var load = function(id){
var page = webpage.create();
2016-04-27 15:01:25 +00:00
page.settings.userAgent = 'SpecialAgent';
2017-11-06 05:55:03 +00:00
page.open('file://'+fs.workingDirectory+'/index.html?server='+id, function(status) {
2016-04-27 15:01:25 +00:00
if(status !== 'success') {
2017-11-06 05:55:03 +00:00
console.log(fs.workingDirectory);
2016-04-27 15:01:25 +00:00
console.log('Unable to access network');
}
setInterval(function(){
2017-11-06 05:55:03 +00:00
if(page.evaluate(function(){
2016-04-27 15:01:25 +00:00
if(!lib.node||!lib.node.clients||!lib.node.clients.length){
2017-11-06 05:55:03 +00:00
return true;
2016-04-27 15:01:25 +00:00
}
2017-11-06 05:55:03 +00:00
else{
return false;
}
})){
page.close();
load(id);
}
},600000);
2016-04-27 15:01:25 +00:00
});
}
2016-04-26 02:34:31 +00:00
2016-04-27 15:01:25 +00:00
load(1);
2017-11-06 05:55:03 +00:00
load(2);
load(3);