Conquer Club

Some invitation automations

Archival storage to keep things organized and uncluttered. Can't find what you need? Search for old topics here.

Moderator: Tech Team

Forum rules
Please read the Community Guidelines before posting.

Some invitation automations

Postby sherkaner on Mon Sep 20, 2010 3:04 pm

I'm running a tournament, and I had to invite a lot of people for it (2*6 games, 4 people per game currently). So I created some javascript to make inviting a bit easier.
And I guess I should share it for the people who'd like to do the same and have some javascript-knowledge.
First: I have FireBug/FireQuery installed, and add jQuery to the page (though it isn't strictly necessary, I'm too lazy to do it differently)
Then I execute my code in the console:
Code: Select all
reserve = function(games) {
  for (var i = 0; i < games.length; i++) {
  var game = games[i];
  for (var j = 0; j < game.players.length; j++) {
   name = game.players[j];
   jQuery.ajax({
    async: false,
    url:"player.php?submit=Reserve",
    data:{game:game.nr,username:name},
    type:"POST",
    success: function(html) {
        console.log(game.nr);
    }
   });
  }
  }
}
var games = [{nr:7584984, players:["Commander62890","perchorin","jrh_cardinal","Krissan"]},
{nr:7584985, players:["Risk_Averse","Aalmeida17","Cognac","Squirly"]},
{nr:7584986, players:["Nesterdude","SirSebstar","Sherkaner","Shoop76"]},
{nr:7584987, players:["StevieQ","caymanmew","I_AM_BOGEY","Woolleyy"]},
{nr:7584988, players:["patrickaa317","HMSPS","Edgron","skillfusniper33"]},
{nr:7584989, players:["Yojimbo28","Mudpuppy","hwhrhett","shaneback"]},
{nr:7584992, players:["Risky_stud","pepperjack","bjf5893","drunkmonkey"]}];
reserve(games);

This does the invites for all games, provided there are still spots left and all the names are correct, and you are on a ConquerClub page (cross-domain..). It executes 1 call to ConquerClub for every invite (which I'd have to do anyway, this way it's just faster). And after that it now posts the entire HTML of the page to the console (could do this better). A lot of restrictions, but it works.
I think a script could be made for inviting from this base, but you'd have to be careful about the restrictions.


After that I even thought I should be able to fetch the names etc. from google docs. Same mechanism of executing, except that you have to be on the page:
Code: Select all
String.prototype.trim = function() {
  return this.replace(/^\s+|\s+$/g, '');
};
var games = [];
var column = 13;
var row = 67;
var waffle = jQuery("#2-grid-table-quadrantscrollable tr");
for (var i = 0; i < 6; i++) {
    var start = row + 4 * i;
    var gameNr = waffle.eq(start).find("td").eq(column + 1).html().trim();
    for (var j = 0; j < 4; j++) {
        var player1 = waffle.eq(start).find("td").eq(column).html().trim();
        var player2 = waffle.eq(start + 1).find("td").eq(column).html().trim();
        var player3 = waffle.eq(start + 2).find("td").eq(column).html().trim();
        var player4 = waffle.eq(start + 3).find("td").eq(column).html().trim();
    }
    games.push({
        nr: gameNr,
        players:[player1,player2,player3,player4]
    });
}
JSON.stringify(games);

gives a string you can use in the first one. I had the player names in column 13, rows 68 to *, with the game number next to it.
https://spreadsheets.google.com/ccc?key ... l=en#gid=2 (3rd tab if this doesn't lead there directly)
if you're curious how it looked exactly. And then you'll see that I started doing this after I sent out 8*32 manually...
Colonel sherkaner
 
Posts: 1595
Joined: Thu May 03, 2007 3:21 am
Location: Zwolle

Re: Some invitation automations

Postby barrycarter on Tue Sep 21, 2010 6:24 pm

Have you looked into iMacros? I use it to "mass" create games 5-10 at a time (sometimes more). http://www.iopus.com/download/imacros-firefox
Sergeant 1st Class barrycarter
 
Posts: 51
Joined: Sat Jul 31, 2010 10:42 am


Return to Tool Archives

Who is online

Users browsing this forum: No registered users

cron