-
-
Save ziru/83100 to your computer and use it in GitHub Desktop.
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
CmdUtils.CreateCommand({ | |
name: "my.tweet", | |
preview: "Insert your latest tweet as a signature.", | |
execute: function(){ | |
var userId = 'YOUR TWITTER ID'; | |
var twitterQueryUrl = 'http://twitter.com/statuses/user_timeline/' + userId + '.json?count=5'; | |
jQuery.get(twitterQueryUrl, null, function(data) { | |
if (!data) return; | |
var latestStatus; | |
for (var i = 0; i < data.length; i++) { | |
if (data[i].text && (data[i].text[0] != '@')) { | |
latestStatus = data[i]; | |
break; | |
} | |
} | |
if (!latestStatus) return; | |
var statusUrl = 'http://twitter.com/' + userId + '/status/' + latestStatus.id; | |
var ts = new Date(latestStatus.created_at); | |
var tsStr = '('+(ts.getMonth()+1) + '/' + ts.getDate() + ')'; | |
var sigHdr = '<div style="font-size:13px"><a href="' + statusUrl + '">最近动态' + tsStr + '</a></div>'; | |
var sigBody = '<div style="margin: .5em;font-size:12px;">' + latestStatus.text + '</div>'; | |
var sigHtml = '<div align="left" style="width:350px; color:#888; margin-top:1em;"><div style="text-align:left; width:30px"><hr style="height: 2px;"></div>' + sigHdr + sigBody + '</div><br/>'; | |
CmdUtils.setSelection(sigHtml); | |
}, "json"); | |
// CmdUtils.setSelection( "Your Signature" ); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment