Paste: baidu tieba sign

Author: test by cat
Mode: javascript
Date: Fri, 31 May 2013 17:00:45
Plain Text |
var BaseUrl="";
var baObjs = new Array;//存贴吧
var localUrl = window.location.href;

if(cutchar(localUrl,"http://",".com")=="wapp.baidu"){
	var bai;
	var ajax=Ajax();
	var pageStr;
	var baCH = new Array;//存贴吧名字
	var baEN = new Array;//存贴吧地址
	show_BaseDiv();
	mark_cell();
}
if(cutchar(localUrl,"http://",".com")=="tieba.baidu"){$("#Sign_MainDiv").innerHTML+= "电脑签到<br/>";
	show_BaseDiv();
	document.getElementById("myli5").innerHTML="<a href='http://wapp.baidu.com/mo/m?tn=bdFBW&tab=favorite'  target='_blank'>进入WAPP</a>";//wapp贴吧页面的链接
	mark_fav();
}



function show_BaseDiv(){
	//以下基本样式
	document.body.innerHTML+=
	"<style>"+
		"html,body,div,p,ul,ol,li,dl,dt,dd,h1,h2,h3,h4,h5,h6,object,iframe,form,blockquote,fieldset,input,textarea,code,address,caption,cite,code,em,i,ins{margin:0;padding:0;}"+
		".Sign_Body{text-align:left;font-family:微软雅黑;}"+/*所有的自定义层都建在这里面*/
		".Sign_Body a, .Sign_Body a:link, .Sign_Body a:visited{color: #d79a1e; text-decoration: none; } .Sign_Body a:hover{color: blue; text-decoration: none;}"+/*所有的自定义的链接*/
		
		".Sign_BarTop{ display: block; position:absolute; position: fixed; width:100%; height:35px; top:0px; left:0px; padding-left:50px; padding-top:4px;  border-bottom: 1px solid red; background-color:black; color:white; z-index:111110; font-size:20px;}"+/* 顶部操作栏*/
		".Sign_BarTop span{ padding:0px;margin:0px;float:left;cursor: pointer;}.Sign_BtnTop{width:164px;height:30px;padding:8px 0px;}"+/*顶部栏中的按钮*/
		".Sign_BackDiv{	display: block; position:absolute; position:fixed; top:0; padding:0px;  margin:0px; width:100%; height:100%; background-color:black; z-index:110000; -moz-opacity: 0.8; opacity:.90; filter: alpha(opacity=80);}"+/*透明背景*/
		".Sign_MainDiv{ display: block; position: absolute; top: 42px; left: 30px; width: 800px; padding-top: 16px; padding-left: 16px; margin-bottom: 16px; border: 2px solid orange; background-color: white; z-index:111000;  word-wrap:break-word; -moz-opacity: 0.8; opacity:.80; filter: alpha(opacity=80);}"+/*主要显示部分*/
		".Sign_NoticeDiv{ display: block; position: absolute; position: fixed; top: 42px; right: 50px; width: 400px; height: 100%; padding-top: 16px; padding-left: 10px; z-index:111100; color:white; word-wrap:break-word; -moz-opacity: 0.9; opacity:.90; filter: alpha(opacity=90);background-color:#444444;}"+/*辅助显示部分*/
		".Sign_MainDiv li,.Sign_NoticeDiv li{ margin-left:-35px;}"+/*列举条例*/ 
		"#myli5{text-align:right;}"+
		/*以下是class*/
		".pr{color:red;} .pg{color:green;} .pb{color:blue;} .py{color:yellow;}"+/*彩色字*/
		".pt10{font-size:10pt;} .pt15{font-size:15pt;} .pt20{font-size:20pt;} .pt25{font-size:25px;} .pt50{font-size:50pt;} .pt60{font-size:60pt;} .pt70{font-size:70pt;} .pt80{font-size:80pt;} .pt90{font-size:90pt;} .pt100{font-size:100pt;} .pt120{font-size:120pt;} .pt150{font-size:150pt;} .pt200{font-size:200pt;} .pt500{font-size:500pt;}"+/*大小字*/
	"</style>";


	//以下构建了基本的页面显示框架
	document.body.innerHTML+="<div class='Sign_Body' id='Sign_Body'></div>";//我的根元素
	document.getElementById("Sign_Body").innerHTML="<div class='Sign_BarTop' id='Sign_BarTop'></div>"+//顶部工具栏
		"<div class='Sign_BackDiv' id='Sign_BackDiv'></div>"+//大背景
		"<div class='Sign_MainDiv' id='Sign_MainDiv'></div>"+//主体显示
		"<div class='Sign_NoticeDiv' id='Sign_NoticeDiv'>11</div>";//公告显示
		
	document.getElementById("Sign_BarTop").innerHTML="<div>"+//顶部栏
		"<span><div class='Sign_BtnTop' id='myli1'></div></span>"+//显示总贴吧数量
		"<span><div class='Sign_BtnTop' id='myli2'></div></span>"+//显示正在进行到第几个
		"<span><div class='Sign_BtnTop' id='myli3'></div></span>"+//完成标志
		"<span><div class='Sign_BtnTop' id='myli5'></div></span>"+//转到手机版的链接
		"<span><div class='Sign_BtnTop' id='close_btn' align='right'><a href='javascript:void 0;' onclick='div_allHid();'>关闭</a></div></span>"+//显示关闭按钮
	"</div>";
	document.getElementById("Sign_Body").innerHTML+="<img class='markPic1' style='position:absolute; position:fixed;top:0px;right:-10px;z-index:111111;' src='http://imgsrc.baidu.com/forum/pic/item/d2a29e315c6034a8bc82c368cb1349540823767a.jpg' />"+//箭头
	"<a href=\"javascript:void((function(){var e=document.createElement('script');e.type='text/javascript';e.charset='UTF-8';e.src='http://chanxi.googlecode.com/files/sign.js'+'?m='+Math.random();document.body.appendChild(e)})());\" class='markPic2' style='position:absolute;position:fixed;top:180px;right:-170px;z-index:111112;width:230px;height:70;cursor:move;background:url(http://imgsrc.baidu.com/forum/pic/item/dc8d124e251f95ca2f8ce95fc9177f3e66095261.jpg) no-repeat;'><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>一键签到</a>";//按钮标签
	
	//$(".markPic2").hover(function(){$(".markPic2").animate({right: "-20px"}, 400 );},function(){$(".markPic2").animate({right: "-170px"}, 400 );});//添加事件
	document.getElementById("myli1").innerHTML="还未收集。。。";
	document.getElementById("myli2").innerHTML="0 / 未知";
	document.getElementById("myli3").innerHTML="";
	document.getElementById("Sign_NoticeDiv").innerHTML="请自行检查有没有签到正确,如有错误,欢迎反馈:<br/>"+
		"<span class='pt15'><a href='http://tieba.baidu.com/p/1768731534'  target='_blank'>蝉曦吧反馈专用贴</a></span><br/>"+
	"服务器随时可能不可用,故关注更新帖,保证可以及时更新书签:<br/>"+
		"<span class='pt15'><a href='http://tieba.baidu.com/p/2110672062?see_lz=1'  target='_blank'>蝉曦吧地址更新专用帖</a></span><br/>"+
	// "<span style='color:red;'>代码修改中,期间使用本签到可能出现故障,请稍候再用</span><br/>"+
		"请注意:请在自动签到的时候,放慢你的发帖和回复速度,防止应为操作过频被度受和谐ID。<br/>"+
		"------2013.04.03 v1.2.2------<br/>"+		
		"更新1.修复由于i贴吧部分页面下线导致的贴吧收集障碍<br/>"+
		"更新2.修复手机签到改UA后出现\"更佳小说吧阅读体验\"导致签到失败<br/>"+
		"提示1.模拟手机签到可在普通版或极简版运行<br/>"+
		"<span style='color:green;'>------------------------------</span><br/>"+
		"ios(越狱)和android版签到工具,请前往<a href='http://tieba.baidu.com/p/2047715431?see_lz=1' target='_blank'>手机签到工具</a>支持并提供宝贵意见,本工具相对别的签到工具的优点是:省流量;100个贴吧的签到约为300KB的流量左右<br/>"+
		"<span style='color:red;'>------------------------------</span><br/>"+
		"注意1.更改UA后使用模拟手机签到,如需进入极简版须清除cookie<br/>"+
		"注意2.IE8用户如需模拟手机签到,须把以下注册表代码复制到记事本另存为wap.reg运行,在地址栏输入http://wap.baidu.com,点击极简版,再点击贴吧进入极简版贴吧<br/>"+
		"Windows Registry Editor Version 5.00<br/>"+
		"[HKEY_CURRENT_USER\\Software\\Classes\\MIME\\Database\\Content Type\\text/vnd.wap.wml]<br/>"+
		"\"CLSID\"=\"{25336920-03F9-11cf-8FD0-00AA00686F13}\"";

	document.getElementById("Sign_MainDiv").innerHTML="此代码是蝉曦签到的分支版本:<br/>"+
		"主体代码与电脑签到跟随 http://chanxi.googlecode.com/files/sign.js 更新<br/>"+
		"模拟手机签到采用蝉曦旧版签到代码稍微修改而成<br/>"+
		"程序开始工作...<br/>---开始收集I贴吧中的贴吧名,请等待 ......<br/>";
}

