Any way to get a screenshot of non-active tabs?

So I see tabs.captureVisibleTab() which allows for capturing active tabs, but is there any way to get screenshots of non-active ones? What I’d like to be able to do is create a UI with all the tabs shown in a grid, with a small screenshot of each as a preview, similar to what the old Tab Groups UI looked like.

You can try to inject a content script in your tab to create a canvas, use context2d.drawWindow() to capture the content and send the data back to your add-on background.

I’m not 100% sure drawWindow() will work well if the tab is not the active but it’s worth the try.

Hmm, so it won’t work for tabs I can’t inject scripts into (which I guess is an acceptable compromise), but otherwise this seems to do exactly what I want it to do. Thanks!

Maybe you can also consider a non-active tab is very likely to have been active at some point and you were able to use tabs.captureVisibleTab(). If you do a good job saving thumbnails whenever you can do it and caching those images, that may work.

You should check whether tabs.captureVisibleTab() works on Firefox admin pages like about:addons or about:config as if it as been implemented the way i suggested, it may not work for the reason you mentioned.

Hmm, to be honest, the set of tabs I can’t inject stuff into is probably small enough in general that it probably wouldn’t even matter if they were missing screenshots. I might look into that kind of strategy as a backup mechanism once I get the main bits in place, though.