1
我想用Greasemonkey自動回答問題。我有問題和答案,但如何選擇它們?如何使用Greasemonkey自動選擇特定的單選按鈕?
這裏的HTML:
<div class="vito_form_q">
<div class="vito_form_title_min_no">
<span id="ContentPlaceHolder1_lblquestionNo">8</span>
</div>
<div class="vito_form_title_min">
<span id="ContentPlaceHolder1_lblquestion">Which sport is not playing with the ball?</span>
</div>
<div class="clearfloat"></div>
<div class="meter orange nostripes"><span style="width: 100%"></span></div>
<div class="quest">
<table id="rbAnswer" class="q1">
<tr><td>
<input id="rbAnswer_0" type="radio" name="ctl00$ContentPlaceHolder1$rbAnswer" value="157"/><label for="rbAnswer_0">Handball</label>
</td></tr>
<tr><td>
<input id="rbAnswer_1" type="radio" name="ctl00$ContentPlaceHolder1$rbAnswer" value="158"/><label for="rbAnswer_1">Basketball</label>
</td></tr>
<tr><td>
<input id="rbAnswer_2" type="radio" name="ctl00$ContentPlaceHolder1$rbAnswer" value="159"/><label for="rbAnswer_2">Football</label>
</td></tr>
<tr><td>
<input id="rbAnswer_3" type="radio" name="ctl00$ContentPlaceHolder1$rbAnswer" value="160"/><label for="rbAnswer_3">Fencing</label>
</td></tr>
例如,對於這樣的問題:
<span id="ContentPlaceHolder1_lblquestion">Which sport is not playing with the ball?</span>
選擇答案:
<td>
<input id="rbAnswer_3" type="radio" name="ctl00$ContentPlaceHolder1$rbAnswer" value="160" />
<label for="rbAnswer_3">Fencing</label>
我該怎麼辦這與Greasemonkey?
你是完美的布魯克·亞當斯。今天我會和我的朋友一起嘗試,因爲它看起來很難。非常感謝你。 – Nikola
嘿兄弟它的工作,但是當我在我的瀏覽器上嘗試它,這是行不通的。我想我沒有什麼問題。你能看看嗎? http://jsfiddle.net/kDThC/感謝:) – Nikola
請參閱http://jsfiddle.net/kDThC/2/。有兩個問題; (1)該頁面使用與此處發佈的問題不同的ID。特別是,'ContentPlaceHolder1_lblSoru'與'ContentPlaceHolder1_lblquestion'。 (2)問題字符串不能有一些Unicode字符。在這種情況下,口音(')。在這種情況下,像我一樣用一段時間('.')替換它。 q值用於構建正則表達式。 –