[gpt4] made me able to toggle image black/white invertion in JS

I extract black on white pages from PDF and feed into image occlusion enhanced.
the white backgrounds are killing my eyes.

googled and found this post:

that code allow image black white invertion.

with gpt4,
I 1st ask for a button to toggle it.
2nd i asked for a hardcoding into the note type.

so now with the following code,
you can hardcode into the notetype whether you want it all black by default or all white (forgive my political correctness),
and you can toggle with a button e.g. when you are reading a photo that need truth in color.

gpt4 is hard to help a layman to create a completely new thing,
but it’s a very powerful tool to let part-time-guy to modify existing thing.


const defaultInverted = true;


window.onload = function() {

var images = document.querySelectorAll('img');

images.forEach(img => {

img.style.filter = defaultInverted ? 'invert(1)' : 'none';






document.addEventListener('keydown', function(event) {

if (event.key === 'l') { // Change 'i' to your preferred toggle key

var images = document.querySelectorAll('img');

images.forEach(img => {

img.style.filter = img.style.filter === 'invert(1)' ? 'none' : 'invert(1)';





btw, the button didn’t work on chromebook’s ankidroid, i tried.

but the hardcoded status do work on my android phone (i suppose same thing)

ps, the 2nd IO will not be working… a small bug… will try fix later.

looks like not easy to make every card inverted according to the hardcoded status.

but at least you can use a button to toggle the invertion individually… sigh…

ps, so the current best use is hardcode the above as “false”,
and then you can toggle each card now with a button.

this JS by gpt4 is good for me.

but did anyone indeep found existing better solutions?


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.