如何使用 Greasemonkey 自动选择单选按钮?
我想用 Greasemonkey 选择自动单选按钮。但我想选择带有标签名称的收音机。 当我看到这四个单选按钮时,Greasemonkey 需要选择我的选项。 示例:我想要自动选择标签 Instagram。
<label for="ContentPlaceHolder1_answer3">Instagram</label>
如何使用 Greasemonkey 选择此单选按钮?
<div class="row">
<input type="radio" tabindex="3" value="answer1" name="ctl00$ContentPlaceHolder1$1" id="ContentPlaceHolder1_answer1"><label for="ContentPlaceHolder1_answer1">Twitpic</label></div>
<div class="row">
<input type="radio" tabindex="4" value="answer2" name="ctl00$ContentPlaceHolder1$1" id="ContentPlaceHolder1_answer2"><label for="ContentPlaceHolder1_answer2">Yfrog</label></div>
<div class="row">
<input type="radio" tabindex="5" value="answer3" name="ctl00$ContentPlaceHolder1$1" id="ContentPlaceHolder1_answer3"><label for="ContentPlaceHolder1_answer3">Instagram</label></div>
<div class="row">
<input type="radio" tabindex="6" value="answer4" name="ctl00$ContentPlaceHolder1$1" id="ContentPlaceHolder1_answer4"><label for="ContentPlaceHolder1_answer4">Flickr</label></div>
</div>
I want select auto radio button with Greasemonkey. But I want select radio with label name.
When I see that four radio button, Greasemonkey need select my option.
Example: I want auto select label Instagram.
<label for="ContentPlaceHolder1_answer3">Instagram</label>
How can I select this radio button with Greasemonkey?
<div class="row">
<input type="radio" tabindex="3" value="answer1" name="ctl00$ContentPlaceHolder1$1" id="ContentPlaceHolder1_answer1"><label for="ContentPlaceHolder1_answer1">Twitpic</label></div>
<div class="row">
<input type="radio" tabindex="4" value="answer2" name="ctl00$ContentPlaceHolder1$1" id="ContentPlaceHolder1_answer2"><label for="ContentPlaceHolder1_answer2">Yfrog</label></div>
<div class="row">
<input type="radio" tabindex="5" value="answer3" name="ctl00$ContentPlaceHolder1$1" id="ContentPlaceHolder1_answer3"><label for="ContentPlaceHolder1_answer3">Instagram</label></div>
<div class="row">
<input type="radio" tabindex="6" value="answer4" name="ctl00$ContentPlaceHolder1$1" id="ContentPlaceHolder1_answer4"><label for="ContentPlaceHolder1_answer4">Flickr</label></div>
</div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
试试这个:
如果不知道 HTML 是如何组合在一起的,我无法确定这是否有效。您在问题中给出了 HTML,但我不知道它是否保留了该恒定格式。
Try this:
I can't tell for sure if that will work without knowing how the HTML is put together. You gave the HTML in your question, but I don't know if it retains that constant format.
我有一段时间没有使用 xpath,所以它可能不会做任何事情:)
但理论上,这将搜索文本包含“Instagram”的所有标签,然后循环遍历所有结果,将 for 属性设置为获取单选按钮并将其选中为 true。 (虽然我认为它是单选按钮的“选择”?)
I've not used xpath in a while, so it might not do anything :)
But in theory, this will search for all labels where the text constains "Instagram", and then it loops through all the results, taking the for attribute to get the radio button and sets it's checked to true. (although i think its "selected" for radio buttons?)