我正在尝试开发chrome中的扩展程序,它可以窥探浏览器历史记录并将其发送到远程计算机。我需要建立套接字连接来传输数据。 但我得到了上述错误。在线阅读了很多帖子,说明在套接字权限的上下文中清单文件中必定存在错误。任何人都可以找出错误吗?请检查下面的代码。
清单文件:
{
"manifest_version": 2,
"name": "Browser History Snooping",
"description": "This extension snoops browser history and sends it to a remote machine",
"version": "1.0",
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"permissions": [
"history"
],
"sockets": {
"tcp": {
"connect": ""
}
}
}
的JavaScript
var histories = [];
var visits = [];
chrome.history.search({
text: '',
maxResults: 0
}, function (historyItems) {
var historiesProcessed = 0;
for (var i = 0; i < historyItems.length; i++) {
//histories.push(historyItems[i]);
console.log(historyItems[i]);
chrome.history.getVisits({
url: historyItems[i].url
}, function (visitItems) {
for (var i = 0; i < visitItems.length; i++) {
visits.push(visitItems[i]);
}
historiesProcessed++;
if (historiesProcessed === historyItems.length) {
console.log(visits.length + ' visits');
}
});
}
console.log(histories);
});
chrome.sockets.tcp.create({}, function (createInfo) {
chrome.sockets.tcp.connect(createInfo.socketId, '127.0.0.1', 8888,
function (result) {
if (result >= 0) {
console.log('Successfully connected');
}
});
});
答案 0 :(得分:3)
错误不言自明:SessionAware
未定义。
extension documentation中没有HttpSession
API,但它是为chrome apps定义的。