function mark_fav(){//电脑签到
	countba();//收集贴吧,开始运行签到程序
}
//查贴吧数量,收集贴吧
function countba(){
	$(".Sign_BtnTop")[0].innerHTML="开始收集。。。";
	
	$.ajax({
		 type: "get",url: "http://tieba.baidu.com/i/" +PageData.user.itieba_id,
		 data: "",dataType: "text",success: function (data) { 
				//alert(cutchar(data,"$_likeForum=[","];"))
				var dataObjs=$(data).find(".always_go_list li .j_ba_link"); 
				for(var i=0;i<dataObjs.length;i++){
					baObjs[i] =new Object;
					baObjs[i].fid=dataObjs.eq(i).attr("forum-id");
					baObjs[i].name=dataObjs.eq(i).attr("title")||dataObjs.eq(i)[0].innerHTML;
					baObjs[i].kw=dataObjs.eq(i).attr("forum");
				}
				$(".Sign_BtnTop")[0].innerHTML="收集完毕!";
				$(".Sign_BtnTop")[1].innerHTML="0 / "+baObjs;
				$(".Sign_MainDiv")[0].innerHTML+="估测完毕:您喜欢的贴吧有"+(baObjs.length)+"个,最长将花费时间"+parseInt(baObjs.length*6/60)+""+(baObjs.length*6%60)+"";
				checksigned(0);
		 }, 
		 error: function () { 
			 $(".Sign_MainDiv")[0].innerHTML+="收集贴吧遇到问题,程序不能继续下去!请手动刷新后重新运行!";
		 } 
	 });
}


