I\'m creating my first Chrome extension and I need some help. I I think everything is working except the fact that I can\'t get the current URL of the tab.
var m
Function:
function getCurrentUrl(callBackFuntion){
//you are in content scripts
if(null == chrome.tabs || null == chrome.tabs.query){
callBackFuntion(document.location.href);
}else{
//you are in popup
var queryInfo = {
active: true,
currentWindow: true
};
chrome.tabs.query(queryInfo, function(tabs) {
var tab = tabs[0];
callBackFuntion(tab.url);
});
}
}
Function call:
function alertUrl(url){
console.log("currentUrl : " + url);
}
getCurrentUrl(alertUrl);