Skip to content

Instantly share code, notes, and snippets.

@Shilo Shilo/css_injection.js
Last active Jul 11, 2018

What would you like to do?
One Line Javascript CSS Injection.
(function() { var css = `body{background-color:black;}`; var cssDiv = document.createElement('div'); cssDiv.innerHTML = '&shy;<style>' + css + '</style>'; document.body.appendChild(cssDiv.childNodes[1]); })();
(function() { var css = `body { background-color: black; }`; var cssDiv = $('<div />', { html: '&shy;<style>' + css + '</style>' }).children().appendTo('body'); })();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.