-
-
Save abodacs/e041a0b181686464a3e5e62a33326799 to your computer and use it in GitHub Desktop.
CSS Helper
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
* { | |
outline: 1px solid red; | |
} | |
*:hover { | |
outline: 2px solid blue; | |
} |
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
var $debugHelper = $debugHelper || {}; | |
$debugHelper = function () { | |
var href = "lib/debugger.css"; | |
var addCss = function () { | |
if (styleStyleIsLoaded(href) === true) { | |
return; | |
} | |
const head = document.head; | |
const link = document.createElement("link"); | |
link.type = "text/css"; | |
link.rel = "stylesheet"; | |
link.href = href; | |
head.appendChild(link); | |
}; | |
var removeCss = function () { | |
if (styleStyleIsLoaded('debugger.css')) { | |
document.querySelector(`link[href$="${href}"]`).remove(); | |
} | |
}; | |
var toggle = function() { | |
if (styleStyleIsLoaded(href) === true) { | |
removeCss(); | |
} else { | |
addCss(); | |
} | |
} | |
var styleStyleIsLoaded = function () { | |
for (var index = 0, count = document.styleSheets.length; index < count; index++) { | |
const sheet = document.styleSheets[index]; | |
if (!sheet.href) { | |
continue; | |
} | |
if (sheet.href.includes(href)) { | |
return true; | |
} | |
} | |
return false; | |
} | |
return { | |
addCss: addCss, | |
removeCss: removeCss, | |
isCSSLinkLoaded: styleStyleIsLoaded, | |
toggle: toggle | |
}; | |
}(); |
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
<script> | |
/* | |
* Karen code | |
* ALT+CTRL+1 toggles adding/removing debugger.css | |
*/ | |
document.addEventListener('keydown', function (event) { | |
if (event.key === '1' && event.altKey && event.ctrlKey) { | |
$debugHelper.toggle(); | |
} | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment