Skip to content

Instantly share code, notes, and snippets.

@saitamanodoruji
Created December 9, 2009 07:20
Show Gist options
  • Save saitamanodoruji/252320 to your computer and use it in GitHub Desktop.
Save saitamanodoruji/252320 to your computer and use it in GitHub Desktop.
Tombloo Togetter extractor
Tombloo.Service.extractors.register(
{
name: 'Conversation - togetter',
RE : /^http:\/\/togetter\.com\/li\//,
ICON : 'http://togetter.com/favicon.ico',
check : function(ctx){
return this.RE.test(ctx.href);
},
extract : function (ctx) {
var list_item = $x('//li[contains(concat(" ", @class, " "), " list_item ")][div[contains(concat(" ", @class, " "), " type_tweet ")]]', ctx.document, true);
var twBody = new Array();
var twText, twId, twStatusId, twPermalink
for (i = 0; i < list_item.length; i++) {
twText = $x('.//div[@class="tweet"]', list_item[i]);
twId = $x('.//a[@class="status_name"]', list_item[i]);
twStatusId = $x('.//div[@class="status_right"]/a[2]/@href', list_item[i])
.match(/twitter\.com\/[^\/]+\/status\/(\d+)/)[1];
twPermalink = 'https://twitter.com/' + twId.textContent + '/statuses/' + twStatusId;
if (twText && twId && twPermalink) {
twBody.push(twId.textContent + ":" + twText.textContent.replace(/[\r\n]/g, '') + " [" + twPermalink + "]");
}
}
var tgId = $x('//div[contains(concat(" ", normalize-space(@class), " "), " info_description ")]/span/a').textContent;
var m = {
type: 'conversation',
item : ctx.title + " by " + tgId + " " + ctx.href,
body: twBody.join('\n'),
//tags: "togetter"
};
return m;
}
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment