【问题标题】:I want to remove captcha automatically from a web page我想从网页中自动删除验证码
【发布时间】:2016-11-04 19:23:02
【问题描述】:

我想自动删除捕获。使用 java 脚本(Greasemonkey)从页面中删除页面 HTML 所以给我一些想法,我怎样才能删除它,它将能够工作 `

    <div class="wrapper">
        <div class="pageHeader"></div> 
        <div class="pageHeading1 text_center">
            Appointment Login
            <a href="index.html"><img src="./images/home.png" style=" width: 30px; height:26px;" align="right"></a>
        </div>
        <div class="container">
            <div class="form_container">   
                <form method="post" autocomplete="off" action="Get_Appointment" onsubmit="return validate_appointmentLogin_form();">  
                    <div class="row text_center" id="generate_otp_msg" style="font-weight:bold;font-size: 14px;padding-bottom: 10px;color:#BF0D0D">

                    </div>
                    <div class="row">
                        <div class="col-31"></div>
                        <div class="col-32">
                            <input name="otp_required" value="generate_otp" id="generate_otp" onclick="otpmgt()" type="radio"> I want to Generate OTP
                            <br>
                            <input name="otp_required" value="have_otp" id="have_otp" onclick="otpmgt()" type="radio">I have received OTP 

                            <br><input name="otp_required" value="send_alotment_sms" id="send_alotment_sms" onclick="otpmgt()" type="radio"> Re-send Appointment Confirmation SMS.</div>
                        <div class="col-33"></div> 
                    </div>

                    <div class="row"> 
                        <div class="col-31 mandatory">Application Id</div>
                        <div class="col-32"><input style="margin-right: 0px; padding-right: 0px;" name="filerfno" id="application_id" size="50" maxlength="12" title="Please Enter your Application Id" value="" type="text"><img title="Max field length is 12" style="position: relative; left: 0px; top: 0px; z-index: 999; cursor: pointer; vertical-align: bottom; border: 0px none; width: 14px; height: 19px; display: inline;" class="ife_marker" src="chrome://informenter/skin/marker.png" id="filerfno_ife_marker_0"></div>
                        <div class="col-33">Please enter application id</div> 
                    </div>
                    <div class="row"> 
                        <div class="col-31 mandatory">Passport Number</div>
                        <div class="col-32"><input style="margin-right: 0px; padding-right: 0px;" name="passport_no" id="passport_no" size="50" maxlength="14" title="Please Enter your Passport No. As in Passport" value="" type="text"><img title="Max field length is 14" style="position: relative; left: 0px; top: 0px; z-index: 999; cursor: pointer; vertical-align: bottom; border: 0px none; width: 14px; height: 19px; display: inline;" class="ife_marker" src="chrome://informenter/skin/marker.png" id="passport_no_ife_marker_1"></div>
                        <div class="col-33">Please enter passport no</div> 
                    </div>
                    <div class="row"> 
                        <div class="col-31 mandatory"> <img src="DisplayDynamicField1"></div>
                        <div class="col-32"><input style="margin-right: 0px; padding-right: 0px;" name="619058" class="textBoxDashed app_field" size="20" maxlength="50" onkeyup="chkString(this)" onblur="trim1(this);" type="text"><img title="Max field length is 50" style="position: relative; left: 0px; top: 0px; z-index: 999; cursor: pointer; vertical-align: bottom; border: 0px none; width: 14px; height: 19px; display: inline;" class="ife_marker" src="chrome://informenter/skin/marker.png" id="619058_ife_marker_2"></div>
                        <div class="col-33"></div> 
                    </div>
                    <div class="row"> 
                        <div class="col-31 mandatory"> <img src="DisplayDynamicField2"></div>
                        <div class="col-32"><input style="margin-right: 0px; padding-right: 0px;" name="920321" class="textBoxDashed app_field" size="20" maxlength="50" onkeyup="chkString(this)" onblur="trim1(this);" type="text"><img title="Max field length is 50" style="position: relative; left: 0px; top: 0px; z-index: 999; cursor: pointer; vertical-align: bottom; border: 0px none; width: 14px; height: 19px; display: inline;" class="ife_marker" src="chrome://informenter/skin/marker.png" id="920321_ife_marker_3"></div>
                        <div class="col-33"></div> 
                    </div>
                    <div class="row cotp" style="display:none"> 
                        <div class="col-31 mandatory ">OTP</div>
                        <div class="col-32"><input name="otp" id="otp" size="50" maxlength="6" value="" type="password"></div>
                        <div class="col-33"></div> 
                    </div>
                    <div class="row">
                        <div class="col-1" id="label1">Question</div>
                            <div class="col-2"> <img src="captcha?rand=1478286830624" id="capt" onload="image_loaded();" style="display: inline">
                            </div>
                            <div class="col-3"><a href="#" onclick="return refreshCaptcha();" style="vertical-align: baseline"><img src="images/refresh.png" style="width:30px;height:30px;display: inline"></a></div>
                        </div>

                        <div class="row">
                                <div class="col-1 mandatory" id="label2">Answer</div>
                            <div class="col-2"><input style="margin-right: 0px; padding-right: 0px;" name="captcha" id="captcha" maxlength="20" type="text"><img title="Max field length is 20" style="position: relative; left: 261px; top: -15px; z-index: 999; cursor: pointer; vertical-align: bottom; border: 0px none; width: 14px; height: 19px; display: inline;" class="ife_marker" src="chrome://informenter/skin/marker.png" id="captcha_ife_marker_4"></div>
                                <div class="col-3 errorify" style="list-style-type: none">  <ul class="errorMessage">
        <li><span>Invalid Captcha</span></li>   </ul>


-->

                    </div><br><br>
                    <div style="text-align: center;font-weight: bold;color:#C61919" id="error_msg">

                    </div>
                    <input name="token" value="7ee843c6-3897-4db9-99fa-3136ef35b480" type="hidden">

                </form>
            </div>
            <br><br>
            <b>Instructions for Appointment</b>
            <ul class="instructions_ul text_bold">
                <li>Applicants for tourist visa need an appointment date to submit their applications at IVACs</li>
                <li> A one-time password (OTP) will be sent to mobile phone of the applicant which is required for securing the appointment date.</li>
                <li>Applicants should fill in their details carefully and provide the correct mobile number.</li>
                <li>The appointment will be sent as an SMS on the mobile phone of the applicant. This SMS should be shown by the applicant at the IVAC Center to enter and deposit the application</li>
                <li>OTP can be generated only after the appointment time starts. </li>
                <li>Appointment can be booked only after logging in using OTP. </li>
                <li>OTP is valid for 20 minutes.</li>
                <li>Maximum 3 OTPs can be generated on a given day for a File Number.</li>
            </ul>    
        </div>
    </div>     

<script>
    function generate_otp(filerfno_var,passport_no_var) {
        $('#error_msg').html('');
        var value1_var=document.getElementsByClassName("app_field")[0].value;
        var value2_var=document.getElementsByClassName("app_field")[1].value;

        if(document.getElementById('generate_otp').checked == true)
            var otp_required_var="generate_otp";
        else if(document.getElementById('have_otp').checked == true)
            var otp_required_var="have_otp";
        else if(document.getElementById('send_alotment_sms').checked == true)
            var otp_required_var="send_alotment_sms";

        var otp_var=document.getElementById("otp").value;
        var captcha_var=document.getElementById("captcha").value;

        //http://localhost:8084/struts_bgd/json/GenerateOtp?filerfno=BGDDV0004116&passport_no=PASS123&value1=TEST&value2=TEST

        $.ajax({
            type: "POST",
            url: "json/GenerateOtp",
            dataType: "json",
            data: {filerfno : filerfno_var,passport_number:passport_no_var,value1:value1_var,value2:value2_var,otp_required:otp_required_var,otp:otp_var,captcha:captcha_var},
            success: function (data) {
                //alert(data['sms_output']);                    
                alert(data);
                $('#generate_otp_msg').text(data);
                refreshCaptcha();
                $('#captcha').val('');
                $('#have_otp').prop('checked', false);  
                $('#generate_otp').prop('checked', false);  
                $('#send_alotment_sms').prop('checked', false);  

            }
        })
        .done(function (data) {

        })
        .fail(function () {
            alert("Some problem occurred");
        })
        .always(function () {
        });
    }



    var refreshIntervalId;
    function startTimer(duration, display) {
        var timer = duration, minutes, seconds;
        refreshIntervalId =  setInterval(function () {
            minutes = parseInt(timer / 60, 10)
            seconds = parseInt(timer % 60, 10);
            minutes = minutes < 10 ?  minutes : minutes;
            seconds = seconds < 10 ?  seconds : seconds;
            // display.text(minutes + ":" + seconds);
            display.text(seconds);
            $('#timer_msg').html('You can submit request after '+seconds+' seconds');
            if (--timer < 0) {
                $('#timer_msg').html('<input name="submit_btn" id="btn1" type="submit" class="btn btn-primary"  value="Submit">');                    
                return;
            }
        }, 1000);
    }

    function otpmgt() {
        var otp_check = null;
        $('#error_msg').html('');
        if (document.getElementById('have_otp').checked == true)
        {
            otp_check = document.getElementById('have_otp').value;      
            $('.cotp').css('display', '');
            $('#otp').prop('disabled', false);
            //call timer function
            $('#timer_msg').html('');
            startTimer(45, $('#btn_time'));       
            document.getElementById("otp").disabled = false;
        }
        else if (document.getElementById('generate_otp').checked == true)
        {   //submit request through ajax
            clearInterval(refreshIntervalId);
            alert("OTP will be sent to your registered mobile number.");
            otp_check = document.getElementById('generate_otp').value;
            $('.cotp').css('display', 'none');
            $('#otp').val('');
            $('#otp').prop('disabled', true);
            $('.cappt_mobile').css('display', '');        
            $('#btn1').val('Generate OTP');

            document.getElementById("otp").disabled = true;
            //display submit button now            
            $('#timer_msg').html('<input name="submit_btn" id="btn1" type="submit" class="btn btn-primary"  value="Generate OTP" >');

        } else if (document.getElementById('send_alotment_sms').checked == true)
        {
            clearInterval(refreshIntervalId);
            otp_check = document.getElementById('send_alotment_sms').value;
            $('.cotp').css('display', 'none');
            $('#otp').val('');
            $('#otp').prop('disabled', true);
            $('.cappt_mobile').css('display', 'none');       
            document.getElementById("otp").disabled = true;
            $('#timer_msg').html('<input name="submit_btn" id="btn1" type="submit" class="btn btn-primary"  value="Send Allotment SMS" >');
        }  

    }

    function validate_appointmentLogin_form() {
        var f1 = document.getElementsByClassName('app_field')[0].value;
        var f2 = document.getElementsByClassName('app_field')[1].value;  

        var otp_value = document.getElementById("otp").value;
        var otp_length = otp_value.length;
        var otp_required_val = "";
        var otp_required_check = ($('input[type=radio]:checked').size() > 0);// false    
        var submit = true;
        var result = "";

        if (document.getElementById('application_id') != undefined) {
            result = validate_filenumber($('#application_id').val(), 1);
            if (result != "true")
            {
                errorify($('#application_id'), result);
                submit = false;
            }
            else
            {
                correctify($('#application_id'), "Please enter application id");
            }
        }
        if (document.getElementById('passport_no') != undefined) {
            result = validate_passportNo($('#passport_no').val(), 1);
            if (result != "true")
            {
                errorify($('#passport_no'), result);
                submit = false;
            }
            else
            {
                correctify($('#passport_no'), "");
            }
        }
        //if(f1 == null || f1.value == "" || isEmpty(f1)||f1.length==0)
        if (f1 == "" || f1.length == 0)
        {
            result = validate_passportNo(f1, 1);
            errorify($(document.getElementsByClassName('app_field')[0]), "Please enter all mandatory details");
            submit = false;
        } else 
        {
            correctify($(document.getElementsByClassName('app_field')[0]), "");
        }
        if (f2 == "" || f2.length == 0)
        {
            //alert("Please Enter All mandtory fields"+document.getElementsByClassName('app_field')[1]);
            errorify($(document.getElementsByClassName('app_field')[1]), "Please enter all mandatory details");
            submit = false;
        }
        else 
        {
            correctify($(document.getElementsByClassName('app_field')[1]), "");
        }
        if (otp_required_check)
        {
            correctify($('#have_otp'), "");
            if (document.getElementById('have_otp').checked == true && otp_value.length == 0) {
                errorify($('#otp'), "Please enter otp");
                submit = false;
                //  alert("Have OTP and Length= 0. Submit = " + submit);
            }
            else
            {
                correctify($('#otp'), "");
            }
            if (document.getElementById('have_otp').checked == true && otp_value.length < 6) {
                errorify($('#otp'), "Please enter correct otp");
                submit = false;
                // alert("Have OTP and Length< 6. Submit = " + submit);
            }
            else 
            {
                correctify($('#otp'), "");
            }          


        }
        else
        {
            errorify($('#have_otp'), "Please select at least one option.");
            submit = false;
        }
        if (document.getElementById('captcha') != undefined) {
            result = validate_captcha($('#captcha').val(), 1);

            if (result != "true")
            {
                errorify($('#captcha'), result);
                submit = false;
            }
            else
            {
                correctify_lowercase($('#captcha'), "");
            }
        }

        //if generate otp is clicked then submit function by ajax else submit to action    
        if(document.getElementById('generate_otp').checked == true && submit == true){
            //call ajax function to generate otp    
            //disable submit button here


            generate_otp($('#application_id').val(),$('#passport_no').val());

            submit=false;
        }


        return submit;
    }

</script>

` please see imag marking blow

【问题讨论】:

  • 这不是代码编写服务。到目前为止你尝试了什么?发布您的代码!运行时发生了什么?你期望会发生什么?你具体有什么问题? stackoverflow.com/help/mcve

标签: javascript java html ajax


【解决方案1】:

如果你只想删除 div,你可以使用类似的东西:

document.getElementsByClassName('row')[4].remove();

这将从页面中删除第 5 次出现的类“行”。这通常不会让您绕过验证码,但类似的代码会删除它。

【讨论】:

    猜你喜欢
    • 2017-01-27
    • 2012-01-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-11
    相关资源
    最近更新 更多