Duplicate of Display current URL in a chrome extension
The solution in my 'background.js':
$(document).ready(function(){
chrome.tabs.query({'active': true, 'lastFocusedWindow': true, 'currentWindow': true}, function (tabs) {
var url = tabs[0].url;
console.log(url);
alert(url)
})
})
did not work for me. I also gave 'tabs' permission on manifest.json
{
"manifest_version": 2,
"name": "YtDl",
"version": "0.1",
"permissions": ["tabs"],
"background": {
"persistent": false,
"scripts": ["jquery.min.js", "background.js"]
},
"content_scripts":[
{
"matches": ["<all_urls>"],
"js": ["jquery.min.js", "content.js"],
}
]
}
is there any other solution to get current tab url?
NOTE: I am trying to get URL from background script. when i reload the extension it works for one time in 'chrome://extensions/' and does not work at any other site.