Skip to content

Instantly share code, notes, and snippets.

@michaelrhodes
Created February 12, 2019 07:06
Show Gist options
  • Save michaelrhodes/1c2c6896f8a632ff94daf0ad97a9798c to your computer and use it in GitHub Desktop.
Save michaelrhodes/1c2c6896f8a632ff94daf0ad97a9798c to your computer and use it in GitHub Desktop.
Grid Bookmarklet
javascript:!function(){var c="#fff",s=64,d=document,f=d.createDocumentFragment(),n=d.createElement("i"),t=Math.ceil(innerWidth/s);n.style.cssText="pointer-events:none;position:fixed;top:0;left:0;background-color:"+c,Array(t).join(" ").split(" ").forEach(function(t,i){if(i){var x=n.cloneNode(),y=n.cloneNode();x.style.cssText+="bottom:0;width:1px;transform:translateX("+s*i+"px)",y.style.cssText+="right:0;height:1px;transform:translateY("+s*i+"px)",f.appendChild(x),f.appendChild(y)}}),d.body.appendChild(f)}()
var color = '#fff'
var size = 64
var fragment = document.createDocumentFragment()
var column = document.createElement('i')
var total = Math.ceil(innerWidth / size)
column.style.cssText = 'pointer-events:none;position:fixed;top:0;left:0;background-color:' + color
Array(total).join(' ').split(' ').forEach(function (s, i) {
if (!i) return
var x = column.cloneNode()
var y = column.cloneNode()
x.style.cssText += 'bottom:0;width:1px;transform:translateX(' + (i * size) + 'px)'
y.style.cssText += 'right:0;height:1px;transform:translateY(' + (i * size) + 'px)'
fragment.appendChild(x)
fragment.appendChild(y)
})
document.body.appendChild(fragment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment