Skip to content

Instantly share code, notes, and snippets.

@alejofv
Forked from vcastroi/css-layout-hack.js
Last active October 2, 2019 03:44
Show Gist options
  • Select an option

  • Save alejofv/914ab2bff3236bd27e51fc9bf6fc10c5 to your computer and use it in GitHub Desktop.

Select an option

Save alejofv/914ab2bff3236bd27e51fc9bf6fc10c5 to your computer and use it in GitHub Desktop.
// create a bookmark and use this code as the URL, you can now toggle the css on/off
// thanks+credit: https://dev.to/gajus/my-favorite-css-hack-32g3
javascript: (function() {
var style = 'html * { background: rgba(255, 0, 0, .1); box-shadow: 0 0 0 1px red; }'
var elements = document.body.getElementsByTagName('*');
var items = [];
for (var i = 0; i < elements.length; i++) {
if (elements[i].innerHTML.indexOf(style) != -1) {
items.push(elements[i]);
}
}
if (items.length > 0) {
for (var i = 0; i < items.length; i++) {
items[i].innerHTML = '';
}
} else {
document.body.innerHTML +=
`<style>${style}</style>`;
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment