日記はScrapboxに移動しました。

livedoor Reader で読んだフィードの履歴を遡れるようにする greasemonkey スクリプト

,

LDR でさくさくフィードを読み進めているときに、さっき読んでたフィードに戻りたいと思いきや、すでにマイフィードのリストは更新されており、そのフィードは消えていて簡単には戻れずに、残念な思いをすることがあります。
そこで、以下の通りのスクリプトを書いて、読んだフィードの履歴を遡れるようにしてみました。Shift + p / Shift + n で履歴をいったりきたりできます。
LDR のキャッシュの仕組みがよくわからないので、フィードを丸ごと配列に保存しておくという強引なやりくちを用いています……。
インストール: ldr_feed_history.user.js

// ==UserScript==
// @name          LDR Feed History
// @namespace     http://antipop.gs/ns/greasemonkey/ldr_feed_history
// @include       http://reader.livedoor.com/reader/*
// ==/UserScript==
(function(){
var historyMaxLength = 5;
var w = unsafeWindow;
var _onload = w.onload;
var onload  = function(){with (w) {
State.GM_now_reading  = null;
State.GM_feed_index   = 0;
State.GM_feed_history = [];
register_hook('after_printfeed', function (feed) {
var filtered = State.GM_feed_history.filter(function (iter) {
return (iter.subscribe_id == feed.subscribe_id);
});
if (!filtered.length) {
State.GM_feed_history.unshift(feed);
while (State.GM_feed_history.length > (historyMaxLength + 1)) {
State.GM_feed_history.pop();
}
State.GM_now_reading = State.now_reading;
State.GM_feed_index  = 0;
}
});
Keybind.add('P', function () {
if (State.GM_feed_index < (State.GM_feed_history.length - 1)) {
print_feed(State.GM_feed_history[++State.GM_feed_index]);
State.now_reading = State.GM_now_reading;
}
});
KeyConfig.history_up = 'P';
KeyHelp.history_up   = '\u5C65\u6B74\u3092\u904E\u53BB\u306B\u5411\u304B\u3063\u3066\u79FB\u52D5\u3059\u308B';
Keybind.add('N', function () {
if (State.GM_feed_index > 0) {
print_feed(State.GM_feed_history[--State.GM_feed_index]);
State.now_reading = State.GM_now_reading;
}
});
KeyConfig.history_down = 'N';
KeyHelp.history_down   = '\u5C65\u6B74\u3092\u73FE\u5728\u306B\u5411\u304B\u3063\u3066\u79FB\u52D5\u3059\u308B';
}};
w.onload = function(){
_onload();
onload();
};
})();

ライブドアの技術面に関する特集が掲載されています。

JavaScriptビジュアル・リファレンス
シーズ
エムディエヌコーポレーション (2004/11)
売り上げランキング: 29,745

非常に評判の高い JavaScript リファレンス。

Leave a Reply

Your email address will not be published. Required fields are marked *