tags:

views:

20

answers:

1

Can someone tell me what I am doing wrong here...

This returns "Button Not Found"

javascript:var nam="http://apps.facebook.com/onthefarm/giftaccept.php?senderId=547766125&gift=haitibackpack_item_single&timestamp=1285776944&ref=gift_accept_tab&key=6870697de39960508737349c7a3f1363%24%24ggM3T%2CPU2YKM2l0mNrM%28U%28b%21eHAoclFCBgwg49%21S34GWkEXxTekFN_Fkx5%2AUZPcNMEOj&signature=a86a9e11aab0051e3fde676a9abe4283&srcapp=FarmVille"; nam="actions["+nam.replace(/\&/g, "&")+"]"; var els=document.getElementsByName(nam); if(els.length == 0) alert("Button not found"); else els[0].click();

This prompts me to enter a URL...I enter the EXACT same URL as in the above example and it works fine, clicks the button which brings me to the desired page.

javascript:var nam=prompt('enter URL Please'); nam="actions["+nam.replace(/\&/g, "&")+"]"; var els=document.getElementsByName(nam); if(els.length == 0) alert("Button not found"); else els[0].click();

Thanks

Before you ask...I've tried in Chrome, IE and Firefox. It does not appear to be an issue with the length of the JS. I get the same results as above regardless of which (valid) URL I use. I am getting desperate here.

A: 

Well, it looks like you're trying to get a specific value within a page. It also looks that this value (nam) is likely regenerated since it contains a timestamp and other properties that seem session based.

I'm of the opinion that your code works perfectly. Its the value that changes, so no match is ever found.

To be sure, we'd have to see the markup... and verify it was not changing

michael
it is not changing. The time stamp is based on the time the item was "sent". I can run the piece of code that does not work, have it fail, then run the one that does work and it will work just fine, or vice versa. I can reload the page and it will remain the same. I will, however, provide the source of the page: http://privatepaste.com/11f27d4328 Note that this is just an example section which includes a similar item as my above example but not the same one so the URL in this source is different than the one above. If you need anything else please let me know.
Seatbelt99
Not sure if it matters but I've also tried to split it up by making one bookmarklet which is just setting the variable "nam", then the next one formatting it and looking for the element. That did not work. BUt, if I do javascript:var nam=prompt('enter url'); alone, then after filling out the url and hitting enter, doing a separate javascript for the rest, that works to . Its something to do with the prompt that makes it work. Just no idea what.
Seatbelt99