Skip to content

Instantly share code, notes, and snippets.

@hail2u
Created September 16, 2016 16:15
Show Gist options
  • Save hail2u/c0d669fb8473bc9c80232be40d8d5e7f to your computer and use it in GitHub Desktop.
Save hail2u/c0d669fb8473bc9c80232be40d8d5e7f to your computer and use it in GitHub Desktop.
`h1`要素で一文字だけ次の行に行ってしまうのを防ぐ汎用スクリプト
/*!
* 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