开发者

avoid chrome popup extension to close

开发者 https://www.devze.com 2023-01-24 22:57 出处:网络
Is there a function that allow me to select text when the extension stays open. 开发者_StackOverflowNormally when I Use the extension popup and I Click outside the

Is there a function that allow me to select text when the extension stays open. 开发者_StackOverflowNormally when I Use the extension popup and I Click outside the extension the extension close. Is there a wat to avoid this.

Thank you so much


Unfortunately there is currently no way to keep the popup open once you focus out of it. This is by design.

If you would like to always show something while interacting with the page, perhaps the experimental Info bars or even Desktop Notifications would work?

Hope that helped!


The only way to keep it open is to right click over the extension icon (button) and select "Inspect popup" the extension popup then show up and remain open but of course the debugger window show and this not a fix obviously still it will maybe inspire a hack... if someone is skilled enough and share the solution with all of us.


I encountered the same problem and I've thought of a possible solution (though not tested it):

Use your background.html to store the content of the popup action and upon loading the popup, you fetch the content via the default messaging for chrome extensions.

When doing all kinds of other stuff, like XHR's or something, I think you should do that in background.html too, so the requests won't abort if you close and you can do something with the result. Then when a user re-opens the popup, he'll see the result of his previous action instead of the default screen.

Anyone tried something like did already?


As far as I know you can't persist a pop up menu but my workaround has been using a content script to append a menu on page load. After the menu is appended you can toggle the menu via messaging between the background script and the content script.

If you want to encapsulate the menu from the page it's deployed on you could wrap your menu in an iframe. This could add complexity to your project since you would have to deal with cross origin issues and permissions.


There is an alternative hack for this. You can make use of chrome local storage to store the metadata as needed. Upon restart you can read that metadata and render the desired content. You will also probably clear that metadata after you have completed performing the operations based on that.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号