Skip to content

Instantly share code, notes, and snippets.

@jorupp
Created March 4, 2015 15:43
Show Gist options
  • Save jorupp/2af4d8583bd592b8331f to your computer and use it in GitHub Desktop.
Save jorupp/2af4d8583bd592b8331f to your computer and use it in GitHub Desktop.
Lock all media queries in their current state
function process(rule) {
if(rule.cssRules) {
for(var i=rule.cssRules.length-1; i>=0; i--) {
process(rule.cssRules[i]);
}
}
if(rule.type == CSSRule.MEDIA_RULE) {
if(window.matchMedia(rule.media.mediaText).matches) {
rule.media.mediaText = "all";
} else {
rule.media.mediaText = "not all";
}
}
return rule;
}
for(var i=0; i<document.styleSheets.length; i++) {
process(document.styleSheets[i]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment