Skip to content

Instantly share code, notes, and snippets.

@jorinvo
Created August 20, 2012 22:29
Show Gist options
  • Save jorinvo/3408632 to your computer and use it in GitHub Desktop.
Save jorinvo/3408632 to your computer and use it in GitHub Desktop.
useful bookmarklet to toggle a 10px grid overlay on your page for design purposes
(function(window, doc, undefined) {
var awesomeGridBookmarkletElement = doc.getElementById('awesomeGridBookmarkletElement');
if ( awesomeGridBookmarkletElement !== null) {
awesomeGridBookmarkletElement.parentNode.removeChild(awesomeGridBookmarkletElement);
return;
}
var grid = doc.createElement('div');
grid.id = 'awesomeGridBookmarkletElement';
grid.style.backgroundImage = 'url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3AgUFTcrYHXFEgAAAAxpVFh0Q29tbWVudAAAAAAAvK6ymQAAABlJREFUGNNjZGBg+M9AJCBKIROxpo0qxAsADuYCECT/rwcAAAAASUVORK5CYII=)';
grid.style.position = 'fixed';
grid.style.top = 0;
grid.style.left = 0;
grid.style.height = '100%';
grid.style.width = '100%';
grid.style.opacity = 0.1;
grid.style.pointerEvents = 'none';
grid.style.zIndex = 9999999;
doc.getElementsByTagName('body')[0].appendChild(grid);
})(window, document);
javascript:(function(e,t,n){var r=t.getElementById("awesomeGridBookmarkletElement");if(r!==null){r.parentNode.removeChild(r);return}var i=t.createElement("div");i.id="awesomeGridBookmarkletElement",i.style.backgroundImage="url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3AgUFTcrYHXFEgAAAAxpVFh0Q29tbWVudAAAAAAAvK6ymQAAABlJREFUGNNjZGBg+M9AJCBKIROxpo0qxAsADuYCECT/rwcAAAAASUVORK5CYII=)",i.style.position="fixed",i.style.top=0,i.style.left=0,i.style.height="100%",i.style.width="100%",i.style.opacity=.1,i.style.pointerEvents="none",i.style.zIndex=9999999,t.getElementsByTagName("body")[0].appendChild(i)})(window,document)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment