Skip to content
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

MV3 example for getting data from page/content script/activeTab context into action / popup #533

Open
wesinator opened this issue Jul 13, 2023 · 3 comments
Labels
idle Issues and pull requests with no activity for three months. needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened.

Comments

@wesinator
Copy link

What information was incorrect, unhelpful, or incomplete?

It doesn't seem like there is a concrete example of an extension that gets text/data from the page (activeTab) using a background or content script, and displays that data (or the output of a transformation on the data) in the extension's browser or page action popup.

Presumably this can be done using runtime.sendMessage to pass data from the content script to the action, but there isn't a concrete functioning example, and StackOverflow answers for how to do this are sparse and incomplete.

What did you expect to see?

An up-to-date, MV3 example that parses data on the activeTab page/DOM using a background or content script (e.g. scripting.executeScript()), and displays that data in the extension action popup, using message passing to get the data from the background/content script to the extension action page.

Do you have any supporting links, references, or citations?

https://stackoverflow.com/questions/19758028/chrome-extension-get-dom-content is an example of this, but it doesn't have a working MV3 example in the answers that passes the output/data to the extension browser/page action popup.

Do you have anything more you want to share?

Use cases: I have at least two addons that I'm trying to figure out how to do this.

One is a background context menu addon that does manipulation on selected text: I want to display the output in the browser action popup.

The other is an extension that would find certain elements in the page and offer text transformations on them in the browser action popup.

@wesinator wesinator added the needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. label Jul 13, 2023
@github-actions
Copy link

It looks like this is your first issue. Welcome! 👋 One of the project maintainers will be with you as soon as possible. We appreciate your patience. To safeguard the health of the project, please take a moment to read our code of conduct.

@github-actions github-actions bot added the idle Issues and pull requests with no activity for three months. label Aug 13, 2023
@dipikabh
Copy link

Hello @wesinator, thanks for the issue.

I was wondering if you've had a chance to check the existing examples on MDN. They might have some relevant / useful implementations:

I wanted to check with you on this before triaging and prioritizing this work. Let me know if you've already looked into these and whether they are of any help. Thanks!

@github-actions github-actions bot removed the idle Issues and pull requests with no activity for three months. label Oct 12, 2023
@wesinator
Copy link
Author

wesinator commented Oct 14, 2023

Hi @dipikabh I have looked at them , thanks!

The "use case" I'm describing here is not captured by any of the existing ones or API examples from what I've seen.
This example I'm describing is one layer more complex than the examples (which are generally very simplistic and "one-dimensional"), and one that I didn't easily figure out how to do in testing.

I started an example at https://stackoverflow.com/questions/19758028/chrome-extension-get-dom-content/76708728#76708728 that can parse the active tab DOM upon clicking a button in the popup, and then display the content to a popup.

I couldn't figure out how to get the output of a function from a contextMenu extension passed to a popup - this may be a browser/webextensions limitation. See w3c/webextensions#160 (comment)

Regards,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
idle Issues and pull requests with no activity for three months. needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened.
Projects
None yet
Development

No branches or pull requests

2 participants