const CUSTOM_CSS_ELEMENT_ID = 'media-views-important'; const processRules = (rules) => { const result = []; [...rules].forEach((rule) => { switch (rule.type) { case CSSRule.STYLE_RULE: result.push(addImportant(rule)); break; case CSSRule.MEDIA_RULE: result.push(`@media ${rule.conditionText} {`); processRules(rule.cssRules, result); result.push('}'); break; default: result.push(rule.cssText); break; } }); return result; }; const addImportant = (rule) => { const declarations = [...rule.style].map( (prop) => `${prop}: ${rule.style.getPropertyValue(prop)} !important`, ); return `${rule.selectorText} { ${declarations.join('; ')}; }`; }; // A