Adding an overlay icon on images

12 views
Skip to first unread message

Ken W

unread,
Apr 13, 2017, 1:37:03 PM4/13/17
to Chromium-Extensions-Announce
Hello,

New to Chrome Extensions but was wondering how I can add an icon overlay on all images on a webpage


Thanks
Ken

PhistucK

unread,
Apr 13, 2017, 6:05:35 PM4/13/17
to Ken W, Chromium-Extensions-Announce
Using a content script, you can search for all of the images (document.querySelectorAll("img, canvas")) and add the overlay to them.
Using MutationObserver, you can take care of any image that is dynamically added.

If you also want to add overlays to background images, that will be tricky and have some performance repercussions, by going through all of the elements, running getComputedStyle on them and checking whether background-image has a value and adding another image to it.


PhistucK

--
You received this message because you are subscribed to the Google Groups "Chromium-Extensions-Announce" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsub...@chromium.org.
To post to this group, send email to chromium-extensions@chromium.org.
Visit this group at https://groups.google.com/a/chromium.org/group/chromium-extensions/.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/a0145dc7-5154-47c8-941e-13d5f55f05f3%40chromium.org.
For more options, visit https://groups.google.com/a/chromium.org/d/optout.

Reply all
Reply to author
Forward
0 new messages