title: Getting the url of the current page in a chrome extension
body: <p>I am trying to log all requests that are made for each page that I load. Here are the <code>manifest.json</code> and <code>background.js</code> files for it.  </p>
  
  <p><code>manifest.json:</code></p>
  
  <pre><code>{
    "name": "Requests",
    "version": "1.0",
    "description": "Log Requests",
    "permissions": ["webRequest",
    "webRequestBlocking",
      "tabs",
      "&lt;all_urls&gt;"],
    "background": {
      "scripts": ["background.js"]
    },
  
    "manifest_version": 2
  }
  </code></pre>
  
  <p><code>background.js:</code></p>
  
  <pre><code>var url = ''
  
  chrome.tabs.query({currentWindow: true, active: true}, function(tabs){
      url = tabs[0].url;
  });
  
  chrome.webRequest.onBeforeRequest.addListener(
    function(info) {
  
      console.log("Request for " + url + ':  --&gt; ' + info.url);
    },
    // filters
    {
      urls: ["&lt;all_urls&gt;"]
    },
    // extraInfoSpec
    ["blocking"]);
  </code></pre>
  
  <p>The issue that I have is that the <code>url</code> parameter inside <code>background.js</code> always contains <code>chrome://extension/</code> no matter which page I am loading. I do not understand why this could be happening. I tried to use <code>window.location</code> to give me the current url, but thats returning the same  value as well. Could anyone please help?</p>