Skip to content
This repository has been archived by the owner on Jun 23, 2021. It is now read-only.

How to properly open windows for browser Action popups #32

Closed
RangerMauve opened this issue Aug 28, 2020 · 11 comments
Closed

How to properly open windows for browser Action popups #32

RangerMauve opened this issue Aug 28, 2020 · 11 comments

Comments

@RangerMauve
Copy link

Hey! I'm loving the library. I'm currently working on getting darkreader to run, and I'm having a problem with the popup action.

I'm opening a page to the popupPage URL, and it's loading, but it's stuck on a loading page.

Similarly, when I try to load the beastify webextension example, it's giving me the error browser is not defined. Is there some additional setup I need to do for these pages to make them work correctly? Like, do I need to manually inject the preload script into them?

I'm using electron-extension 6.0.4 and electron 9.2.0

@sentialx
Copy link
Owner

is your popup in the same session as where the extension is loaded?

@RangerMauve
Copy link
Author

I think so, yeah.

Here's where I'm setting the partition: https://github.com/RangerMauve/agregore-browser/blob/master/app/extensions/index.js#L48

Here's where I'm using the partition for the web contents: https://github.com/RangerMauve/agregore-browser/blob/master/app/ui/index.html#L25

It looks like the content scripts from plugins are being injected just fine. 🤔

@sentialx
Copy link
Owner

Any errors in the background page webcontents?

@RangerMauve
Copy link
Author

Hey! Thanks for the follow up, I had to focus on other stuff for a while, just getting back into this.

It seems that it's having issues with getting the active tab URL. It looks like the action popups might be spawning correctly, but I'm not sure how the active tab stuff would work here. 🤔

@RangerMauve
Copy link
Author

I'm adding all the windows with extensions.addWindow

Could the sandboxing be preventing necessary IPC messages or something?

@sentialx
Copy link
Owner

I think not, but I'm not sure

@sentialx
Copy link
Owner

What's actually preventing you from using the new version of this lib?

@RangerMauve
Copy link
Author

I think maybe docs? I tried upgrading earlier and I could get anything to work anymore. 😅

I could try again some time soon.

So far I'm thinking it's a race condition where when I click on the action, the BrowserView containing the web content loses focus and therefore there's no longer an active tab to query.

@RangerMauve
Copy link
Author

Err, it doesn't look like the activeTab variable is getting set anywhere? I'll see if that's the issue and maybe I could submit a PR to fix it if that's the case?

@sentialx
Copy link
Owner

sentialx commented Sep 18, 2020

Oh, you should set session.activeTab property to the corresponding web contents id by yourself.

@RangerMauve
Copy link
Author

It worked! Thank you so much. 😁

I'll submit a PR to the 6-x-y branch with some docs on the activeTab portion. 💜

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants