From cad3852cfb8814b1820763871b2443afdfb66128 Mon Sep 17 00:00:00 2001 From: janus_wel Date: Mon, 21 Mar 2011 22:48:15 +0900 Subject: Avoid an error at first time of accessing はてブ by activating non-javascript static page at top of はてブ Signed-off-by: janus_wel --- direct_bookmark.js | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'direct_bookmark.js') 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); -- cgit v1.2.3