Skip to content

Commit

Permalink
Updated foursquare and pivotal tracker handlers. Added posterous hand…
Browse files Browse the repository at this point in the history
…ler.
  • Loading branch information
codebutler committed Feb 14, 2011
1 parent 4a415b6 commit 1733122
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 11 deletions.
9 changes: 2 additions & 7 deletions xpi/handlers/foursquare.js
Expand Up @@ -19,12 +19,7 @@ register({
// Maybe this is useful for something in the future..?
this.userId = userId;

// 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;
}
this.userName = resp.body.querySelector('#personDetail h2 a').textContent;
this.userAvatar = resp.body.querySelector('#personDetail img').src;
},
});
8 changes: 4 additions & 4 deletions xpi/handlers/pivotal.js
Expand Up @@ -3,22 +3,22 @@
register({
name: 'Pivotal Tracker',
url: 'http://www.pivotaltracker.com/dashboard',
sessionCookieNames: [ '_myapp_session' ],
sessionCookieNames: [ 'tracker_session' ],
domains: [ 'pivotaltracker.com' ],

processPacket: function () {
var cookie = this.firstPacket.cookies['_myapp_session'];
var cookie = this.firstPacket.cookies['tracker_session'];
var railsSession = RailsHelper.parseSessionCookie(cookie);
if (!railsSession.signin_person_id) {
this.sessionId = null;
return;
}
this.sessionId = railsSession.session_id;
this.firstPacket._myapp_session = railsSession;
this.firstPacket.tracker_session = railsSession;
},

identifyUser: function () {
var resp = this.httpGet(this.siteUrl);
this.userName = resp.body.querySelector('.welcome_message').textContent.replace('Welcome,', '').trim();
}
});
});
27 changes: 27 additions & 0 deletions xpi/handlers/posterous.js
@@ -0,0 +1,27 @@
// Authors:
// Eric Butler <eric@codebutler.com>

register({
name: 'Posterous',

matchPacket: function (packet) {
if (packet.cookies['_sharebymail_session_id'] && packet.cookies['posterous_mp']) {
var data = JSON.parse(unescape(packet.cookies['posterous_mp']));
return data.all && data.all.registered == "true";
}
return false;
},

processPacket: function () {
this.sessionId = this.firstPacket.cookies['_sharebymail_session_id'];
},

identifyUser: function () {
var resp = this.httpGet('http://posterous.com/manage/settings/contact');
var firstName = resp.body.querySelector('#user_firstname').value;
var lastName = resp.body.querySelector('#user_lastname').value;

this.userName = firstName + ' ' + lastName;
this.userAvatar = resp.body.querySelector('img[alt="user photo"]').src;
}
});

0 comments on commit 1733122

Please sign in to comment.