提问人:Kritidipto Ghosh 提问时间:7/12/2023 最后编辑:Kritidipto Ghosh 更新时间:7/12/2023 访问量:77
为什么web_accessible_resource能够访问 chrome 扩展程序中的其他非web_accessible_resource?
Why is a web_accessible_resource able to access other non - web_accessible_resource in chrome extension?
问:
我有一个正在本地开发的 chrome MV3 扩展。
现在,我有一个内容脚本,可以将 iframe 注入用户站点。
iframe 的 html src 是一个文件,我们使用 url 。
现在这个文件也链接了 a & a。sample.html
chrome.runtime.getURL('/iframeinjector/sample.html'))
sample.css
sample.js
当我声明iframe时.html web_accessible_resource我也可以导入css和js文件,而无需web_acesssible_resources这些文件。
如果我不web_accessible_resources中声明它.html预计我无法访问 iframe。那么为什么我能够访问 CSS/JS 文件而不将它们声明为 web_accessible_resource .
manifest.json
...
"web_accessible_resources": [
{
"resources": [
"/iframeinjector/sample.html",
],
"matches": ["<all_urls>"],
"extension_ids": ["extension_id1234"]
}]
...
内容脚本.js
$injectedIframe.setAttribute('id', 'extension-iframe');
$injectedIframe.setAttribute('src', chrome.runtime.getURL('/injectediframe/sample.html'));
示例:.html(iframe src)
<html>
<head>
<link rel="stylesheet" type="text/css" href="bootstrap/built.min.css"></link>
</head>
<body >
<script type="text/javascript" src="./script.js"></script>
</body>
</html>
我上传到 chrome 的 dist 包含那些 js 和 css 文件。 鉴于web_accessible_resource的定义,如果资源未列出,我不希望资源可用。
答: 暂无答案
评论
chrome-extension://id/