Accessing images before their display
Posted by azerty_04@reddit | learnprogramming | View on Reddit | 3 comments
Hello. I'm trying to create a simple browser extension using HTML and Python code, which edits the pictures before they're displayed, but I can't figure out how to actually access them before they load.
Any ideas as to how to do this?
PlatformWooden9991@reddit
you probably need to intercept the network requests before images get downloaded, not after they load in dom
azerty_04@reddit (OP)
And how exactly do I do that?
carcigenicate@reddit
You could try registering a mutation observer on the parent element. If the replacement is fast and synchronous, you may be able to replace it before the original image renders.