Is there a way to close the Chrome extension popup when the user is on a separate chrome window?

The script I'm trying to get is:

If the user opens the extension pop-up window in Chrome 1 and does not close the pop-up window, the moment the user opens another Chrome window (window 2) and starts working with it, I want the pop-up window in window 1 to close,

Basically, only the active Chrome window can open an extension popup.

+4
source share
1 answer

Hm. I did not know that pop-ups worked like that!

, . chrome.extension.getViews() .

, :

chrome.extension.getViews({type: "popup"}).forEach(function(win) {
  if(win != window) win.close(); 
});

API ( , ), .

+3

All Articles