我无法在Chromium Version 25.0.1364.160 Ubuntu 12.10(25.0.1364.160-0ubuntu0.12.10.1)上使用chrome.webRequest。尝试访问其方法时,我收到一个未定义的错误。它甚至没有加载到chrome命名空间。这是我的代码和配置:
的manifest.json:
{
"manifest_version": 2,
"name": "My Extension",
"description": "....",
"version": "0.9",
"browser_action": {
"default_icon": "icon.png",
"default_popup": "index.html"
},
"permissions": [
"experimental",
"webRequest",
"webRequestBlocking",
"<all_urls>"
],
"background": {
"scripts": ["index.js"],
"persistent": true
}
}
index.js:
console.log(chrome,'chrome');
输出:
Object
Event: function (opt_eventName, opt_argSchemas, opt_eventOptions) {
app: Object
appNotifications: Object
bookmarks: Object
browserAction: Object
commands: Object
csi: function () { native function GetCSI(); return GetCSI();}
devtools: Object
extension: Object
i18n: Object
infobars: Object
loadTimes: function () { native function GetLoadTimes(); return GetLoadTimes();}
management: Object
omnibox: Object
pageAction: Object
permissions: Object
runtime: Object
scriptBadge: Object
searchBox: Object
tabs: Object
test: Object
tld: Object
types: Object
windows: Object
__proto__: Object
答案 0 :(得分:-2)
进入chrome:// flags /并启用实验扩展API。重新启动浏览器。