Permalink
Browse files

Updated harvest handler.

  • Loading branch information...
1 parent 77103c4 commit 1896d19d034d3a348e84c4970d2ea654c9394cf3 @codebutler committed Feb 16, 2011
Showing with 11 additions and 8 deletions.
  1. +11 −8 xpi/handlers/harvest.js
View
19 xpi/handlers/harvest.js
@@ -2,27 +2,30 @@
// Eric Butler <eric@codebutler.com>
register({
name: 'Harvest',
- domains: [ 'harvestapp.com' ],
- sessionCookieNames: [ '_enc_sess' ],
+ sessionCookieNames: [ '_harvest_sess' ],
+ matchPacket: function (packet) {
+ return (packet.host.match(/\.harvestapp.com$/));
+ },
+
processPacket: function () {
this.siteUrl = 'http://' + this.firstPacket.host;
- var cookie = this.firstPacket.cookies['_enc_sess'];
+ var cookie = this.firstPacket.cookies['_harvest_sess'];
var railsSession = RailsHelper.parseSessionCookie(cookie);
if (!railsSession.user_id) {
this.sessionId = null;
return;
}
this.sessionId = railsSession.session_id;
- this.firstPacket._enc_sess = railsSession;
+ this.firstPacket._harvest_sess = railsSession;
},
identifyUser: function () {
- var resp = this.httpGet(this.siteUrl);
- var user = resp.body.querySelector("#login-info").firstChild.textContent.trim();
- var company = resp.body.querySelector('#company-name').textContent.trim();
- this.userName = user;
+ var resp = this.httpGet(this.siteUrl + '/overview');
+
+ this.userName = resp.body.querySelector('.user-area').textContent.split('|')[0].trim();
+ var company = resp.body.querySelector('#company_bar strong').textContent;
this.siteName = 'Harvest (' + company + ')';
}
});

0 comments on commit 1896d19

Please sign in to comment.