Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Screenshot using chrome.tabs.captureVisibleTab

I'm 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:

Unchecked runtime.lastError while running tabs.captureVisibleTab: The 'activeTab' permission is not in effect because this extension has not been in invoked.

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 being made from a background script
  • I'm matching <all_urls>

Why do I get that error?

like image 862
chris Avatar asked Feb 03 '15 21:02

chris


1 Answers

There are things that talk about <all_urls> as something to match, but what I was missing was the <all_urls> permission. After I added the permission, it worked.

like image 91
chris Avatar answered Oct 22 '22 07:10

chris