diff options
author | janus_wel | 2011-03-21 22:48:15 +0900 |
---|---|---|
committer | janus_wel | 2011-03-21 22:48:15 +0900 |
commit | cad3852cfb8814b1820763871b2443afdfb66128 (patch) | |
tree | 5b783fbc5eec246dff239f5cce67b25bdcb26a7a /direct_bookmark.js | |
parent | 413ae2b01139405a031c240bc9b40adc021282a8 (diff) | |
download | vimperator-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>
Diffstat (limited to 'direct_bookmark.js')
-rw-r--r-- | direct_bookmark.js | 24 |
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);
|