title: Chrome extension. Get element after redirect with jquery
body: <p>manifest.json:</p>
  
  <pre><code>{
  "manifest_version": 2,
  
  "name": "Name",
  "description": "Description",
  "version": "1.0",
  
  "browser_action": {
      "name": "Manipulate DOM",
      "icons": ["icon.png"],
      "default_icon": "icon.png",
      "default_popup": "index.html"
  },
  "content_scripts": [ {
      "js": [ "jquery.min.js", "custom.js" ],
      "matches": [ "http://*/*", "https://*/*"]
    }],
  "permissions": [
      "activeTab", "tabs", "&lt;all_urls&gt;", "webRequest "
  ]}
  </code></pre>
  
  <p>custom.js:</p>
  
  <pre><code>function hello() {
  chrome.tabs.executeScript({
      file: 'alert.js'
  }); 
  }
  document.getElementById('clickme').addEventListener('click', hello);
  </code></pre>
  
  <p>alert.js:</p>
  
  <pre><code>$('input[name="firstname"]').val('Alex');
  $('input[name="lastname"]').val('Jefferson');
  $('button[name="submit"]').trigger('click');
  </code></pre>
  
  <p>After trigger('click'), a redirect to another page with second form.
  How can I fill a second form?
  "$('#elem').val();" does not work in new page.</p>
  
  <p><strong>UPD:</strong> my background.js code:</p>
  
  <pre><code>function secondStep() { 
      chrome.tabs.executeScript(null, {file: "secondStep.js"}); 
      chrome.webNavigation.onCompleted.removeListener(boundX); 
  } 
  
  chrome.browserAction.onClicked.addListener(function(tab) { 
      chrome.tabs.executeScript(null, {file: "firstStep.js"}, function() { 
          var boundX = secondStep.bind(); 
          chrome.webNavigation.onCommitted.addListener(boundX);   
      }); 
  });
  </code></pre>