Created
January 11, 2013 14:17
-
-
Save saitamanodoruji/4510954 to your computer and use it in GitHub Desktop.
Twitter の検索結果を、タイムスタンプをタイトルに入れて Tumblr に Chat でポストする Tombloo パッチ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Tombloo.Service.extractors.register( | |
{ | |
name: 'Conversation - Twitter Search', | |
RE: /^https?:\/\/twitter\.com\/search(?:\/realtime|timeline)?\?q=/, | |
ICON: 'http://twitter.com/favicon.ico', | |
check: function(ctx){ | |
return this.RE.test(ctx.href); | |
}, | |
extract : function (ctx) { | |
var tweets = ctx.document.querySelectorAll('.tweet'), | |
id, text, permalink, item, timestamp, d, | |
body = []; | |
for (var i = 0; i < tweets.length; i++) { | |
id = tweets[i].querySelector('.username b, .nickname b').textContent; | |
text = tweets[i].querySelector('.js-tweet-text, .entry-content p').textContent; | |
permalink = tweets[i].querySelector('.tweet-timestamp, .view-details').href; | |
if (id && text && permalink) { | |
text = text.replace(/[\r\n]/g, '') | |
.replace(/^\s+/, '') | |
.replace(/\s+$/, ''); | |
body.push(id + ":" + text + " [" + permalink + "]"); | |
} | |
} | |
d=new Date(Number((new Date()).getTime()+32400000)); | |
timestamp = d.toISOString().replace(/\.\d+Z/,'+09:00'); | |
item = ctx.document.title + ' at ' + timestamp + ' ' + ctx.document.location.href; | |
alert(item + '\n' + body.join('\n')); | |
return { | |
type: 'conversation', | |
item: item, | |
body: body.join('\n'), | |
}; | |
} | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment