Skip to content

Instantly share code, notes, and snippets.

@bjrmatos
Forked from jorupp/gist:2af4d8583bd592b8331f
Created October 6, 2015 04:55
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 bjrmatos/84624daca5161e082d88 to your computer and use it in GitHub Desktop.
Save bjrmatos/84624daca5161e082d88 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