Last active
March 4, 2024 18:45
-
-
Save mreinstein/5360cac59a4304faf3cb5c7234eaf12b to your computer and use it in GitHub Desktop.
invert all colors on a web page
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
// invert all colors on the page | |
export default function invert() { | |
let css = 'html {-webkit-filter: invert(100%);' + | |
'-moz-filter: invert(100%);' + | |
'-o-filter: invert(100%);' + | |
'-ms-filter: invert(100%); }', | |
head = document.getElementsByTagName('head')[0], | |
style = document.createElement('style') | |
if (!window.counter) { | |
window.counter = 1 | |
} else { | |
window.counter++ | |
if (window.counter % 2 == 0) { | |
css ='html {-webkit-filter: invert(0%); -moz-filter: invert(0%); -o-filter: invert(0%); -ms-filter: invert(0%); }' | |
} | |
} | |
style.type = 'text/css' | |
if (style.styleSheet) { | |
style.styleSheet.cssText = css | |
} else { | |
style.appendChild(document.createTextNode(css)) | |
} | |
head.appendChild(style) | |
} |
@ATLAS-IND-Software I'm not sure what you mean, can you elaborate? This isn't published as an official module anywhere, it's just a gist I was using to experiment with inverting all colors on a website. It does work though.
confirmed does work, removed 'export default' and added 'invert()'
cheers
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
what module do i need to run this shit