title: Chrome extension : get source code of active tab
body: <p>I Need to get source code of current tab when the chrome extension icon is clicked . i have also tried with button click event. Please go through my current code :</p>
  
  <p>manifest.json</p>
  
  <pre><code>    {  "name": "UM Chrome Extension!",  "version": "1.0",
    "description": "To ensure the tracking codes present.",
      "icons": {
  "128": "TW-Extension-Icon2.png"
  },   "background": {
        "scripts": [ "background.js"]
     }, 
    "content_scripts": [
      {
        "matches": ["http://*/*"],  
        "js": ["popup1.js","jquery-1.10.2.js","jquery-ui.js","bootstrap.min.js"]
      }
      ], 
      "permissions": [
      "activeTab","tabs","contextMenus", "http://*/*"
    ],
  
    "browser_action": {
      "default_popup": "popup.html"
    },
    "manifest_version": 2
  }
  </code></pre>
  
  <p>popup.html</p>
  
  <pre><code>&lt;!doctype html&gt;
  &lt;html class="no-js" lang=""&gt;
      &lt;head&gt;
          &lt;script type="text/javascript" src="popup1.js"&gt;&lt;/script&gt;
      &lt;/head&gt;
  
      &lt;body style="width: 600px; height: 300px;"&gt;
  &lt;button value="Test" id="check-1"&gt; &lt;/button&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>and popup.js</p>
  
  <pre><code>window.addEventListener('DOMContentLoaded', function() {
  var fbshare = document.querySelector('#check-1');
      fbshare.addEventListener('click', function() {
          var htmlCode = document.documentElement.outerHTML;
       window.alert(htmlCode);
        });
  
  });
  </code></pre>
  
  <p>How to get active tab's source code ? i need to get source code of the page so that i need to search whether the page contains particular tracking code(like GA code).</p>
  
  <p>Thank You</p>