Search code examples
javascriptgoogle-chrome-extensionmessaging

Need to make a partial screenshot in Chrome extension


I have a Chrome extension, and it has a popup window. When clicking the button in popup window, it should allow user to select the area inside current tab, and when it's selected, the partial screenshot should be displayed inside popup.

I tried to send message from popup to content script when clicking this button, and then, when user selected the area, pass the message back. Unfortunately, it seems like when I am closing the popup, the port is also closed and I am facing the Attempting to use a disconnected port object exception.

So, is there any way to make something I want?


Solution

  • This answer solved it: "Attempting to use a disconnected port object" while sending message from content to popup in Chrome extension

    In short: when I close popup, the port closes, so what I decided to do is to use chrome.storage to save a screenshot, then opening in inside a popup.