//检查该贴吧有没有签到
function checksigned(bai){
	if(bai>=baObjs.length){
		$(".Sign_MainDiv")[0].innerHTML+="<br/>签到完毕!请自行检查有没有签到正确,如有错误,欢迎反馈<a href='http://tieba.baidu.com/p/1768731534'  target='_blank'>蝉曦吧反馈专用贴</a><br/><br/><br/><br/><br/>";
		$(".Sign_BtnTop")[2].innerHTML="<span style='color:red;'>签到完毕!</span>";//显示签到完毕
		return 0;
	}else{
		$(".Sign_BtnTop")[1].innerHTML=(bai+1)+" / "+baObjs.length;//显示在签第几个
		$(".Sign_MainDiv")[0].innerHTML+="<br/>+"+(bai+1)+" .<a href='http://tieba.baidu.com/f?kw="+baObjs[bai].kw+"' target='_blank'>"+baObjs[bai].name+"吧</a>";
	}
	$.ajax({
		 type: "get",url:  "http://tieba.baidu.com/f?kw="+baObjs[bai].kw+"&mmmm="+Math.random(),
		 data: "",dataType: "text",success: function (data) { 
				var rewords=data;
				var my_Rank=cutchar(rewords,"<span class=\"sign_index_num j_signin_index\">","</span>");
				var my_Days=cutchar(rewords,"c_sign_num : ",",");
				var my_AllDays=cutchar(rewords,"c_sign_num : ",",");
				var tbs=cutchar(rewords,"PageData.tbs = \"","\";");
				
				if(cutchar(rewords,"PageData.user.is_block = ",";//是否已封禁")=="1"){
					$(".Sign_MainDiv")[0].innerHTML+="--您在本吧<span style='color:red;'>被封禁,不能签到!</span>---防和谐,等待1s ing...";
					setTimeout("checksigned("+(bai+1)+");",1000);
					return 0;	
				}
				if(rewords.indexOf("<span class=\"sign_index_num j_signin_index\">")<0){
					$(".Sign_MainDiv")[0].innerHTML+="--本吧还没开放签到系统!---防和谐,等待1s ing...";
					setTimeout("checksigned("+(bai+1)+");",1000);
					return 0;	
				}
				if(my_Rank=="0"){
					$(".Sign_MainDiv")[0].innerHTML+="--未签到!";
					signed(bai,tbs);
				}else{
					$(".Sign_MainDiv")[0].innerHTML+="--已签到!--今日第<span style='color:red;'>"+my_Rank+"</span>个签到,连续<span style='color:red;'>"+my_Days+"</span>天!---防和谐,等待1s ing...";
					setTimeout("checksigned("+(bai+1)+");",1000);
				}
				return 0;
		 }, 
		 error: function () { 
			$(".Sign_MainDiv")[0].innerHTML+="---检查出现问题,重新检查!";
			setTimeout("checksigned("+bai+");",1000);
		 } 
	});	
	
}

