CHROME扩展笔记之页面更新监听

/**
* 监听tab页面变化(用于处理页面logo问题)
*/
chrome.tabs.onUpdated.addListener(function(tabId,changeInfo,tab){
     
	if( changeInfo.url == undefined){
     return false;}
	// 检查是否是wish页面的tab
	if(tab.url.indexOf('pinterest.com') > 0){
     
		// 通知对应的tab页面url变化了,需要优化为离开立即移除,进入则加载完毕再添加
		if (tab.status === 'loading'){
     
			sendMessageToContentScript(tabId,{
     type:'tabUpdate', tab:tab}, function(response)
			{
     
				console.log('来自content的回复:'+response);
			});
		}
	}
});

你可能感兴趣的:(js,chrome,javascript)