title: Content script & jQuery. Download/get DOM from different web page
body: <p>I'm trying to modify img src attribute by getting the url from different page. Thing is i need to find it by inspecting DOM as it's not static data; i will be looking via classes and IDs.</p>
  
  <p>My knowledge of chrome extensions is very limited at the time. Basicly i just started.
  Look at the "PSEUDO CODE" part of background.js</p>
  
  <p>manifest.json</p>
  
  <pre><code>{
      "manifest_version" : 2 ,
      "name": "#####" ,
      "version": "1.0" ,
      "description": "#####" ,
      "browser_action": 
      {
          "name": "#####" ,
          "icons": ["icon.png"] ,
          "default_icon": "icon.png"
      },
      "content_scripts": [ 
      {
          "js": [ "jquery.min.js", "background.js" ] ,
          "matches": [ "http://*.#####.com/encounters/promospp.phtml"] ,
          "run_at": "document_end"
      }]
  }
  </code></pre>
  
  <p>background.js</p>
  
  <pre><code>var l = document.getElementsByTagName("div");
  
  for (var i = 0; i &lt; l.length; i++)
  {
      var obj = l[i].parentNode;
      if (l[i].getAttribute("class") &amp;&amp; l[i].getAttribute("class") == "user_contact")
      {
          var div = l[i];
          var id = div.getAttribute("id").replace("u_", "0");
          var profileUrl = "../" + id + "/";
  
          var imgs = div.getElementsByClassName("userpic");
          log("found img.userpic : " + imgs.length);
  
          if (imgs &amp;&amp; imgs.length &gt; 0)
          {
              var img = imgs[0];
  
              var alink = document.createElement('a');
              img.parentNode.appendChild(alink);
  
              alink.setAttribute("href", profileUrl);
              alink.appendChild(img);
  
              // PSEUDO CODE - the unknown
              //
              // download profileUrl page html
              // search for given div element
              // pull src attribute value from it
              // apply it to img here
  
          }
      }
  }
  </code></pre>
  
  <p>So in essence. How to download different page and work with it</p>