Screenshot using chrome.tabs.captureVisibleTab

I am trying to capture the visible area of ​​a page using chrome.tabs.captureVisibleTab. Here is the code that makes the call:

chrome.extension.onMessage.addListener(function(request, sender, sendResponse) {
    if (request.name == 'screenshot') {
        chrome.tabs.captureVisibleTab(null, null, function(dataUrl) {
            sendResponse({ screenshotUrl: dataUrl });
        });
    }
});

But when I try to capture the tab, I get this error:

An unproductive runtime.lastError while running tabs.captureVisibleTab: The permission "activeTab" does not work because this extension was not called.

Here is my manifest file:

   {
  "manifest_version": 2,

  "name": "Empathy",
  "version": "0.1",

  "description": "Simulate accessibility issues for websites.",

  "browser_action": {
    "default_icon": "empathy19.png",
    "default_title": "Empathy!"
  },

  "permissions": [
    "activeTab",
    "contextMenus",
    "desktopCapture",
    "tabCapture",
    "tts" // Text-to-speech
  ],

  "background":   {
    "scripts": [
      "boot.js"
    ],
    "persistent": false
  },

  "content_scripts": [
    {
      "matches": ["<all_urls>"],
      "js": [
        "src/helpers.js",
        "src/colorblindness.js",
        "lib/colorvision.js",
        "lib/html2canvas.js"
      ]
    }
  ]
}
  • I have active tab permissions
  • The call is made from a background script
  • I agree <all_urls>

Why am I getting this error?

+4
source share
1 answer

, <all_urls> - , , , <all_urls>. , .

+5

All Articles