Опробовал ваш код но к сожалению он почему то не работает.
Прилагаю весь код.
P.s. таймаут надо делать после каждого элемента массива.
// ==UserScript==
// @name TM_flyga
// @namespace *
// @include [url]http://*tmgame.ru/game.php[/url]
// ==/UserScript==
var loc;
var tmDomain;
var actions;
var tmDomain;
var id;
var art_id;
actionSpusk = new Array();
actionSpusk = new Array(
"action.php?xml=1&acode=move¶m[x]=5¶m[y]=7",
"action.php?xml=1&acode=move¶m[x]=5¶m[y]=8",
"action.php?xml=1&acode=move¶m[x]=4¶m[y]=9",
"action.php?xml=1&acode=chgloc¶m[trans_id]=1",
"action.php?xml=1&acode=move¶m[x]=3¶m[y]=1",
"action.php?xml=1&acode=move¶m[x]=3¶m[y]=2",
"action.php?xml=1&acode=move¶m[x]=2¶m[y]=3",
"action.php?xml=1&acode=move¶m[x]=2¶m[y]=4",
"action.php?xml=1&acode=move¶m[x]=1¶m[y]=5",
"action.php?xml=1&acode=move¶m[x]=1¶m[y]=6",
"action.php?xml=1&acode=move¶m[x]=0¶m[y]=6",
"action.php?xml=1&acode=chgloc¶m[trans_id]=10",
"action.php?xml=1&acode=move¶m[x]=11¶m[y]=7",
"action.php?xml=1&acode=move¶m[x]=11¶m[y]=8",
"action.php?xml=1&acode=move¶m[x]=10¶m[y]=9",
"action.php?xml=1&acode=chgloc¶m[trans_id]=7",
"action.php?xml=1&acode=move¶m[x]=9¶m[y]=1",
"action.php?xml=1&acode=move¶m[x]=9¶m[y]=2",
"action.php?xml=1&acode=move¶m[x]=8¶m[y]=3",
"action.php?xml=1&acode=move¶m[x]=8¶m[y]=4",
"action.php?xml=1&acode=move¶m[x]=7¶m[y]=4",
"action.php?xml=1&acode=move¶m[x]=6¶m[y]=4",
"action.php?xml=1&acode=move¶m[x]=5¶m[y]=5",
"action.php?xml=1&acode=move¶m[x]=4¶m[y]=5",
"action.php?xml=1&f=1&obj_id=1160&obj_type=7"
);
(function(){
tmDomain=document.location.href.match(/http:\/\/[^\/]+/gi);
tmDomain=tmDomain?tmDomain[0]:"http://www.tmgame.ru";
refresh();
}
)();
loc=document.location.href;
function refresh() {
GM_xmlhttpRequest({
method: 'GET',
url: tmDomain+'/suka',
headers: {
'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey/0.3',
'Accept': 'application/atom+xml,application/xml,text/xml',
},
});
var url = (tmDomain+'/srv/user/bpxml?'+rand(1000,9999));
GM_xmlhttpRequest({
method: 'GET',
url: url,
headers: {
'User-agent': 'Mozilla/4.0 (compatible)',
'Accept': 'application/atom+xml,application/xml,text/xml',
}
,
onload: function(responseDetails) {
var parser = new DOMParser();
var resp=responseDetails.responseText;
resp=resp.replace(/\=([^\"])/g,'!$1').replace(/\&/g,'@');
var dom = parser.parseFromString(resp,"application/xml");
var items = dom.getElementsByTagName('item');
for (var q=0;q<items.length;q++){
art_id = items[q].getAttribute("art_id");
id = items[q].getAttribute("id");
var amount = items[q].getAttribute("amount");
var vUrl;
if (art_id==160 && amount<100) {
setTimeout(function () {
var names = [];
for (var i in actionSpuck)
names.push(i);
var i=0;
(function(i){
calee=arguments.callee;
GM_xmlhttpRequest({method: "GET", url: tmDomain+'/'+actionSpuck[names[i]],callback:function(){
calee(++i);
}});
})(i);
}, 2000);
}
}
}
});
//setTimeout(refresh, 10000);
}
function locCheck(substr){
return loc.indexOf(substr)>=0;
}
function rand(Min,Max){
var iMin=parseInt(Min);
var iMax=parseInt(Max);
return (Math.floor(((Math.random()*(iMax-iMin+1))+iMin)));
}