开发者

Click on a button with long url for name with javascript bookmarklet

开发者 https://www.devze.com 2023-01-17 14:41 出处:网络
I need either a javascript which can click on a button.The thing is, there are 100+ buttons on the page all with the same value.The name is unique but quite long.

I need either a javascript which can click on a button. The thing is, there are 100+ buttons on the page all with the same value. The name is unique but quite long.

The full name of the element is something like :

actions[http://apps.facebook.com/frontierville/giftaccept.php?next=giftaccept.php&senderId=1%3A1325206719&gh=3a8bfdace76051752a9127d1f9b43872&gift=nails&timestamp=1285598414&ref=tab&key=29b15e06ed9d7c00a8870c955ab938cf%24%24cfH1PUUZ%217bZYhg8M-o-XQc%218HHRMcvvyhuf4d%21.64qEvlQe&src=request&aff=gift&crt=nails&signature=6dd3fa03fe88f98b6dcab4faf4c7da94]

The value of every button is Accept and Play.

So. Is there a way to have it click on the button with a specific URL in the name?

I tried this:

javascript:(function(){var b=document.getElementsByName('actions[http://apps.facebook.com/frontierville/gift开发者_StackOverflowaccept.php?next=giftaccept.php&amp;senderId=1%3A1325206719&amp;gh=3a8bfdace76051752a9127d1f9b43872&amp;gift=nails&amp;timestamp=1285598414&amp;ref=tab&amp;key=29b15e06ed9d7c00a8870c955ab938cf%24%24cfH1PUUZ%217bZYhg8M-o-XQc%218HHRMcvvyhuf4d%21.64qEvlQe&amp;src=request&amp;aff=gift&amp;crt=nails&amp;signature=6dd3fa03fe88f98b6dcab4faf4c7da94]');for(var j=0;j<b.length;j++){if(b[j].value.match(/^Accept and Play/i)){b[j].click();break;}}})()

and it did not work. Any suggestions?

EDIT: If it helps, here is the source of the info for one of the buttons:

<input value="Accept and Play" type="submit" name="actions[http://apps.facebook.com/onthefarm/giftaccept.php?senderId=1259413693&amp;gift=mysterygift&amp;timestamp=1285599906&amp;ref=gift_accept_tab&amp;key=78fcc7de3b36b8f9564262fab506893f%24%24ceK5RVRY61bZYhg8M-o-XQcyL%2CzHccEwEeuj4e-%21-dh0AD0A2AgyScd&amp;signature=32db959ce43f8330cf8fd992fbd53a51&amp;srcapp=FarmVille]">


your script works for me.

Are u sure, that you use the exact name in your script?

Are there other elements in the page, that share the same name? If it does: you better also check the type of these elements. If they are not click()-able Elements(for example hidden-Inputs or text-inputs, this will cause an exception, so your loop will be stopped)

0

精彩评论

暂无评论...
验证码 换一张
取 消