Jquery uses ajax to implement the WeChat automatic reply plug-in _ jquery

Source: Internet
Author: User
Tags stop script
This article mainly introduces jquery's use of ajax to implement automatic reply plug-ins. For more information, see myscript. js.

The Code is as follows:


Var _ autorun;
Var str = new Array ('forwarded by', 'shared by', 'forwarded by ', 'applied ', 'Do not ', 'sent', 'forward ', 'share', 'shared ', 'yv', 'bv', 'gv ', 'pv', 'rv ', 'hao', 'beauty', 'request', 'code', ''I want ', 'want V ', 'Add V ');
Var isrun = false;
Var I = 0;
Function start (){
Console. log ('sub' + (++ I) + 'refresh ');
Var chatListColumn = $ (". chatListColumn ");
ChatListColumn. each (function (){
Var _ this = this;
Var _ me = $ (this );
Var attr = $ (this). attr ('non ');
If (attr! = '') & (Attr! = 'Filehelper ') & (attr! = 'Weixin') & (attr! = 'Newsapp') & (attr! = 'Fmessage ')){
// Console. log ($ (this). attr ('non '));
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 ('you have already add ')! =-1 | disp. indexOf ('Your friend verification request ')! =-1 | disp. indexOf ('add to address book ')! =-1 ){
_ This. click ();
Var _ input = $ ("# textInput ");
Var message = _ ajax ('you have already add', attr );
_ Input. val (message );
Var _ click = document. getElementsByClassName ("chatSend ");
_ Click [0]. click ();
Isrun = false;
}
Else if (disp. indexOf ('send friend verification request ')! =-1) & disp! = ''){
Isrun = false;
}
Else if (disp. indexOf ('read the above message carefully ')! =-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 ('add to address book ')! =-1 ){
_ This. click ();
Var _ input = $ ("# textInput ");
Var message = _ ajax ('add to address book ', attr );
_ Input. val (message );
Var _ click = document. getElementsByClassName ("chatSend ");
_ Click [0]. click ();
Isrun = false;
}
Else if (disp. indexOf ('you added ')! =-1 | disp. indexOf ('Your friend verification request ')! =-1 ){
_ This. click ();
Var _ input = $ ("# textInput ");
Var message = _ ajax ('you have already add', attr );
_ Input. val (message );
Var _ click = document. getElementsByClassName ("chatSend ");
_ Click [0]. click ();
Isrun = false;
}
Else if (disp. indexOf ('send friend verification request ')! =-1) & disp! = ''){
Isrun = false;
}
Else if (disp. indexOf ('read the above message carefully ') =-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 = '20140901 ';
Function run (){
_ Autorun = setInterval ('start () ', time );
}

// Alert (1 );
Var button ="

Note: After the left-side session List is fully loaded, click the following button V1.4.4 to reply to the first version.

";
Button + =" Execute scripts";
Button + =" Stop script"
Button + = "script refresh time adjustment: Seconds OK

";
$ ("Body"). prepend (button );
$ ("# Weixin_button"). click (function (){
Certificate (this).css ({'background ':' # 30da59', 'color': 'rgb (253,248,248 )'});
$ ("# Stop" ).css ({'background': '# BEC7C0', 'color': 'rgb (14, 9, 9 )'})
Run ();
})
$ ("# Stop"). click (function (){
Certificate (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 ('the refresh time is too short. Script crashes may occur when a large number of people increase! Set it again! ');
$ ("# Frequ"). val ('3. 5 ');
Time = 3500 + "";
}
Else if (_ second> 6 ){
Var is_true = confirm ('the refresh time is too long, and the user may not receive the message for a long time. Are you sure you want to set it like this? ');
If (is_true ){
Time = _ secondd * 1000 + "";
Alert ('Stop the script after modifying the refresh time and then click execute the script to take effect .');
}
Else {
$ ("# Frequ"). val ('3. 5 ');
Time = 3500 + "";
}
}
Else {
Time = _ secondd * 1000 + "";
Alert ('Stop the script after modifying the refresh time and then click execute the script to take effect .');
}
Console. log ("Change time to:" + time + "millisecond ");
})

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.