True Reader Mode

    
      
  • /*
     * @title True Reader Mode
     * @description Show only main content
     * @include http://*
     * @license MIT License
     * @require 
     */
    (function() {
      function hide(el) {
        var parent = el.parentNode;
        if (parent) {
          var sibling = parent.firstElementChild;
          while (sibling) {
            if (sibling != el) {
              sibling.style.webkitFilter = 'brightness(1)';
            }
            sibling = sibling.nextElementSibling;
          }
          hide(parent);
        }
      }
    
      var el = document.querySelector('*[role="main"]');
      if (el) {
        hide(el);
      } else {
        var root = document.body || document.documentElement;
        root.style.webkitFilter = 'brightness(1)';
      }
    })()
    
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2012/10/12 23:56:32 - 2012-10-12