I am very new to web application and even more new to browser extension development. I have created a simple browser extension which is working properly on clicking on the extension button near the browser address bar. But if the browser extension popup is open and I switch the browser window, the browser UI (a small popup like page, popup.html) disappears. On clicking again, it opens. But I want know if somehow I can keep it open even on a window/tab switch. I would like to close that popup only when user closes it, presses escape or does not do any activity on it for say 10sec or something. This expected behavior is close to how the pocket extension behaves. How is this achieved?
Asked
Active
Viewed 234 times
0
-
1possible duplicate of [Click make popup disapear](http://stackoverflow.com/questions/25805777/click-make-popup-disapear) – Xan Feb 24 '15 at 14:21
-
The answers to that question indicates that it is not doable. But as I can see, the Pocket extension does achieve it. How is it done? – labyrinth Feb 24 '15 at 15:53
-
It does not show any popup. It injects UI directly into pages. – Xan Feb 24 '15 at 15:58
-
Sorry if my questions are extremely basic to be discussed here, but how do you know that it inject UI directly into pages? As in I checked the source of page when extension was not open and when it was open, but I could not see any change! – labyrinth Feb 24 '15 at 17:40
-
I looked at the (uglified) source code of the extension - it does not use popups but an `onClicked` listener. Besides, it's easy to see that the UI it shows is not connected to the button / not framed as popups are. And, as said above, it's impossible to keep a popup open if it loses focus. Sorry, I already nuked the account I created to test it, so I won't look again. – Xan Feb 24 '15 at 17:42
-
After your comments, I took a closer look at the extension architecture and understood how the injection works. But, I am now even surprised to see that Pocket app works even without a very long list of web_accessible_resources in their manifest: just a few font and image files. Any idea how that works then? – labyrinth Feb 26 '15 at 18:27
-
Do you understand that this discussion is totally inappropriate for this comment thread? – Xan Feb 26 '15 at 18:29
-
Yes. May be I will post another question for this.Thanks! – labyrinth Feb 26 '15 at 18:44
1 Answers
-1
You can try this:
chrome.browserAction.onClicked.addListener(function() {
chrome.windows.create({ url: "popup.html", type: "popup"})
})
Include this in a background page defined in the manifest:
"background": { "scripts": ["background.js"], "persistent": false },

Daniel Herr
- 19,083
- 6
- 44
- 61
-
Nope, that's a different meaning of "popup" (that always bugged me in the Chrome API terminology) – Xan Feb 25 '15 at 23:14
-
-
It matters, because (in my opinion) you're answering the wrong question. This is neither advice to keep the browser action popup open, nor an explanation how Pocket extension does it. – Xan Feb 25 '15 at 23:19
-