//对该贴吧进行签到
function signed(bai,tbs){
	$.ajax({
		type: "post",
		url:  "http://tieba.baidu.com/sign/add",
		data: "kw="+encodeURIComponent(baObjs[bai].name)+"&ie=utf-8&tbs="+tbs, 
		dataType: "text",
		success: function (data) { 
				var rewords=eval('(' + data + ')'); 
				if(rewords.error==""){
					$(".Sign_MainDiv")[0].innerHTML+="--签到完毕,您是第<span style='color:red;'>"+rewords.data.uinfo.user_sign_rank+"</span>个签到,连续<span style='color:red;'>"+rewords.data.uinfo.cont_sign_num+"</span>天,共<span style='color:red;'>"+rewords.data.uinfo.cout_total_sing_num+"</span>天!---防和谐,等待6s ing...";
					var  waittime=6000;
				}
				else{
					$(".Sign_MainDiv")[0].innerHTML+="--<span style='color:red;'>"+eval('"'+rewords.error+'"')+"</span>---防和谐,等待1s ing...";
					var  waittime=1000;
				}
				setTimeout("checksigned("+(bai+1)+");",waittime);
		 }, 
		 error: function () { 
			 $(".Sign_MainDiv")[0].innerHTML+="签到出现问题,马上重签!";
			 signed(bai,tbs);
		 } 
	 });
}

function mark_cell(){//手机签到
	if(navigator.userAgent=="Mozilla/5.0 (Linux; U; Android 4.1.2; zh-cn; MB526 Build/JZO54K) AppleWebKit/530.17 (KHTML, like Gecko) FlyFlow/2.4 Version/4.0 Mobile Safari/530.17 baidubrowser/042_1.8.4.2_diordna_458_084/alorotoM_61_2.1.4_625BM/1200a/39668C8F77034455D4DED02169F3F7C7%7C1327"){
		ajax.get("http://wapp.baidu.com/mo/q----sz%40240_320%2C,sz@320_240-1-3-0--2/m?tn=bdIndex&lp=7202", function(data){
			var waite = setTimeout(function(){
				countba_cell();
			},6000);
		});
	}else{
		ajax.get("http://wapp.baidu.com/mo/q----sz%40320_240%2C,sz@176_208-1-1-0--2/m?tn=bdIndex&lp=1062", function(data){
			var waite = setTimeout(function(){
				countba_cell();
			},6000);
		});
	}
}

function countba_cell(){//收集贴吧
	var i=0;ba=0;
	var urlStr1;
	ajax.get("http://wapp.baidu.com/mo/m?tn=bdFBW&tab=favorite", function(data){
		pageStr=data.split("/m?kw");
		urlStr1=cutchar(data,"/mo/","/m?");
		for(var j=1;j<pageStr.length;j++){
			baEN[ba]=cutchar(pageStr[j],"=","\"");
			baCH[ba]=cutchar(pageStr[j],"\">","</a>");
			ba++;
		}
		document.getElementById("myli1").innerHTML="收集完毕!";
		document.getElementById("myli2").innerHTML="0 / "+ba;
		var ret = setInterval(function(){
			document.getElementById("myli2").innerHTML=(i+1)+" / "+ba		
			document.getElementById("Sign_MainDiv").innerHTML+="<br/>";
			ajax.get("http://wapp.baidu.com/mo/"+urlStr1+"/m?kw="+baEN[i]+"&m="+Math.random(), function(data){
				document.getElementById("Sign_MainDiv").innerHTML+=(i+1)+". <a href='http://wapp.baidu.com/mo?kw="+baEN[i]+"' target='_blank'>"+baCH[i]+"</a>";
				check_cell(data,urlStr1,baEN,i);
				i++;
				if(i==ba) {
					clearInterval(ret);
					document.getElementById("myli5").innerHTML="<span style='color:red;'>签到完毕!</span>";
				}
			});
		},4000);
	});
}

function check_cell(data,urlStr1,baEN,i){//判断贴吧
	if(data.indexOf("<span >已签到</span>")>0) {
		document.getElementById("Sign_MainDiv").innerHTML+="--已签到!";
	}else if(data.indexOf(">签到</a>")>0){
		document.getElementById("Sign_MainDiv").innerHTML+="--未签到!";
		var  urlStr2=cutchar(data,"/sign?","\"").replace(/&amp;/gi,"&");
		ajax.get("http://wapp.baidu.com/mo/"+urlStr1+"/sign?"+urlStr2, function(data){
			sign_cell(data);
		});
	}else if(data.indexOf(">喜欢本吧</a>")>0){
		document.getElementById("Sign_MainDiv").innerHTML+="--未喜欢!";
		var  urlStr2=cutchar(data,"amp;itb_","\"").replace(/&amp;/gi,"&");
		ajax.get("http://wapp.baidu.com/mo/"+urlStr1+"/sign?"+urlStr2, function(data){
			sign_cell(data);
		});
	}else if(data.indexOf("<td style=\"text-align:right;\"></td>")>0){
		document.getElementById("Sign_MainDiv").innerHTML+="--本吧还没开放签到系统!";
	}else if(data.indexOf("请下载贴吧客户端,享受更佳小说吧阅读体验")>0){
		ajax.get("http://wapp.baidu.com/mo/m?kw="+baEN[i]+"&lp=novel_guide_skip&novel_client_guide=1", function(data){
			check_cell(data,urlStr1,baEN,i);
		});
	}
}

function sign_cell(data){//开始签到
	if(data.indexOf("<span class=\"light\">签到成功,经验值上升<span class=\"light\">6</span>")>=0)
		document.getElementById("Sign_MainDiv").innerHTML+="--签到,经验+6!";
	else if(data.indexOf("<span class=\"light\">签到成功,经验值上升<span class=\"light\">5</span>")>=0)
		document.getElementById("Sign_MainDiv").innerHTML+="--签到,经验+5!";
	else if(data.indexOf("<span class=\"light\">签到成功,经验值上升<span class=\"light\">4</span>")>=0)
		document.getElementById("Sign_MainDiv").innerHTML+="--签到,经验+4!";
	else if(data.indexOf("<span class=\"light\">签到成功,经验值上升<span class=\"light\">3</span>")>=0)
		document.getElementById("Sign_MainDiv").innerHTML+="--签到,经验+3!";
	else if(data.indexOf("<span class=\"light\">汗,操作未成功,麻烦再试一下下")>=0)
		document.getElementById("Sign_MainDiv").innerHTML+="--签到失败!操作未成功,请稍后再试!";
	else if(data.indexOf("<span class=\"light\">你在本吧被封禁不能进行当前操作")>=0)
 		document.getElementById("Sign_MainDiv").innerHTML+="--被封禁,不能签到!";
	else if(data.indexOf("<span class=\"light\">零点时分,赶在一天伊始签到的人好多,亲要不等几分钟再来签吧~")>=0)
		document.getElementById("Sign_MainDiv").innerHTML+="--签到失败!零点时分,签到人数过多,请稍后再试!";
	else if(data.indexOf("<span class=\"light\">亲,你之前已经签过了")>=0)
		document.getElementById("Sign_MainDiv").innerHTML+="--已签到!";
 }

