使用明显的V3 Chrome扩展名,是否可以将扩展名HTML资源文件加载到新选项卡中?
使用明显的V3 Chrome扩展名,是否可以将扩展名HTML资源文件加载到新选项卡中?我正在考虑提供比Popdown面板提供的更大,全页用户体验的插件。我创建了一个page.html(现在只是简单的html,没有JS或CSS),然后将其放入我的扩展文件夹中。 将其添加到清单中。JSON:
"web_accessible_resources": [
{
"resources": ["page.html"],
"matches": [ "*://*/*" ]
}
]
我重新加载了插件,然后尝试在我的浏览器中引导到此页面
:
然后,我 “无法到达此站点”消息。
With a Manifest v3 Chrome Extension, is it possible to load an extension HTML resource file into a new tab? I was thinking about providing a plugin with a larger, full-page user experience than what the popdown panel could provide. I created a page.html (just simple HTML for now, no JS or CSS) and put it in my extensions folder. I then added this to the manifest.json:
"web_accessible_resources": [
{
"resources": ["page.html"],
"matches": [ "*://*/*" ]
}
]
I reloaded the plugin and then tried navigating to this page in my browser with:
chrome://extensions/MY-EXTENSION-ID-GOES-HERE/page.html
I get an ERR_FAILED and "This site can't be reached" message.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在这种情况下,在这种情况下,在这种情况下,在这种情况下,无需使用
web_accessible_resources
。只需使用以下代码从service-worker.js打开它:这将自动打开类似于...
chrome-extension的东西:///my-extension-id/page.html
...其中my-extension -ID会自动通过
chrome.runtime.geturl('page.html')
填充。然后,您可以在HTML标签中引用远程和本地资源。对于本地资源,只需使用相对路径即可。对于远程资源,请密切关注Google Chrome扩展开发人员政策。
谢谢 woxxom 为他的帮助。
There is no need for a
web_accessible_resources
in this case in the v3 manifest for this action. Just use something like the following code to open it from the service-worker.js:This will automatically open something akin to...
chrome-extension://MY-EXTENSION-ID/page.html
...where MY-EXTENSION-ID is automatically filled in by
chrome.runtime.getURL('page.html')
.You can then reference remote and local resources in your HTML tags. For local resources, just use relative pathing. For remote resources, keep an eye on Google Chrome Extension developer policies.
Thanks goes to wOxxOm for his assistance.