Skip to content

Instantly share code, notes, and snippets.

@bobbykjack
Last active June 25, 2025 12:35
Show Gist options
  • Select an option

  • Save bobbykjack/af6f1221b3ff0921189d9e683918fb2f to your computer and use it in GitHub Desktop.

Select an option

Save bobbykjack/af6f1221b3ff0921189d9e683918fb2f to your computer and use it in GitHub Desktop.
function set_stylesheet_disable(val) {
for (let i = 0; i < document.styleSheets.length; i++) {
document.styleSheets.item(i).disabled = val;
}
}
function disable_stylesheets_hold() {
document.addEventListener("keydown", function (e) {
if (e.key === "Escape") {
set_stylesheet_disable(true);
}
});
document.addEventListener("keyup", function (e) {
if (e.key === "Escape") {
set_stylesheet_disable(false);
}
});
}
function disable_stylesheets_toggle() {
document.addEventListener("keyup", function (e) {
if (e.key === "Escape" && document.styleSheets.length) {
set_stylesheet_disable(!document.styleSheets.item(0).disabled);
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment