title: Get current tab url - Chrome Extension
body: <p>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 <code>content.js</code>. </p>
  
  <p>I was trying to use something like below in content.js</p>
  
  <pre><code>chrome.tabs.query({active: true, currentWindow: true}, function (tabs) {
      url = new URL(tabs[0].url)
      console.log(`URL: ${url}`)
  })
  </code></pre>
  
  <p>However, it appears that <code>Chrome.tabs</code> api is not available in <code>content</code> scripts. </p>
  
  <p>How can I get the current tab url in <code>content.js</code> without having use <code>background.js</code> and use message passing from there.</p>