SidePanel DOM Access

1,122 views
Skip to first unread message

Ryan Heupler

unread,
Jul 25, 2023, 10:07:58 AM7/25/23
to Chromium Extensions
With the new side panel API, is it possible for a side panel extension to have access to the DOM from the active tab? I.e. if I wanted to overlay something on top of the page through side panel -- like if a user clicks a link and it opens a box overtop the window. is something like that possible?

it looks like it's not possible, as side panel seems to have it's own DOM, but I see that it has access to the active tab, so I'm curious what data comes with that.

wOxxOm

unread,
Jul 26, 2023, 2:24:48 AM7/26/23
to Chromium Extensions, Ryan Heupler
The sidePanel is an entirely separate page with its own chrome-extension:// URL, so you need a content script to access DOM of the web page, see https://developer.chrome.com/docs/extensions/mv3/content_scripts/

The access to the tab you see in the toolbar menu doesn't give you any DOM data by itself, it basically says you have a permission to do things like injecting a content script into this page to get that data. The permission is granted based upon host_permissions or content_scripts->matches or the activeTab permission that depends on user gesture.

Max Nikulin

unread,
Jul 31, 2023, 9:52:41 AM7/31/23
to chromium-...@chromium.org
On 26/07/2023 13:24, wOxxOm wrote:
> The access to the tab you see in the toolbar menu doesn't give you any
> DOM data by itself, it basically says you have a permission to do things
> like injecting a content script into this page to get that data. The
> permission is granted based upon host_permissions or
> content_scripts->matches or the activeTab
> <https://developer.chrome.com/docs/extensions/mv3/manifest/activeTab/>
> permission that depends on user gesture.
I think, there should be an option to inject content scripts into the
current tab in response to a click inside sidePanel without the
<all_urls> permission. Perhaps it may be a more specific permission like
"sidePanel.activeTab" or some switch in UI that allows users to grant
and revoke access to active tab from side panel.

Calling permission.request for each host may be annoying for users.

Consider extensions that e.g. extracts metadata from the current page or
shows dates when links were visited.
Reply all
Reply to author
Forward
0 new messages