diff options
author | anekos | 2012-08-16 20:40:36 +0900 |
---|---|---|
committer | anekos | 2012-08-16 20:40:36 +0900 |
commit | 5c08fa58051c8315c042e193a1049e1b9f6f58e3 (patch) | |
tree | 4fce58273cfd034f48714fe632f1ae96d3acae8c /twittperator | |
parent | c4c6a2f0df63d0c9eced030b0bd87af0dac8f027 (diff) | |
download | vimperator-plugins-5c08fa58051c8315c042e193a1049e1b9f6f58e3.tar.bz2 |
Implement "require" method.
Diffstat (limited to 'twittperator')
-rw-r--r-- | twittperator/twsidebar-expand-url.tw | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/twittperator/twsidebar-expand-url.tw b/twittperator/twsidebar-expand-url.tw index ae84110..8eee68d 100644 --- a/twittperator/twsidebar-expand-url.tw +++ b/twittperator/twsidebar-expand-url.tw @@ -1,3 +1,6 @@ + +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'], @@ -33,8 +36,13 @@ function sidebar () document.getElementById('sidebar')._contentWindow.document; - function twsText (id) - sidebar().getElementById(id).childNodes[1].childNodes[3].childNodes[3].firstChild; + function twsText (id) { + try { + return sidebar().getElementById(id).childNodes[1].childNodes[3].childNodes[3].firstChild; + } catch (e) { + return void 0; + } + } function scroll () { let tws = sidebar().getElementById('tw-anekos-sb-home-list'); @@ -48,13 +56,11 @@ expandURL(urls[i].expanded_url, function (eUrl , expand) { tweet.text = tweet.text.replace(sUrl, eUrl); let fUrl = expand ? sUrl : eUrl; - let interval = setInterval(function () { - if (twsText(id)) { - twsText(id).textContent = escapeBreakers(twsText(id).textContent.replace(fUrl, Config.filter(eUrl))); - scroll(); - clearInterval(interval) - } - }, 100); + let e = twsText(id); + if (e) { + e.textContent = escapeBreakers(e.textContent.replace(fUrl, Config.filter(eUrl))); + scroll(); + } }); } } |