简体   繁体   English

javascript小书签以在Facebook页面上单击“接受”

[英]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). 我需要一个JavaScript书签,它将在Farmville(或任何类似的Facebook游戏)的Facebook页面上单击“是”按钮。 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. 是的,是的,并发送谢谢礼物和否。我想通过JavaScript选择是。

Information related to the Yes button (pulled from chrome inspector) 与“是”按钮相关的信息(从Chrome检查器中提取)

<form action="" method="post" style="float: left; text-align: right; width: 30%;" id="app102452128776_form_4c96dd63e3ca077b35e0b"><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. 假定名称acceptReward是该元素唯一的名称。

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;}}})()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM