Как отследить переход на новую страницу (не на вкладку) используя API Chrome?
Пытаюсь так, но, наверное, неправильно:
chrome.windows.onCreated.addListener(function(win){
chrome.windows.get(win.id,{populate:true},function(tabwin){
setTimeout(function(){
//chrome.tabs.executeScript(tabwin.tabs[0].id,{code:"alert(JSON.stringify(window));",runAt:'document_idle'});
console.log('onCreated');
},500);
});
});
Дополнение:
Вылетает ошибка, когда пытаемся отправить сообщения: extensions::schemaUtils:113 Uncaught Error: Invocation of form tabs.sendMessage(integer) doesn't match definition tabs.sendMessage(integer tabId, any message, optional object options, optional function responseCallback)
chrome.tabs.onUpdated.addListener(function (tabId, changeInfo, tab) {
if(changeInfo.url != null) {
console.log('изменилось '+changeInfo.url);
console.log('tabId '+tabId);
setTemer(tabId);
}
});
function setTemer(tabs_id){
setInterval(function(){
chrome.tabs.sendMessage(tabs_id), {greeting: "hello"}, function (response) {
//console.log("ID - "+tabs);
};
}, 6000);
}
sendMessage
то даже и не знаю как я смогу его отпарвить, каким образом.