Last active
May 22, 2017 14:14
-
-
Save depoulo/4bf34a423ec320c38eda to your computer and use it in GitHub Desktop.
Add CSS rules quickly from the browser JS console. Idea taken from http://davidwalsh.name/add-rules-stylesheets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(() => { | |
var style = document.createElement("style"); | |
style.appendChild(document.createTextNode("")); | |
document.head.appendChild(style); | |
var rules = prompt('Paste CSS rules here'); | |
var importStatements = (rules.split(';') || []).filter(s => s.startsWith('@import')).map(s => s + ';'); | |
importStatements.forEach((importStatement, index) => style.sheet.insertRule(importStatement, index)); | |
style.sheet.insertRule(`@media all{${rules}`, importStatements.length); | |
}()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bookmarklet: