How to use chrome.tabs.onUpdated.addListener?

I am creating an extension for Chrome. I want to show alert () with the URL of the page when the user moves from one tab to another or when the user enters a new URL in the tab.

This does not work:

chrome.tabs.onUpdated.addListener(function(integer tabId, object changeInfo, Tab tab) { alert(changeInfo.url); }); chrome.tabs.onActivated.addListener(function(object activeInfo) { // also please post how to fetch tab url using activeInfo.tabid }); 
+6
source share
1 answer

Remove integer , object and Tab in function signature.

 chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) { alert(changeInfo.url); }); chrome.tabs.onActivated.addListener(function(activeInfo) { // how to fetch tab url using activeInfo.tabid chrome.tabs.get(activeInfo.tabId, function(tab){ console.log(tab.url); }); }); 
+22
source

Source: https://habr.com/ru/post/918755/


All Articles