Skip to content

Instantly share code, notes, and snippets.

@wakaba
Last active Feb 16, 2017
Embed
What would you like to do?
javascript:var s=document.createElement('script');s.src="https://gist.githack.com/wakaba/b90f120b2617afe5c2fc4d08d84e801f/raw/script.js";document.body.appendChild(s);void(0)
Array.prototype.forEach.call (document.querySelectorAll (".entry-title, h1, h2, h3, h4, h5, h6"), function (e) {
var f = document.createElement ('dummy-container');
while (e.firstChild) {
f.appendChild (e.firstChild);
}
e.appendChild (f);
var tryCount = 0;
var maxTryCount = 30;
var eWidth = e.offsetWidth;
var minLastWidth = 3.5 * parseFloat (getComputedStyle (e).fontSize);
e.style.transformOrigin = "left top";
e.style.boxSizing = "border-box";
var factor = 1;
var rects = f.getClientRects ();
while (rects.length > 1 && rects[rects.length-1].width < minLastWidth && tryCount++ < maxTryCount) {
factor *= 0.99;
e.style.transform = "scalex("+factor+")";
e.style.width = eWidth / factor + "px";
e.style.background = "red";
e.setAttribute ('data-try-count', tryCount);
rects = f.getClientRects ();
}
});
@wakaba
Copy link
Author

wakaba commented Feb 15, 2017

bukkenfan.jp でブックマークレット実行

before
before

after
after

@cho45
Copy link

cho45 commented Feb 16, 2017

なるほど!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment