Skip to content

Instantly share code, notes, and snippets.

@Shilo
Last active July 11, 2018 13:08
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 Shilo/d1d7bf310376b0c0b02fc47a1d73a597 to your computer and use it in GitHub Desktop.
Save Shilo/d1d7bf310376b0c0b02fc47a1d73a597 to your computer and use it in GitHub Desktop.
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