Created
September 16, 2016 16:15
-
-
Save hail2u/c0d669fb8473bc9c80232be40d8d5e7f to your computer and use it in GitHub Desktop.
`h1`要素で一文字だけ次の行に行ってしまうのを防ぐ汎用スクリプト
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*! | |
* wrapfix.js | |
* | |
* LICENSE: http://hail2u.mit-license.org/2016 | |
*/ | |
"use strict"; | |
(function (d) { | |
var e; | |
var h; | |
var i; | |
var l; | |
var n = d.querySelectorAll("h1"); | |
for (i = 0, l = n.length; i < l; i += 1) { | |
e = n[i]; | |
if (e.childNodes.length !== 1) { | |
continue; | |
} | |
h = e.textContent.split(""); | |
e.textContent = h.slice(0, -2).concat(h.slice(-2).map(function (c) { | |
return "\uFEFF" + c; | |
})).join(""); | |
} | |
})(document); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment