You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It does not seem currently possible to inject content-scripts into pages loaded via the protocol handler API. I tested the following methods:
content_scripts manifest key: Custom protocol patterns (e.g. dweb://*/*) are not accepted under the matches key. Also using <all_urls> does not trigger for custom protocols.
browser.tabs.executeScript for tab loading a custom protocol url. This gives me the error: "Missing host permission for the tab".
My use-case for content-scripts on these pages is to inject APIs into the pages. The content-script is required to create a communication channel between the page and the extension background. An alternative to using content-scripts would be a method to add APIs to a protocol, as part of browser.protocol.
The text was updated successfully, but these errors were encountered:
Thanks for reporting. It seems that WebExtensions are supporting specific set of protocols only based on the documentation:
The special value "<all_urls>" matches all URLs under any of the supported schemes: that is "http", "https", "ws", "wss", "ftp" and "file".
Presumably list of supported protocols is there to avoid loading content scripts into things like about:, chrome:, resource:. So we'd need to discuss this with the Web Extension team to see what are our options there.
An alternative to using content-scripts would be a method to add APIs to a protocol, as part of browser.protocol.
I think this is reasonable. Still it's likely will need to use same content script infrastructure and to be honest I'm not sure there will be much benefit to this over just content scripts.
I would much rather prefer API like:
navigator.permissions.query({name: something})
Where addon's could subscribe to requests on something and optionally return implementation. I'm trying to discuss this but it's also unlikely to make it anytime soon.
I think the best bet right now would be to define a REST API to the extension background with a protocol handler itself. And then use fetch or XMLHttpRequest to interact with it.
It does not seem currently possible to inject content-scripts into pages loaded via the protocol handler API. I tested the following methods:
content_scripts
manifest key: Custom protocol patterns (e.g.dweb://*/*
) are not accepted under thematches
key. Also using<all_urls>
does not trigger for custom protocols.browser.tabs.executeScript
for tab loading a custom protocol url. This gives me the error:"Missing host permission for the tab"
.My use-case for content-scripts on these pages is to inject APIs into the pages. The content-script is required to create a communication channel between the page and the extension background. An alternative to using content-scripts would be a method to add APIs to a protocol, as part of
browser.protocol
.The text was updated successfully, but these errors were encountered: