0
下面是我的清單chrome.history在自定義擴展不確定
{
"manifest_version": 2,
"name": "Print History",
"version": "0.1",
"permissions": ["history", "tabs"],
"content_scripts": [
{
"matches": [
"<all_urls>"
],
"js": ["content.js"]
}
],
"browser_action":{
},
"background": {
"scripts": ["background.js"]
}
}
下面是我的背景JS:
chrome.browserAction.onClicked.addListener(function(tab) {
// Send a message to the active tab
chrome.tabs.sendMessage(tab.id, {"message": "clicked_browser_action"});
});
下面是內容JS:
chrome.runtime.onMessage.addListener(
function(request, sender, sendResponse) {
if(request.message === "clicked_browser_action") {
alert("hello");
chrome.history.getVisits({"url": "www.facebook.com"},
function (visits) {
if (visits.length >= 0) {
chrome.tabs.sendMessage(sender.tab.id, {
"message": "clicked_browser_action"
});
};
});
}
}
);
的警報打印在屏幕上,我在控制檯中看到一個錯誤,說undefined.getVisits。出於某種原因,chrome.history是未定義的。 讓我知道,如果我失去了一些東西。
謝謝,工作。 – user1455116