I'm trying to develop a chrome extension that will capture screenshots without user intervention and push them to a server. I do not intend to publish this extension, I just want to develop it for me. I would feed the extension with a list of urls to visit on a daily base and then capture screenshots and send them to a server.
I'm already stuck by a permission problem at the very beginning. Here is the code in background.js:
chrome.tabs.create({ url: 'https://www.example.com', active: true }, tab =>
{
if (chrome.runtime.lastError)
{
console.error(chrome.runtime.lastError);
}
else
{
console.log(tab);
chrome.tabs.captureVisibleTab(null, {format: 'png'}, function(dataURI)
{
// do something
});
}
});
When running this code, I get the following error: Unchecked runtime.lastError: Cannot access contents of url "". Extension manifest must request permission to access this host.
In my manifest, I have:
"host_permissions":
[
"tabs",
"*://*/",
"http://*/",
"https://*/",
"<all_urls>",
"notifications",
"webRequest",
"webNavigation",
"management",
"storage",
"webRequestBlocking",
"http://*/*",
"background",
"alarms",
"desktopCapture",
"activeTab",
"https://*/*"
],
"permissions": [
"tabs",
"http://*/",
"https://*/",
"<all_urls>",
"notifications",
"webRequest",
"webNavigation",
"management",
"storage",
"webRequestBlocking",
"http://*/*",
"background",
"alarms",
"desktopCapture",
"activeTab",
"https://*/*"
],
"background": {
"scripts": ["background.js"],
"persistent": true
},
"content_scripts": [
{
"matches": ["http://*/*", "https://*/*"],
"js": ["content.js"]
}],
"browser_action": {
"default_icon": "logo.png",
"default_popup": "popup.html"
}
There are multiple discussions about this topic on stackexchange, I have applied recommendations about permissions but it still doesn't work.
Where am I missing something?
Thanks
Laurent