How to get or fetch the URL of a Google Chrome tab

First, you've to set the permissions for the tab API :

"permissions": [
    "tabs"
]

And to store the URL :
 
chrome.tabs.getSelected(null,function(tab) {
    var tablink = tab.url;
});