-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How can a content script target a frame? #41
Comments
This could happen in the user’s code, but it would mean having to implement mapping, waiting, registration events, etc… outside I'm going to implement named targets. More in: |
There's a few different scenarios:
Therefore I think supporting a couple patterns could be useful:
Related:
|
Currently the messenger lets us target doSomething({ page: "/iframe.html" }, ...args); it can also target such page in a specific tab: doSomething({ page: "/iframe.html", tabId: 123 }, ...args);
// I think
browser.tabs.sendMessage(tabId, message, {
allFrames: true
}) The messenger does not support this yet, but maybe we can implement it: doSomething({ page: "https://full.page.url/iframe.html", tabId: 123 }, ...args); With two requirements:
Since content scripts cannot use the |
Content scripts should be able to send messages to "the sidebar".
At the moment, the background has some logic to track the sidebar, which I assume is:
https://github.com/pixiebrix/pixiebrix-extension/blob/b37306c112a8d495e226be0b0445d1da33d0c060/src/background/browserAction.ts#L226
This allows the content script to message the sidebar without knowing its ID. This is only possible because there's a smart "middle man" that tracks the connection between the two.
This specific situation could be fixed by having the sidebar register itself directly with the content script instead of the background page. Then the content script will be able to contact the sidebar with the usual
target
information:The text was updated successfully, but these errors were encountered: