Skip to content

Instantly share code, notes, and snippets.

@asontu
Last active January 14, 2025 20:22
Show Gist options
  • Save asontu/6c00e82739637a926a70a912a97c35eb to your computer and use it in GitHub Desktop.
Save asontu/6c00e82739637a926a70a912a97c35eb to your computer and use it in GitHub Desktop.
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.maxHeight = '100vh';
        styleTag.style.minWidth = '4em';
        styleTag.style.maxWidth = '50vw';
        styleTag.style.overflow = 'auto';
        styleTag.style.zIndex = '99999';
        styleTag.style.padding = '3px';
        styleTag.style.whiteSpace = 'pre';
        styleTag.style.background = 'rgba(0, 0, 0, .85)';
        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(95%) 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