aboutsummaryrefslogtreecommitdiffstats
path: root/twittperator
diff options
context:
space:
mode:
authorebith2012-11-07 12:51:49 +0900
committerebith2012-11-07 12:51:49 +0900
commit423615f23417c54ec956955d09101e2f727ec6fd (patch)
tree603fed81e08d60a2d673ccc31dff3e452ce2a655 /twittperator
parent8bc2496a532e78b0e5d2b2e249c881b83f95df5a (diff)
downloadvimperator-plugins-423615f23417c54ec956955d09101e2f727ec6fd.tar.bz2
ツイート詳細URLの場合自動展開する。それにともなってfilterを非同期に。
Diffstat (limited to 'twittperator')
-rw-r--r--twittperator/twsidebar-expand-url.tw20
1 files changed, 16 insertions, 4 deletions
diff --git a/twittperator/twsidebar-expand-url.tw b/twittperator/twsidebar-expand-url.tw
index 89dc9a8..aae14d1 100644
--- a/twittperator/twsidebar-expand-url.tw
+++ b/twittperator/twsidebar-expand-url.tw
@@ -4,8 +4,18 @@ require('twsidebar');
(function () {
let Config = liberator.globalVariables.twittperator_sidebar_expand_url_config || {
host: ['ff.im', 'is.gd', 't.co', 'bit.ly', 'j.mp', 'htn.to', 'goo.gl', 'ow.ly'],
- filter: function (url) {
- return url.length > 60 ? url.substr(0, 60) + '...' : url;
+ filter: function (url, callback) {
+ let isStatus = /https?:\/\/twitter\.com\/(\w+)\/status\/(\d+)/.exec(url);
+ let isPhoto = /\/photo\/\d/;
+ if (isStatus) {
+ if (!isPhoto.test(isStatus.input)) {
+ plugins.twittperator.OAuth.jsonGet('http://api.twitter.com/1/statuses/show', {id:isStatus[2]}, function(msg){
+ callback('\u26A1 ' + msg.user.screen_name + ' : ' + msg.text);
+ });
+ }
+ } else {
+ callback(url.length > 60 ? url.substr(0, 60) + '...' : url);
+ }
}
}
@@ -60,8 +70,10 @@ require('twsidebar');
setTimeout(function () {
let e = twsText(id);
if (e) {
- e.textContent = escapeBreakers(e.textContent.replace(fUrl, Config.filter(eUrl)));
- scroll();
+ Config.filter(eUrl, function(filtered){
+ e.textContent = escapeBreakers(e.textContent.replace(fUrl, filtered));
+ scroll();
+ });
}
}, 100);
});