masuda font normalizer

    @@ -2,10 +2,16 @@ * @title masuda font normalizer * @description 増田のデカ文字を普通のサイズにする * @include http://anond.hatelabo.jp/* + * @contributor yuta25 http://let.hatelabo.jp/yuta25/let/hLHWyLPB-JlO (Fork of) * @license MIT http://opensource.org/licenses/MIT * @javascript_url */ +// c.f. +// http://h.hatena.ne.jp/noromanba/316617863696041811 +// http://h.hatena.ne.jp/noromanba/298796980354824283 +// +// huge fonts e.g. // .deco // <span class="deco" style="font-size:10000%;">ごめん</span> // http://anond.hatelabo.jp/20141214002335
  • /*
     * @title masuda font normalizer
     * @description 増田のデカ文字を普通のサイズにする
     * @include http://anond.hatelabo.jp/*
     * @contributor yuta25  http://let.hatelabo.jp/yuta25/let/hLHWyLPB-JlO (Fork of)
     * @license MIT http://opensource.org/licenses/MIT
     * @javascript_url
     */
    
    // c.f.
    // http://h.hatena.ne.jp/noromanba/316617863696041811
    // http://h.hatena.ne.jp/noromanba/298796980354824283
    //
    // huge fonts e.g.
    // .deco
    // <span class="deco" style="font-size:10000%;">ごめん</span>
    // http://anond.hatelabo.jp/20141214002335
    //
    // non .deco
    // <span style="font-size:2800%;"> 愛 <span>
    // http://f.hatena.ne.jp/noromanba/20141214040647
    // http://anond.hatelabo.jp/20141214004936
    
    
    (function () {
        // slice binding c.f.
        // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice
        var slice = Function.prototype.call.bind(Array.prototype.slice);
    
        var handler = function (context) {
            // like a NodeFilter; c.f.
            // https://developer.mozilla.org/en-US/docs/Web/API/NodeFilter
    
            var filter = function(node, selector) {
                if (node.nodeName.toLowerCase() === selector.toLowerCase()) {
                    return [node];
                }
                if (!node.querySelectorAll) { // alt. document.ELEMENT_NODE
                    return [];
                }
                return slice(node.querySelectorAll(selector));
            };
    
            var each = function (nodes) {
                nodes.forEach(function (node) {
                    if (node.style.fontSize) {
                        node.style.fontSize = 'inherit';
                    }
                });
            };
    
            each(filter(context, '[style*="font-size"]'));
        };
        handler(document.body);
    
        // c.f. MutationObserver
        // https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver
        // http://caniuse.com/#feat=mutationobserver
        new MutationObserver(function (records) {
            records.forEach(function (record) {
                handler(record.target);
            });
        }).observe(document.body, { childList: true, subtree: true });
    })();
    
    
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2014/12/15 03:13:13 - 2014-12-15
  2. 2014/12/14 05:27:05 - 2014-12-14
  3. 2014/12/14 05:19:05 - 2014-12-14
  4. 2014/12/14 05:09:53 - 2014-12-14
  5. 2014/12/14 04:44:23 - 2014-12-14
  6. 2014/12/14 04:44:13 - 2014-12-14
  7. 2014/12/14 04:41:37 - 2014-12-14