Skip to content

Instantly share code, notes, and snippets.

@zakelfassi
Last active December 23, 2015 17:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zakelfassi/6666410 to your computer and use it in GitHub Desktop.
Save zakelfassi/6666410 to your computer and use it in GitHub Desktop.
Do you ever feel the need to adjust the font-size of a page ? Just run this code in your Console (Chrome dev tools/Firebug/...) and select some text ! // note that this code was written under 60seconds just to read this post : http://lifehacker.com/a-scientific-guide-to-saying-no-1293242273 Chrome extension coming soon. Maybe.
(function() {
function setSelectedSize(s) {
var arr = document.getElementsByTagName(window.getSelection().baseNode.parentNode.tagName);
for(var i=0; i<arr.length; i++) {
arr[i].style.fontSize = "" + s + "px";
}
}
window.addEventListener("mouseup", function() {
if(window.getSelection().type == "Range") {
s = prompt("New font size ?", "");
setSelectedSize(s);
}
});
})();
/**
* as a bookmarklet
*
/
// javascript:(function(){function e(e){var t=document.getElementsByTagName(window.getSelection().baseNode.parentNode.tagName);for(var n=0;n<t.length;n++){t[n].style.fontSize=""+e+"px"}}window.addEventListener("mouseup",function(){if(window.getSelection().type=="Range"){s=prompt("New font size ?","");e(s)}})})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment