CL_autoReply

草榴新手自动回复

As of 2014-07-31. See the latest version.

// ==UserScript==
// @name           CL_autoReply
// @description    草榴新手自动回复
// @include        http://*t66y.com/*
// @include        http://cl.man.lv/*
// @include        http://184.154.178.130/*
// @author         congxz6688
// @version        2014.7.31.0
// @grant          none
// @namespace https://greasyfork.org/scripts/102
// ==/UserScript==

function addStyle(css){
	document.head.appendChild(document.createElement("style")).textContent = css;
}
addStyle("#autoReply{margin-left:800px}");
var rou = ["%D0%BB%D0%BB%B7%D6%CF%ED", "%D5%E2%B8%F6%B2%BB%B4%ED%A1%A3", "%B8%D0%D0%BB%B7%D6%CF%ED", "%BA%DC%B2%BB%B4%ED%B5%C4%C2%EF"];
var kinds = ["7", "7", "7", "7", "7", "7", "2", "2", "2", "15", "15", "4", "4", "5"];
var ede;

function runAutoreply() {
	var thisFid = kinds[Math.floor(kinds.length * Math.random())];
	var fidListurl = "http://" + window.location.hostname + "/thread0806.php?fid=" + thisFid;
	var getFidList = new XMLHttpRequest();
	getFidList.open("GET", fidListurl, true);
	getFidList.send(null);
	getFidList.onreadystatechange = function () {
		if (getFidList.readyState == 4) {
			if (getFidList.status == 200) {
				console.log("已经进入fid" + thisFid + "的第1页,开始随机获取主题信息...");
				var reTextTxt = getFidList.responseText;
				var tr2n = reTextTxt.split('>��ͨ���}<')[1];
				var tdthis = tr2n.match(/<h3>.*?<\/h3>/g)[Math.ceil(90 * Math.random())];
				var tid = tdthis.match(/tid=\d{6,}|\d{6,}\.html/)[0].match(/\d+/)[0];
				var tdtitle = tdthis.match(/">(.*)?<\//)[1];
				var td_content = rou[Math.floor(rou.length * Math.random())];
				var dataa = "atc_money=0&atc_rvrc=0atc_usesign=1&atc_convert=1&atc_autourl=1&atc_title=Re:" + tdtitle + "&atc_content=%D0%BB%D0%BB%B7%D6%CF%ED&step=2&action=reply&fid=" + thisFid + "&tid=" + tid + "&editor=0&atc_attachment=none&pid=&article=&verify=" + (thisFid == "7" ? "3de7ee9f" : "verify");
				console.log("主题信息获取成功,开始回复主题" + tid + "...");
				var urll = "http://" + window.location.hostname + "/post.php?";
				var myPost = new XMLHttpRequest();
				myPost.open("POST", urll, true);
				myPost.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
				myPost.setRequestHeader("Content-length", dataa.length);
				myPost.setRequestHeader("Connection", "close");
				myPost.send(dataa);
				myPost.onreadystatechange = function () {
					if (myPost.readyState == 4) {
						if (myPost.status == 200) {
							var res = myPost.responseText;
							if (res.indexOf("�l�N�ꮅ�c���M�����}�б�") != -1) {
								var jyy = new Date();
								var recardTime = jyy.getTime();
								var edwwq = jyy.toLocaleTimeString();
								console.log("已于 " + edwwq + " 回复成功...1080秒后再试");
								localStorage["recardTime"] = recardTime;
								clearTimeout(ede);
								ede = setTimeout(runAutoreply, 1080000);
							} else if (res.indexOf("��ˮ�A���C���ѽ����_����1024��Ȳ��ܰl�N") != -1) {
								console.log("发贴时间未到...6分钟后再试");
								clearTimeout(ede);
								ede = setTimeout(runAutoreply, 360000);
							} else if (res.indexOf("�Ñ��M���ޣ������ٵ��Ñ��Mÿ������ܰl 10 ƪ����.") != -1) {
								console.log("新人每天回复不能超过10贴,今天发完了");
								document.getElementById("autoReply").checked = false;
								localStorage['autoReplybox'] = "false";
							} else {
								alert("自动回复出现未知情况,请检查...\r\n" + res);
							}
						} else {
							console.log("出现错误,1分钟后重新尝试");
							clearTimeout(ede);
							ede = setTimeout(runAutoreply, 60000);
						}
					}
				}
			}
		}
	}
}

//添加按钮
var replySpan = document.createElement("span");
replySpan.innerHTML = "自动回复";
var autoReplybox = document.createElement("input");
autoReplybox.type = "checkbox";
autoReplybox.id = "autoReply";
autoReplybox.title = "选中此项,启动自动回复,否则,关闭自动回复";
autoReplybox.checked = !localStorage.autoReplybox || localStorage.autoReplybox == "false" ? false : true;
autoReplybox.addEventListener('click', function () {
	localStorage['autoReplybox'] = document.getElementById("autoReply").checked;
}, true);
document.querySelector(".banner").appendChild(autoReplybox);
document.querySelector(".banner").appendChild(replySpan);

if (document.getElementById("autoReply").checked) {
	var nrt = new Date();
	var nowTime = nrt.getTime();
	var edwww = nrt.toLocaleTimeString();
	var lastTime = localStorage.recardTime ? localStorage.recardTime : 0;
	var tbt = nowTime - lastTime;
	if (tbt > 1075000) {
		runAutoreply();
	} else {
		clearTimeout(ede);
		console.log("现在是 " + edwww + ",上次回复是" + tbt + "毫秒前");
		ede = setTimeout(runAutoreply, 1080000 - tbt);
	}
}