Created
April 19, 2024 06:39
-
-
Save wpeasy/7d6214709479ede958540fdce71010f7 to your computer and use it in GitHub Desktop.
Bricks fix focus state.
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
(() => { | |
document.addEventListener("DOMContentLoaded", () => { | |
const removeCSSRule = (selectorText) => { | |
// Get all stylesheets in the document | |
const stylesheets = document.styleSheets; | |
// Loop through all stylesheets | |
for (let i = 0; i < stylesheets.length; i++) { | |
const stylesheet = stylesheets[i]; | |
// Attempt to access rules - this may fail due to CORS policies | |
try { | |
const rules = stylesheet.cssRules || stylesheet.rules; // cssRules for modern browsers and rules for IE | |
// Loop through all rules in the stylesheet | |
for (let j = 0; j < rules.length; j++) { | |
const rule = rules[j]; | |
// Check if the rule's selector matches the one we're looking for | |
if (rule.selectorText === selectorText) { | |
// Remove the rule if it matches | |
stylesheet.deleteRule(j); | |
console.log(`Rule removed: ${rule.selectorText}`); | |
return; // Exit after removing the rule | |
} | |
} | |
} catch (e) { | |
console.error("Error accessing rules from stylesheet:", e); | |
} | |
} | |
// Log if the rule was not found in any stylesheet | |
console.log(`Rule not found: ${selectorText}`); | |
}; | |
// Example usage | |
removeCSSRule("body.bricks-is-frontend :focus"); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment