0

So I want wrote some code which will allow me to take a screenshot of the page when a button is pressed on my website. The code works, but the only problem is that I have to click on the chrome extension first, and then I can click on the button for it to take the screenshot. I guess that's because the active tab is not invoked. Any ideas? This error does not occur in Ubuntu and Mac, only windows.

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

Chrome version

52.0.2743.116 m (64-bit)

My manifest.json

"permissions": [
    "tabs",
    "activeTab",
    "tabCapture",
    "<all_urls>",
    "privacy"
  ]

background.js

chrome.tabs.captureVisibleTab(self.windowId, {
          'format': 'png'
        }, function(dataURI) {
          ....
        });
fpalma
  • 25
  • 5
  • Remove `"activeTab"` because you're using `""` which is a superset of the former. – wOxxOm Aug 30 '16 at 18:12
  • I removed the permission activeTab, but the error continues – fpalma Aug 30 '16 at 18:24
  • If you properly reloaded the extension on chrome://extensions page the error can't be the same unless it's a bug in Chrome. – wOxxOm Aug 30 '16 at 18:25
  • Yeah. This problem only happens on ms windows. – fpalma Aug 30 '16 at 18:31
  • Well, it's not important if the tab is actually captured, right? At least on my Windows PC your code works. So just check chrome.runtime.lastError in the code to make it happy. – wOxxOm Aug 30 '16 at 18:43
  • How could I do this? – fpalma Aug 30 '16 at 19:03
  • `var ignoreError = chrome.runtime.lastError;` – wOxxOm Aug 30 '16 at 19:08
  • I printed "chrome.runtime.lastError" before call the "captureVisibleTab". The lastError is undefined. – fpalma Aug 30 '16 at 19:31
  • `undefined` means no error. – wOxxOm Aug 30 '16 at 19:32
  • I'm tempted to close this as a dupe of https://stackoverflow.com/questions/28431505/unchecked-runtime-lasterror-when-using-chrome-api/ – Xan Aug 31 '16 at 10:12
  • I found the source of the problem. Before the captureVisible code, my plugin mimimize the window.... ** chrome.windows.update(window.id, { state: 'minimized' }, function() { if (chrome.runtime.lastError) { console.warn('Error (windows.update): ' + chrome.runtime.lastError.message); } });. ** Because I would like the my user does not see the window. When the window is minimized, the captureVisibleTab does not work for me. – fpalma Aug 31 '16 at 17:17

0 Answers0