Skip to content

Commit

Permalink
Fix Foursquare handler name/avatar grabbing
Browse files Browse the repository at this point in the history
 * Some redirects were causing odd behavior when pulling down
 http://foursquare.com/user, so now just use / instead of /user
  • Loading branch information
craSH committed Oct 17, 2010
1 parent f4656e4 commit c862443
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions xpi/handlers/foursquare.js
Expand Up @@ -2,6 +2,7 @@
// Eric Butler <eric@codebutler.com>
register({
name: 'Foursquare',
url: 'http://foursquare.com/',
domains: [ 'foursquare.com' ],
sessionCookieNames: [ 'ext_id', 'XSESSIONID' ],

Expand All @@ -11,15 +12,19 @@ register({
},

identifyUser: function () {
var resp = this.httpGet('http://foursquare.com/user');
var resp = this.httpGet(this.siteUrl);
var path = resp.request.channel.URI.path;
var userId = path.split('/')[2];

// Maybe this is useful for something in the future..?
this.userId = userId;
this.userName = resp.body.querySelectorAll('.withImage a')[1].innerHTML
this.userAvatar = resp.body.querySelector('.withImage img').src;

// Get image object for user avatar (contains their name, too!)
var user_img = resp.body.querySelector('.withImage img');
this.userName = user_img.alt;
this.userAvatar = user_img.src;
if (this.userAvatar.substr(0, 4) != 'http') {
this.userAvatar = 'http://foursquare.com/' + this.userAvatar;
}
},
});
});

0 comments on commit c862443

Please sign in to comment.