Reputation: 68
captureVisibleTab
[docs] doesn't appear to be working for me in my Google Chrome extension, I've been trying to get it running in a browser action based extension but the image returned is undefined
every time. I then downloaded the example created by Google and this also doesn't appear to work, returning either undefined
or white.png
(a blank white image) as the image src
.
I've tried setting permissions to "tabs", "<all_urls>"
in the manifest.json
files for both projects. I have Google Chrome 37.
I've been trying to find an answer but I don't see any solid information out there, is there a bug, and is there a fix for it? If there's no fix are there any alternatives?
Thanks, Christian.
Edit: I should probably make this part more clear. I downloaded the Google example, installed it, ran the extension on code.google.com, and a blank image was returned see screenshot.
Upvotes: 1
Views: 1492
Reputation: 348972
There are two bugs at play here:
chrome.tabs.captureVisibleTab
requires the <all_urls>
permission (crbug.com/339703).chrome.tabs.onUpdated
is never triggered for extension pages in newly opened extension tabs (crbug.com/411225).The work-around for the first bug is to declare <all_urls>
in the permissions section of the manifest file; the work-around for the second bug is to not use the chrome.tabs.onUpdated
event to detect whether a tab is updated, but use message passing or chrome.runtime.getBackgroundPage
to get the data-URL of the screenshot in the newly opened extension page. (note that you cannot use the webNavigation instead of the tabs API to detect new tabs, because chrome-extension:-URLs are hidden from the webNavigation API).
Upvotes: 2