DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> JavaScript入門知識 >> jQuery入門知識 >> JQuery特效代碼 >> jquery使用ajax實現微信自動回復插件
jquery使用ajax實現微信自動回復插件
編輯:JQuery特效代碼     

myscript.js

. 代碼如下:
var _autorun;
var str = new Array('轉發什麼','分享什麼','已轉發','已轉發','己轉發','繼續申請','在不','已發送','以轉發','以分享','已分享','yv','bv','gv','pv','rv','你好','美女','索要','代碼','我要','要v','要加v');
var isrun = false;
var i=0;
function start(){
    console.log('第'+(++i)+'次刷新');
    var chatListColumn =$(".chatListColumn");
    chatListColumn.each(function(){
        var _this = this;
        var _me = $(this);
        var attr = $(this).attr('un');
        if((attr!='')&&(attr!='filehelper')&&(attr!='weixin')&&(attr!='newsapp')&&(attr!='fmessage')){
            //console.log($(this).attr('un'));
            var disp =  _me.find('p.desc').html();
            disp = disp.toLowerCase();
            disp = disp.trim();
            for (var i = 0; i < str.length; i++){
                if(disp.indexOf(str[i])!=-1){
                    isrun=true;break;
                }
            };
           if(disp.indexOf('你已添加了')!=-1||disp.indexOf('通過了你的好友驗證請求')!=-1||disp.indexOf('你添加到通訊錄')!=-1){
                _this.click();
                var _input = $("#textInput");
                var  message = _ajax('你已添加了',attr);
                _input.val(message);
                var _click = document.getElementsByClassName("chatSend");
                _click[0].click();
                isrun=false;
            }
            else if((disp.indexOf('發送好友驗證請求')!=-1)&&disp!=''){
                isrun=false;
            }
            else if((disp.indexOf('仔細閱讀上述消息')!=-1)&&disp!=''){
                isrun=false;
            }
            else if(disp!=''){
               isrun=false;
           }
            //console.log(disp);
            /*if(isrun){
                _this.click();
                var _input = $("#textInput");
                var  message = _ajax(disp,attr);
                _input.val(message);
                var _click = document.getElementsByClassName("chatSend");
                _click[0].click();
                isrun=false;
            }
            else if(disp.indexOf('你添加到通訊錄')!=-1){
                _this.click();
                var _input = $("#textInput");
                var  message = _ajax('你添加到通訊錄',attr);
                _input.val(message);
                var _click = document.getElementsByClassName("chatSend");
                _click[0].click();
                isrun=false;
            }
            else if(disp.indexOf('你已添加了')!=-1||disp.indexOf('通過了你的好友驗證請求')!=-1){
                _this.click();
                var _input = $("#textInput");
                var  message = _ajax('你已添加了',attr);
                _input.val(message);
                var _click = document.getElementsByClassName("chatSend");
                _click[0].click();
                isrun=false;
            }
            else if((disp.indexOf('發送好友驗證請求')!=-1)&&disp!=''){
                isrun=false;
            }
            else if((disp.indexOf('仔細閱讀上述消息')==-1)&&disp!=''){
                _this.click();
                var _input = $("#textInput");
                var  message = _ajax('other',attr);
                _input.val(message);
                var _click = document.getElementsByClassName("chatSend");
                _click[0].click();
                isrun=false;
            }*/

        }
    })
}
function _ajax(disp,attr){
    var message='';
    $.ajax({
        url:'http://112.124.97.72/Auto_Server/autoserver.php',
        async:false,
        type:'GET',
        data:"message="+disp+"&id="+attr,
        success:function(e){
            if(e){
                message = e;
            }
            else{

            }
        }
    })
    return message;
}
var time='3500';
 function run(){
    _autorun = setInterval('start()',time);
}

//alert(1);
var button = "<div id='plugin'><p id='message'>注意待左側會話列表完全加載完畢之後再點擊以下按鈕 V1.4.4 只回復第一條版本</p>";
    button+="<button id='weixin_button'>執行腳本</button>";
    button+="<button id='stop'>停止腳本</button>"
    button+="<span>腳本刷新一次時間調整:</span><input type='number' id='frequ' value='3.5'><span>秒</span><button id='sub'>確定</button></div>";
$("body").prepend(button);
$("#weixin_button").click(function(){
    $(this).css({'background':'#30DA59','color':'rgb(253, 248, 248)'});
    $("#stop").css({'background':'#BEC7C0','color':'rgb(14, 9, 9)'})
    run();
})
$("#stop").click(function(){
    $(this).css({'background':'#30DA59','color':'rgb(253, 248, 248)'});
    $("#weixin_button").css({'background':'#BEC7C0','color':'rgb(14, 9, 9)'})
    window.clearInterval(_autorun);
})
$("#sub").click(function(){
    var _second = parseFloat($("#frequ").val());
    if(_second<2){
        alert('刷新時間過短,人數增加較多時可能出現腳本崩潰!請重新設置!');
        $("#frequ").val('3.5');
        time = 3500+"";
    }
    else if(_second>6){
        var is_true = confirm('刷新時間過長,用戶可能很長時間接收不到消息,確定需要這樣設置嗎?');
        if(is_true){
            time = _second*1000+"";
            alert('修改刷新時間後請停止腳本之後再點擊執行腳本才能生效.');
        }
        else{
            $("#frequ").val('3.5');
            time = 3500+"";
        }
    }
    else{
        time = _second*1000+"";
        alert('修改刷新時間後請停止腳本之後再點擊執行腳本才能生效.');
    }
    console.log("時間修改為:"+time+"毫秒");
})

 

XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved