I want to create an extension for automatically logging into my servers. So I created a background page to check the current URL and if it conforms to my URL regex, I\'ll di
Use chrome.tabs.query with the following parameters:
active: true - To get the active tablastFocusedWindow: true - To select the active windowCode snippet:
// Do NOT forget that the method is ASYNCHRONOUS
chrome.tabs.query({
active: true, // Select active tabs
lastFocusedWindow: true // In the current window
}, function(array_of_Tabs) {
// Since there can only be one active tab in one active window,
// the array has only one element
var tab = array_of_Tabs[0];
// Example:
var url = tab.url;
// ... do something with url variable
});
The activeTab permission is sufficient for this to work.