aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjanus_wel2011-03-21 22:48:15 +0900
committerjanus_wel2011-03-21 22:48:15 +0900
commitcad3852cfb8814b1820763871b2443afdfb66128 (patch)
tree5b783fbc5eec246dff239f5cce67b25bdcb26a7a
parent413ae2b01139405a031c240bc9b40adc021282a8 (diff)
downloadvimperator-plugins-cad3852cfb8814b1820763871b2443afdfb66128.tar.bz2
Avoid an error at first time of accessing はてブ
by activating non-javascript static page at top of はてブ Signed-off-by: janus_wel <janus.wel.3@gmail.com>
-rw-r--r--direct_bookmark.js24
1 files changed, 17 insertions, 7 deletions
diff --git a/direct_bookmark.js b/direct_bookmark.js
index 931941f..862f2b4 100644
--- a/direct_bookmark.js
+++ b/direct_bookmark.js
@@ -376,13 +376,23 @@ for Migemo search: require XUL/Migemo Extension
var xhr = new XMLHttpRequest();
var hatena_tags = [];
- //xhr.open("GET","http://b.hatena.ne.jp/my",false);
- xhr.open("GET","http://b.hatena.ne.jp/"+user,false);
- xhr.send(null);
-
- var mypage_html = parseHTML(xhr.responseText);
- //var tags = getElementsByXPath("//ul[@id=\"taglist\"]/li/a",mypage_html);
- var tags = getElementsByXPath('id("tags")/li/a', mypage_html);
+ var getting_tags = function () {
+ //xhr.open("GET","http://b.hatena.ne.jp/my",false);
+ xhr.open("GET","http://b.hatena.ne.jp/"+user,false);
+ xhr.send(null);
+
+ var mypage_html = parseHTML(xhr.responseText);
+ //var tags = getElementsByXPath("//ul[@id=\"taglist\"]/li/a",mypage_html);
+ return getElementsByXPath('id("tags")/li/a', mypage_html);
+ };
+
+ var tags = getting_tags();
+ if (!tags) {
+ // activate non-javascript static page
+ xhr.open("GET", 'http://b.hatena.ne.jp/config.disable_fast?path=/' + user + '/', false);
+ xhr.send(null);
+ tags = getting_tags();
+ }
tags.forEach(function(tag){
hatena_tags.push(tag.innerHTML);