function deleteTag(id){
    var my = document.getElementById(id);
    if (my != null)       my.parentNode.removeChild(my);
 }

function div_allHid(){
	deleteTag("Sign_Body");
//	location.href="http://adf.ly/LzLxo";
}
function cutchar(allstr,prechar,endchar){
	var preposition=allstr.indexOf(prechar)+prechar.length;
	var strlength=allstr.indexOf(endchar,preposition);
	return allstr.substring(preposition,strlength);
}

function Ajax(recvType) {
    var aj = new Object();
    aj.recvType = recvType ? recvType.toUpperCase() : 'HTML';//HTML XML
    aj.targetUrl = '';//请求地址
    aj.sendString = '';//发送的字符串
    aj.resultHandle = null;
    aj.createXMLHttpRequest = function() {//创建ajax引擎对象
        var request = false;
       //window对象中有XMLHttpRequest存在就是非IE,包括(IE7,IE8)
        if (window.XMLHttpRequest) {
            request = new XMLHttpRequest();
            if (request.overrideMimeType) {
                request.overrideMimeType("text/xml");
            }
        //window对象中有ActiveXObject属性存在就是IE
        } else if (window.ActiveXObject) {
            var versions = ['Microsoft.XMLHTTP', 'MSXML.XMLHTTP', 'Msxml2.XMLHTTP.7.0', 'Msxml2.XMLHTTP.6.0', 'Msxml2.XMLHTTP.5.0', 'Msxml2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP'];
            for (var i = 0; i < versions.length; i++) {
                try {
                    request = new ActiveXObject(versions[i]);
                    if (request) {
                        return request;
                    }
                } catch(e) {
                    request = false;
                }
            }
        }
        return request;
    }
    aj.XMLHttpRequest = aj.createXMLHttpRequest();//获取ajax引擎对象
    aj.processHandle = function() {//判断状态
        if (aj.XMLHttpRequest.readyState == 4) {
            if (aj.XMLHttpRequest.status == 200) {
                if (aj.recvType == "HTML") aj.resultHandle(aj.XMLHttpRequest.responseText);
                else if (aj.recvType == "XML") aj.resultHandle(aj.XMLHttpRequest.responseXML);
            }
        }
    }
    aj.get = function(targetUrl, resultHandle) {
        aj.targetUrl = targetUrl;
        if (resultHandle != null) {
            aj.XMLHttpRequest.onreadystatechange = aj.processHandle;
            aj.resultHandle = resultHandle;//接收回调方法
        }
        if (window.XMLHttpRequest) {
            aj.XMLHttpRequest.open("get", aj.targetUrl);
            aj.XMLHttpRequest.send(null);
        } else {
            aj.XMLHttpRequest.open("get", aj.targetUrl, true);
            aj.XMLHttpRequest.send();
        }
    }
    aj.post = function(targetUrl, sendString, resultHandle) {
        aj.targetUrl = targetUrl;
        if (typeof(sendString) == "object") {
            var str = "";
            for (var pro in sendString) {
                str += pro + "=" + sendString[pro] + "&";
            }
            aj.sendString = str.substr(0, str.length - 1);
        } else {
            aj.sendString = sendString;
        }
        if (resultHandle != null) {
            aj.XMLHttpRequest.onreadystatechange = aj.processHandle;
            aj.resultHandle = resultHandle;
        }
        aj.XMLHttpRequest.open("post", targetUrl);
        aj.XMLHttpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        aj.XMLHttpRequest.send(aj.sendString);
    }
    return aj;
}

New Annotation

Summary:
Author:
Mode:
Body: