Search code examples
google-chrome-extensionscreenshot

How to take screenshot of a tab in chrome extension


I am adding screenshot support to my extension, I want to take screenshot of a tab when a specific event is triggered, for example, a url is accessed. Now I am able to take screenshot of current tab using chrome.tabs.capturevisibletab, but the problem is that the event can be triggered by a tab that is not currently visible. So instead of visible tab, how can I take screenshot of any specific tab?


Solution

  • The method name is clear: capturevisibletab.

    You can put the focus on the tab you want to snapshot, invoke the method and the restore the focus on the previous tab though.
    You will need to add the <all_urls> permission in your manifest file.