Home > Archives > 2008年03月 > はてなダイアリー過去記事全文連結スクリプト(要Firebug)

はてなダイアリー過去記事全文連結スクリプト(要Firebug)

はてなダイアリー過去記事全文連結スクリプト(要Firebug)

記事一覧ページで過去の記事の見出しをその場で検索できるようになりました - はてなダイアリー日記

kga_ 2008年03月28日 hatena mala

http://d.hatena.ne.jp/#{ID}/archive/plaintext で日付け、Permalink、タイトルがとれる

ページ詳細 - 記事一覧ページで過去の記事の見出しをその場で検索できるようになりました - livedoor クリップ

ネタ元。


var xhr = function(uri, callback){
    var xmlhttp = new XMLHttpRequest() || new ActiveXObject("Msxml2.XMLHTTP");
    xmlhttp.open("GET", uri, true);
    xmlhttp.onreadystatechange = function(){
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
            callback(xmlhttp.responseText);
        }
    };
    xmlhttp.send(null);
};
var baseuri = location.href.slice(0, -18);
var lines = (document.body.textContent || document.body.innerText).split("\n");
var w = window.open();
w.document.open();
w.document.write('<html><head><title>' + baseuri + '/</title></head><link rel="stylesheet" href="http://d.hatena.ne.jp/css/base.css" type="text/css" /><link rel="stylesheet" href="http://d.hatena.ne.jp/theme/hatena/hatena.css" type="text/css" /><style type="text/css">p.commentform{display:none;}</style><body>');
var i = 0, l = lines.length;
(function(){
    var path = lines[i].split(",")[1];
    if (path) {
        xhr(baseuri + path, function(res){
            w.document.write(res.match(/<div id="days">([\s\S]*?)<div class="calendar" id="pager-bottom">/)[1]);
        });
    }
    if (++i < l) {
        setTimeout(arguments.callee, 5000);
    } else {
        w.document.write('</body></html>');
        w.document.close();
    }
})();

使い方。

  1. Firefoxを立ち上げてFirebugを有効にする
  2. http://d.hatena.ne.jp/#{ID}/archive/plaintextを開く
  3. Firebugのコンソールから上を実行する
  4. 別ウィンドウに全過去ログが書き出される*1
  5. ページを保存してあとで見る

あまり行儀の良いスクリプトじゃないけど、過去記事をまとめて保存しとくと場合によっては役に立つかと思って作りました。

  • *1: 記事1000件当たり約1時間23分かかる

Comment: 0

Attention
コメントの受け付けは終了しました。

Trackback: 0

Attention
トラックバックの受け付けは終了しました。

Home > Archives > 2008年03月 > はてなダイアリー過去記事全文連結スクリプト(要Firebug)

Feeds
Counter
  • Counter

    since 2008.01.11

Page Top