Kentaro Kuribayashi's blog

Software Engineering, Management, Books, and Daily Journal.

livedoor Reader をより快適にするかもしれない、ちょい「<ruby><rb>不良</rb><rp>(</rp><rt>ワル</rt><rp>)</rp></ruby>」 greasemonkey スクリプト

livedoor Reader ネタが続いてますが、気にせず投入。
LDR は、インタフェイスの隅々まで開発者の配慮が行き届いていて、ユーザたる我々は、激しく素敵極まりない最速体験をただただ享受するのみなわけですが、まぁしかしそこはあれ、LDR とて商業的なサービスなのであってみれば、ある一線より先に進もうとすればユーザ側でなんとかする他なくなります。まぁよくある例としては、広告を消すとかそういうことだったりするのですが。
というわけで、そのあたりを含めて、使い勝手をもすこし高めるべく greasemonkey スクリプトを書いていたりしたのですが、もうこのぐらいでいんじゃね?的な気分になってきたので、ここらでひとつ晒してみることに。いちいち解説するのもアレなので、適当にお取り扱いください。あと、僕の好みに沿ってカスタマってるので、その辺もまぁアレ。
インストール: ldr_utils.user.js

// ==UserScript==
// @name          Utilities for livedoor Reader
// @description   Make livedoor Reader more convenient.
// @namespace     http://antipop.gs/ns/greasemonkey/ldr_utils
// @include       http://reader.livedoor.com/reader/*
// ==/UserScript==

(function(){
     var w = unsafeWindow;
     var _onload = w.onload;
     var onload  = function(){
         with (w) {

             // add keybindings
             //  - http://la.ma.la/blog/diary_200604261407.htm
             Keybind.add('j', Control.go_next);
             Keybind.add('k', Control.go_prev);

             // hide ads
             ['ads_top', 'ads_bottom'].forEach(function(v){DOM.hide(v);});

             // move total-unread-count into the control box
             var total_unread_count = DOM.clone($('total_unread_count'));
             setStyle(total_unread_count, {
                          'position' : 'absolute',
                          'right'    : '150px',
                          'top'      : '5px',
                          'font-size': '12px'
                      });
             DOM.remove('total_unread_count');
             DOM.insert($('control'), total_unread_count, $('fontpad'));

             // replace Control.toggle_fullscreen with custom function
             var toggle_fullscreen_with_control = function(){
                 var fs = [];
                 var elements = ['header', 'menu', 'control', 'footer'];
                 fs[0] = ['header', 'menu', 'control', 'footer'];
                 fs[1] = ['menu', 'control'];
                 fs[2] = ['control'];
                 fs[3] = [];
                 if(!State.fullscreen){
                     State.fullscreen = 1;
                 } else if(State.fullscreen == fs.length-1){
                     State.fullscreen = 0;
                 } else {
                     State.fullscreen++
                 }
                 Element.hide(elements);
                 Element.show(fs[State.fullscreen]);
                 fit_screen()
             };
             Keybind.add("Z", toggle_fullscreen_with_control);

             // make the view-area wide on the page loaded
             var i = 2;
             while (i) {
                 toggle_fullscreen_with_control();
                 i--;
             }
         }
     };

     w.onload = function(){
         _onload();
         onload();
     };
})();