title: Triggering a click event from content script - chrome extension
body: <p>In my chrome extension's content script, I click on certain links/buttons on webpages from certain sites. To do that, I use following code in the content script (I embed jQuery in the content script):</p>
  
  <pre><code>$(css_selector).trigger("click")
  </code></pre>
  
  <p>This works on most sites.</p>
  
  <p>However, on certain sites like delta.com, match.com, and paypal.com, this way of triggering a click on elements does not work. On delta.com, I get following exception thrown when I attempt triggering in the content script:</p>
  
  <pre><code>Error: An attempt was made to reference a Node in a context where it does not exist.
  Error: NotFoundError: DOM Exception 8
  </code></pre>
  
  <p>Strange thing is, if I open javascript consoleon delta.com, include a jQuery and attempt the same click triggering code snippet, it works.</p>
  
  <p>On match.com and paypal.com, triggering simply does not work in the content script and there is no error. I cannot even trigger "click" event through javascript console the way I did on delta.com. </p>
  
  <p>If I manually use mouse click, everything works fine on all the three sites. Hence I also tried to simulate that using mousedown(), mouseup(), but that did not work either.</p>
  
  <p>This seems to be issue because javascripts from those sites are hijacking and ignoring events. I tried to read code from these sites to see what is happening but there was simply too much code. </p>
  
  <p>Does anyone have any idea about what is happening here and how to fix it?</p>