gpt4 book ai didi

javascript - 如何使用 "chrome.webRequest.onBeforeRequest"?

转载 作者:行者123 更新时间:2023-11-29 22:24:43 24 4
gpt4 key购买 nike

Chrome 一直说:“无法读取未定义的属性‘onBeforeRequest’”。我不明白为什么。

背景.html:

<html>
<head>
<script type="text/javascript">// <![CDATA[
try
{
chrome.webRequest.onBeforeRequest.addListener(function(e){alert("onBeforeRequest")},{urls: ["http://*/*", "https://*/*"]}, ["blocking"]) ;
}
catch (ErrorMessage)
{
alert('page:'+ErrorMessage) ;
}


// ]]></script>
</head>
</html>

list .json:

{
"name": "first extension",
"version": "1.0",
"description": "first extension",
"browser_action": {
"default_icon": "icon.gif",
"popup": "popup.html"
},

"permissions":
["tabs", "chrome.webRequest", "webNavigation", "management", "http://*/*", "https://*/*"],
"background_page": "background.html"
}

最佳答案

webRequest API 请求权限的正确方法是 webRequest(没有 chrome.)。

"permissions": [
"tabs",
"webRequest",
"webNavigation",
"management",
"http://*/*",
"https://*/*"
],

关于javascript - 如何使用 "chrome.webRequest.onBeforeRequest"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10277222/

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