masuda font normalizer
-
/*
* @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.
// cover over "write diary"
// <span class="deco" style="font-size:20000%;">
// http://f.hatena.ne.jp/noromanba/20141215030849
// http://anond.hatelabo.jp/20141214234857
//
// <span style="font-size:2800%;">
// 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 です。