title: How to automatically press ENTER key/Confirm alert box with javascript/jquery
body: <p>I'm writing a userscript (javascript/jquery) to automate some things in a browser game. There's an auction where products can be bought with a discount. I want a script that automatically buys goods when it has 33% discount.</p>
  
  <p>The script runs on the url of the auction (greasemonkey), then checks if there are products with at least 33% discount  - if that's the case then it will press the button in that row to buy the product.</p>
  
  <p>The problem I'm facing now is: Once you have pressed the button, you have to confirm you want to buy the goods via an alert box. Is there a way to automate this?</p>
  
  <p>I've googled and also checked stackoverflow and people say it's not possible with javascript/jquery. Is this really the case? That would mean it's basically impossible to automate buying goods in the browser game i'm playing. I was thinking of letting the script automatically press ENTER because that would be the same as clicking 'Ok' in the alert box. But that also is impossible they say. So now i'm wondering: is there a way to automate this?</p>
  
  <p>This is the code behind the button: </p>
  
  <pre><code>&lt;input id="buybutton_3204781" class="button" type="button" onclick="if(confirm('Wil je deze producten kopen?')){document.submitForm.BuyAuctionNr.value=3204781; document.submitForm.submit();}{return false;}" value="Kopen"&gt;
  </code></pre>
  
  <p>EDIT: </p>
  
  <p>Hooray, it works by changing the attribute onClick of the button!!
  This is the code used: </p>
  
  <p>$('element').attr('some attribute','some attributes value');</p>
  
  <p>Can be closed now, thanks alot guys, appreciate your help!!</p>