aboutsummaryrefslogtreecommitdiffstats
path: root/twittperator
diff options
context:
space:
mode:
authoranekos2012-08-16 20:40:36 +0900
committeranekos2012-08-16 20:40:36 +0900
commit5c08fa58051c8315c042e193a1049e1b9f6f58e3 (patch)
tree4fce58273cfd034f48714fe632f1ae96d3acae8c /twittperator
parentc4c6a2f0df63d0c9eced030b0bd87af0dac8f027 (diff)
downloadvimperator-plugins-5c08fa58051c8315c042e193a1049e1b9f6f58e3.tar.bz2
Implement "require" method.
Diffstat (limited to 'twittperator')
-rw-r--r--twittperator/twsidebar-expand-url.tw24
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();
+ }
});
}
}