Last active
May 16, 2024 23:15
-
-
Save asontu/6c00e82739637a926a70a912a97c35eb to your computer and use it in GitHub Desktop.
Gist for this blogpost: https://asontu.github.io/2024/05/16/a-poor-mans-custom-stylesheet-bookmarklet.html
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
javascript:(function(){ | |
var styleTag = document.querySelector('#niftyStyle'); | |
if (!styleTag) { | |
styleTag = document.createElement('style'); | |
styleTag.id = 'niftyStyle'; | |
styleTag.type = 'text/css'; | |
styleTag.contentEditable = 'plaintext-only'; | |
styleTag.style.position = 'fixed'; | |
styleTag.style.top = '0'; | |
styleTag.style.minHeight = '1em'; | |
styleTag.style.minWidth= '4em'; | |
styleTag.style.zIndex = '99999'; | |
styleTag.style.padding = '3px'; | |
styleTag.style.whiteSpace = 'pre'; | |
styleTag.style.background = '#000'; | |
styleTag.style.color = '#fff'; | |
styleTag.style.fontFamily = 'consolas, monospace'; | |
document.body.appendChild(styleTag); | |
} | |
if (!styleTag.innerText.trim()) { | |
var sheet = localStorage.getItem('niftyStyle'); | |
if (!sheet) { | |
sheet = 'html {\n filter: invert(1) hue-rotate(180deg);\n}'; | |
styleTag.style.display = 'block'; | |
} | |
styleTag.appendChild(document.createTextNode(sheet)); | |
return; | |
} | |
if (styleTag.style.display == 'block') { | |
localStorage.setItem('niftyStyle', styleTag.innerText.trim()); | |
styleTag.style.display = 'none'; | |
} else { | |
styleTag.style.display = 'block'; | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment