dimanche 23 mars 2014

Making a working Chrome Extension with jQuery code


Vote count:

0




this is my first post and I have searched stackoverflow for any potential solutions to no avail, as the answers are more geared towards more advanced coders, and secondly this is quite a niche area. My problem is: I'm trying to make a script that automates a checkout process on a website. Here is my raw code:



document.getElementById("size").selectedIndex = 1;
document.getElementsByName('commit')[0].click();
window.location.href = "http://ift.tt/1f7qu7V";
document.getElementById('order_billing_name').value="Joe Bloggs";
document.getElementById('order_email').value="jbloggs@hotmail.com";
document.getElementById('order_billing_address').value="99 High Street";
document.getElementById('order_billing_address_2').value="Blah";
document.getElementById('order_billing_city').value="Blah";
document.getElementById('order_billing_zip').value="Blah";
document.getElementById('order_billing_country').value="GB";


The first two lines of code choose an item specific (size) from a dropdown menu and simulate a click on the 'add to cart' button on the webpage (button name = commit). The third line redirects to the checkout page and the rest 'auto-fills' my details. A problem I'm having is if I run the first two lines of code, then the redirect, then the 'auto-fill' as three separate bookmarklets in Chrome (after running the above code through here) it works perfectly, but if I try to put all the code into one bookmarklet it doesn't run! I think this is something to do with it running in context with the active page but I'm not sure. Can someone help me to fix this issue so I can put all the code into one bookmarklet?


Thanks!


Also sorry if one's English isn't exquisite but it's not my main language so please ask if any further clarification is required.



asked 43 secs ago






Aucun commentaire:

Enregistrer un commentaire