Last active
February 16, 2017 07:34
-
-
Save wakaba/b90f120b2617afe5c2fc4d08d84e801f to your computer and use it in GitHub Desktop.
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
javascript:var s=document.createElement('script');s.src="https://gist.githack.com/wakaba/b90f120b2617afe5c2fc4d08d84e801f/raw/script.js";document.body.appendChild(s);void(0) |
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
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 (); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
bukkenfan.jp でブックマークレット実行
before

after
