开发者

javascript bookmarklet to click Accept on a Facebook Page

I need a javascript bookmarklet that will click the "Yes" button on a facebook page for farmville (or any similar facebook game). The page would say soemthing like "Would you like to accept this gift" and there are three buttons. YEs, Yes and send thank you gift and No. I want to select Yes via javascript.

Information related to the Yes button (pulled from chrome inspector)

<form action="" method="post" style="float: left; text-align: right; width: 30%;" id="app102452128776_form_4c96dd开发者_高级运维63e3ca077b35e0b"><input type="hidden" name="fb_sig_locale" value="en_US" /><input type="hidden" name="fb_sig_in_new_facebook" value="1" /><input type="hidden" name="fb_sig_time" value="1284955491.9298" /><input type="hidden" name="fb_sig_added" value="1" /><input type="hidden" name="fb_sig_profile_update_time" value="1279260928" /><input type="hidden" name="fb_sig_expires" value="1284962400" /><input type="hidden" name="fb_sig_user" value="100001318363956" /><input type="hidden" name="fb_sig_session_key" value="2.Oh1iDQtbxvGYg3vOpKpRVQ__.3600.1284962400-100001318363956" /><input type="hidden" name="fb_sig_ext_perms" value="email,user_birthday,user_location" /><input type="hidden" name="fb_sig_country" value="us" /><input type="hidden" name="fb_sig_api_key" value="80c6ec6628efd9a465dd223190a65bbc" /><input type="hidden" name="fb_sig_app_id" value="102452128776" /><input type="hidden" name="fb_sig" value="366919f0f771b5fb47303abcb5d6055f" /> 
                <input class="inputyessubmit" type="submit" name="acceptReward" value="Yes" /> 
            </form> 


Based on your snippet above, you'd take this

javascript:(function(){ var b; b=document.getElemenstByName('acceptReward'); if(b.length>0) { b[0].click(); } })()

and paste it into the address bar. This assumes the name acceptReward is unique to that element.

edits: try this. fixed a typo and added some additional checking. that's what I get for coding without intellisense.

javascript:(function(){var b=document.getElementsByName('acceptReward');for(var j=0;j<b.length;j++){if(b[j].value.match(/^Yes$/i)){b[j].click();break;}}})()
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