Moderator: Tech Team
sherkaner wrote:Well, there aren't that many scripts that have active developers and aren't working in chrome, actually.
viewtopic.php?f=526&t=132420#p2916271 gives a nice overview, chatglove was changed to work with chrome afterwards. So it's mainly chipv's scripts, and a few old ones that don't work on chrome yet. I mainly put it up for ppl interested in it (maybe new developers?).
And about greasemonkey in ff4beta: Scriptish seems to be new, but will need some adaptions. But probably greasemonkey will have a new version too, nightlies can be tried atm: https://arantius.com/misc/gm-nightly/ (likely to be unstable though).
chipv wrote:sherkaner wrote:Well, there aren't that many scripts that have active developers and aren't working in chrome, actually.
viewtopic.php?f=526&t=132420#p2916271 gives a nice overview, chatglove was changed to work with chrome afterwards. So it's mainly chipv's scripts, and a few old ones that don't work on chrome yet. I mainly put it up for ppl interested in it (maybe new developers?).
And about greasemonkey in ff4beta: Scriptish seems to be new, but will need some adaptions. But probably greasemonkey will have a new version too, nightlies can be tried atm: https://arantius.com/misc/gm-nightly/ (likely to be unstable though).
If you can think of a way to emulate multiple AJAX requests safely in Chrome let me know, there is a good reason why those scripts don't work in Chrome.
chipv wrote:Ok let me see.
chatglove gets single ajax reqs at a time, maprank for example has to manage multiple simultaneous ajax reqs at a time
and uses arrays for efficiency. Arrays here is mandatory to make sure the order of the incoming pages doesn't matter
(see Map Rank to see why), this is a non-trivial difference and is common with all the scripts that need to poll the API
with results spanning more than one page.
chipv wrote:Map Rank also does cross-site requests , something that, at present , is not easy in Chrome if not impossible last time
I checked.
sherkaner wrote:Actually, chatgloves does a request per game, and does them simultaeous. I'm not even sure whether you need to alter code if you use the override-function in the other thread, which uses a normal XMLHttpRequest to simulate the greasemonkey-variant.
var npages = 0;
var ghistobj;
var uname = "Masli";
var gorder = new Array();
function getGamesObj(page) {
var jump = 'http://www.conquerclub.com/api.php?mode=gamelist&events=Y&gs=F&un=' + uname;
if(page > 1) jump += "&page=" + page;
ghistobj = new XMLHttpRequest();
ghistobj.open('GET', jump, true);
ghistobj.onreadystatechange = function() {
if (ghistobj.readyState == 4) {
var parser = new DOMParser();
var dom = parser.parseFromString(ghistobj.responseText,"application/xml");
var games = dom.getElementsByTagName('game');
var pages = dom.getElementsByTagName('page')[0].firstChild.nodeValue;
var numGames = parseInt(dom.getElementsByTagName('games')[0].getAttribute('total'));
var pn;
if(pages.match(/^(\d+) of (\d+)$/)) {
numPages = parseInt(RegExp.$2);
}
if(page == 1) {
if(numPages > 1) {
for(var pg=2;pg<=numPages;pg++) {
getGames(pg);
}
}
}
npages++;
gorder.push(pn);
if(npages == numPages) {
alert(gorder);
}
}
}
ghistobj.send(null);
}
var leftBar = document.getElementById("leftColumn");
if(leftBar) {
var ul = leftBar.getElementsByTagName("ul");
if (ul[0]) {
getGamesObj(1);
}
}
/**
* Watch all tournaments's active games
*
* @param {String} tournament name
* @param {Integer} page id
*/
function watchTournament(tournamentName, page, state) {
var requestPage, request, data, gamesNumbers, i, e;
tournamentName = encodeURIComponent(tournamentName);
requestPage = window.location.protocol + '//www.conquerclub.com/api.php?mode=gamelist&gs=' + state + '&to=' + tournamentName + '&page=' + page;
request = new XMLHttpRequest();
request.open('GET', requestPage, true);
request.overrideMimeType('text/xml');
request.onreadystatechange = function() {
if (request.readyState == 4) {
try {
data = request.responseXML;
maxPages = /\d+ of (\d+)/i.exec(data.getElementsByTagName('page')[0].childNodes[0].nodeValue);
if (maxPages[1] > page) {
watchTournament(username, page + 1, state);
}
gamesNumbers = data.getElementsByTagName('game_number');
for (i in gamesNumbers) {
watchGame(gamesNumbers[i].childNodes[0].nodeValue);
}
}
catch (e) {
//~ alert(e.message);
}
}
};
request.send(null);
}
chipv wrote:This is the same issue as chatglove. Neither piece of software needs to know when all pages have been received because both pieces of code can go ahead and process each request on the fly without caring about the order.
I have a number of things to do after all pages have been received, and cannot do things on the fly as my data is collective.
function getGameRow(gameNumber) {
var requestPage, request, data, table, games, game, players, player, playersArray, i, e;
var gameNumber, tournament, privateGame, speedGame, map, gameType, initialTroops, playOrder, bonusCards, fortifications, warFog, round, timeRemaining;
requestPage = window.location.protocol + '//www.conquerclub.com/api.php?mode=gamelist&gn=' + gameNumber;
request = new XMLHttpRequest();
request.open('GET', requestPage, true);
request.overrideMimeType('text/xml');
request.onreadystatechange = function() {
if (request.readyState == 4) {
try {
data = request.responseXML;
games = data.getElementsByTagName('games')[0].attributes;
if (games.getNamedItem('total').nodeValue != '0') {
gameNumber = data.getElementsByTagName('game_number')[0].childNodes[0].nodeValue;
gameState = data.getElementsByTagName('game_state')[0].childNodes[0].nodeValue;
tournament = '';
if (data.getElementsByTagName('tournament')[0].childNodes.length > 0) {
tournament = data.getElementsByTagName('tournament')[0].childNodes[0].nodeValue;
}
privateGame = data.getElementsByTagName('private')[0].childNodes[0].nodeValue;
speedGame = data.getElementsByTagName('speed_game')[0].childNodes[0].nodeValue;
map = data.getElementsByTagName('map')[0].childNodes[0].nodeValue;
// Add unique maps to global array
if (!(Maps_Array.has(map))) {
Maps_Array.push(map);
}
gameType = data.getElementsByTagName('game_type')[0].childNodes[0].nodeValue;
initialTroops = data.getElementsByTagName('initial_troops')[0].childNodes[0].nodeValue;
playOrder = data.getElementsByTagName('play_order')[0].childNodes[0].nodeValue;
bonusCards = data.getElementsByTagName('bonus_cards')[0].childNodes[0].nodeValue;
fortifications = data.getElementsByTagName('fortifications')[0].childNodes[0].nodeValue;
warFog = data.getElementsByTagName('war_fog')[0].childNodes[0].nodeValue;
round = data.getElementsByTagName('round')[0].childNodes[0].nodeValue;
timeRemaining = data.getElementsByTagName('time_remaining')[0].childNodes[0].nodeValue;
players = data.getElementsByTagName('player');
playersArray = new Array();
for (i = 0; i < players.length; i++) {
player = players[i];
if (player.attributes.getNamedItem('state').nodeValue == 'Open') {
player = new playerObject('', '', '', '', '', player.attributes.getNamedItem('state').nodeValue);
} else {
player = new playerObject(player.childNodes[0].nodeValue, '', '', '', '', player.attributes.getNamedItem('state').nodeValue);
}
playersArray.push(player);
// Add unique players to global array
if (player.userid != '' && !(Players_Array.has(player.userid))) {
Players_Array.push(player.userid);
}
}
game = new gameObject(gameNumber, gameState, tournament, privateGame, speedGame, map, gameType, initialTroops, playOrder, bonusCards, fortifications, warFog, round, timeRemaining, playersArray);
Games_Array.push(game);
} else {
// Remove unexistent game
toggleGame(gameNumber, false);
updateTabNumber();
}
if (Games_Array.length == getWatchedGamesNumber()) {
addTabContent();
}
}
catch (e) {
//~ alert(e.message);
}
}
};
request.send(null);
}
chipv wrote:I believe some of you use other methods that would work in both FF and Chrome, is that right?
I could get a lot done if this is circumvented.
chipv wrote:Yes I can see although request is not an array, that is what I am referring to.
Now if this does work (and come to think of it, I did do Clan Rank in Chrome at one point so it should do)
some of my scripts use the old method of polling a text file (cross site) for the version number.
I believe some of you use other methods that would work in both FF and Chrome, is that right?
I could get a lot done if this is circumvented.
Users browsing this forum: No registered users