gpt4 book ai didi

google-chrome-extension - Chrome 扩展阻止对 popup.html 的编程请求

转载 作者:行者123 更新时间:2023-12-02 04:29:46 26 4
gpt4 key购买 nike

Chrome 66 发布后,我们用于测试 Chrome 扩展的规范失败了,因为我们无法以编程方式访问 popup.html,因为对 chrome-extension://<extension-id>/src/popup.html 的请求被封锁。

Request is blocked when accessing popup.html programmatically

我们尝试使用 chrome.runtime.id 以编程方式获取扩展程序 ID和 chrome.runtime.getURL() .

我们还尝试生成我们自己的 PEM 来对扩展进行签名,并使用 list 中生成的 ID 作为扩展 key 。这两种尝试都没有结果。

还有办法以编程方式访问 Chrome 扩展以进行测试吗?

更新:这是我的 manifest.json :

{
"manifest_version": 2,
"name": "Paparazzi",
"version": "1.0.9",
"background": {
"matches": ["<all_urls>"],
"scripts": [
"src/background.js",
"vendor/jszip.js",
"vendor/FileSaver.js",
"vendor/mixpanel.js"
]
},
"browser_action": {
"default_icon": {
"16": "ic-paparazzi-16.png",
"48": "ic-paparazzi-48.png",
"96": "ic-paparazzi-96.png",
"128": "ic-paparazzi-128.png",
"256": "ic-paparazzi-256.png"
},
"default_popup": "src/popup.html"
},
"commands": {
"capture_screen": {
"suggested_key": {
"default": "Ctrl+Shift+E",
"mac": "Command+Shift+E"
},
"description": "Capture screenshot of current tab"
}
},
"content_security_policy":
"script-src 'self' https://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js; object-src 'self'",
"icons": {
"16": "ic-paparazzi-16.png",
"48": "ic-paparazzi-48.png",
"96": "ic-paparazzi-96.png",
"128": "ic-paparazzi-128.png",
"256": "ic-paparazzi-256.png"
},
"permissions": [
"activeTab",
"cookies",
"identity",
"identity.email",
"notifications",
"tabCapture",
"tabs",
"webRequest",
"webRequestBlocking",
"http://*/",
"*://*.sharethrough.com/*",
"*://localhost/*",
"<all_urls>"
],
"web_accessible_resources": [
"src/*",
"vendor/fonts/MetricWeb-Regular.woff",
"vendor/bootstrap.min.css"
],
"key": "bgcanlbkmndllogdnbohopfomoknmjmf"
}

最佳答案

我在 Chrome 66.0.3359.117 上,我能够得到这样的文件;

chrome.runtime.getURL("popups/popup.html");

window.open() 成功打开页面。当文件夹或文件未在 "web_accessible_resources" 下指定时,它不起作用。

"web_accessible_resources": [
"popups/*"
]

如果问题不在于 list ,则很可能与测试软件有关,而不是 Chrome。

关于google-chrome-extension - Chrome 扩展阻止对 popup.html 的编程请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50047975/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com