I need to fetch the URL of current tab using a chrome extension. The extension is a page action extension. So I'm thinking of doing this in content.js
.
I was trying to use something like below in content.js
chrome.tabs.query({active: true, currentWindow: true}, function (tabs) {
url = new URL(tabs[0].url)
console.log(`URL: ${url}`)
})
However, it appears that Chrome.tabs
api is not available in content
scripts.
How can I get the current tab url in content.js
without having use background.js
and use message passing from there.