title: Google Chrome extension: Getting all links in page
body: <p>I am trying to make chrome extension, that can recursively go trough the website and search for common error message strings (like "Error 500" etc.), for web developer testing. </p>
  
  <p>The first step is get all links from the active tab. So, in my extension's background script I have this code snippet: </p>
  
  <pre><code>var $html = jQuery(html);
  
  var links = [];
  $html.find('a').each(function(){
      console.log(this);      
      console.log(this.href);
      //links.push(this.href); 
  });
  </code></pre>
  
  <p>But output of this script is weird for relative links: </p>
  
  <pre><code>&lt;a href=​"/​" id=​"logo"&gt;​&lt;/a&gt;​
  chrome-extension://kmldadmcjflefibfflbkpmgjdpklghfa/ 
  
  &lt;a href=​"#top"&gt;About&lt;/a&gt;​
  chrome-extension://kmldadmcjflefibfflbkpmgjdpklghfa/background.html#top 
  
  &lt;a href=​"/articles/applications/​1"&gt;​Web applications&lt;/a&gt;​
  chrome-extension://kmldadmcjflefibfflbkpmgjdpklghfa/articles/applications/1 
  </code></pre>
  
  <p>Though element's <code>href</code> attribute has the value '/', dumped <code>this.href</code> outputs 'chrome-extension://kmldadmcjflefibfflbkpmgjdpklghfa/'. </p>
  
  <p>How can I get link's href value without 'chrome-extension://blahblahblah/' ? </p>