![](/img/trans.png)
[英]Uncaught TypeError: Cannot read property 'tcp' of undefined in chrome extension
[英]error Uncaught TypeError: Cannot read property 'onVisited' of undefined in chrome extension
我想在用户访问faceboook url时记录日志,但是在使用onVisited时出现错误。
这是我的background.js
chrome.history.onVisited.addListener(function(historyItem){
if(historyItem.url === "https://www.facebook.com/"){
console.log('user visits '+historyItem.url+ ' at '+historyItem.lastVisitTime+ ' number of times visited '+historyItem.visitCount);
}
});
我还在manifest.json中添加了权限:
{
"manifest_version": 2,
"name": "My Proj Extension",
"version": "0.1",
"background":{
"scripts":["background.js"],
"permissions": ["tabs", "history"]
},
"content_scripts":[
{
"matches": ["<all_urls>"],
"js": ["content.js"]
}
]
}
任何人都可以提出建议,为什么这不起作用以及我还能怎么做。
权限密钥不应在背景中:
{
"manifest_version": 2,
"name": "My Proj Extension",
"version": "0.1",
"permissions": ["tabs", "history"],
"background":{
"scripts":["background.js"],
},
"content_scripts":[
{
"matches": ["<all_urls>"],
"js": ["content.js"]
}
]
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.