单击带有长 url 的按钮以获取带有 javascript 书签的名称

发布于 2024-09-24 18:56:06 字数 1735 浏览 3 评论 0原文

我需要一个可以点击按钮的javascript。问题是,页面上有 100 多个按钮,它们的值都相同。这个名字很独特,但很长。
该元素的全名类似于:

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]

每个按钮的值都是 Accept 和 Play。

所以。有没有办法让它点击名称中带有特定 URL 的按钮?

我尝试了这个:

javascript:(function(){var b=document.getElementsByName('actions[http://apps.facebook.com/frontierville/giftaccept.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;}}})()

但没有成功。有什么建议吗?

编辑: 如果有帮助,这里是其中一个按钮的信息来源:

<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]">

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/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]');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&gift=mysterygift&timestamp=1285599906&ref=gift_accept_tab&key=78fcc7de3b36b8f9564262fab506893f%24%24ceK5RVRY61bZYhg8M-o-XQcyL%2CzHccEwEeuj4e-%21-dh0AD0A2AgyScd&signature=32db959ce43f8330cf8fd992fbd53a51&srcapp=FarmVille]">

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

静水深流 2024-10-01 18:56:06

你的剧本对我有用。

您确定在脚本中使用了确切的名称吗?

页面中是否还有其他具有相同名称的元素?
如果是:您最好还检查这些元素的类型。如果它们不是 click()-able 元素(例如隐藏输入或文本输入,这将导致异常,因此您的循环将停止)

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)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文