aboutsummaryrefslogtreecommitdiffstats
path: root/twittperator
diff options
context:
space:
mode:
authoranekos2012-08-17 08:38:52 +0900
committeranekos2012-08-17 08:38:52 +0900
commit6358a2d624c8facd12f7d37b67c4e4b8562060c6 (patch)
tree610d1a6f20f13a92f5305ee427e28f4049997c32 /twittperator
parentf26331eaed724e6983f02a9f1d94b1b3eeaac7d9 (diff)
parent3ad3428b1153d598210e4e49ee414a9febd56163 (diff)
downloadvimperator-plugins-6358a2d624c8facd12f7d37b67c4e4b8562060c6.tar.bz2
Merge branch 'twittperator/require'
Diffstat (limited to 'twittperator')
-rw-r--r--twittperator/twsidebar-expand-url.tw20
1 files changed, 14 insertions, 6 deletions
diff --git a/twittperator/twsidebar-expand-url.tw b/twittperator/twsidebar-expand-url.tw
index 19a1caa..89dc9a8 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');
@@ -49,11 +57,11 @@
tweet.text = tweet.text.replace(sUrl, eUrl);
if (!sidebar().getElementById('tw-anekos-sb-home-list')) { return; }
let fUrl = expand ? sUrl : eUrl;
- let interval = setInterval(function () {
- if (twsText(id)) {
- twsText(id).textContent = escapeBreakers(twsText(id).textContent.replace(fUrl, Config.filter(eUrl)));
+ setTimeout(function () {
+ let e = twsText(id);
+ if (e) {
+ e.textContent = escapeBreakers(e.textContent.replace(fUrl, Config.filter(eUrl)));
scroll();
- clearInterval(interval)
}
}, 100);
});