CL_autoReply

草榴新手自动回复

当前为 2014-07-31 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==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.1
// @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", "%B8%D0%D0%BB%C2%A5%D6%F7%B5%C4%B7%D6%CF%ED", "%B8%D0%D0%BB%B7%D6%CF%ED", "%B8%D0%D0%BB%C2%A5%D6%F7%B7%D6%CF%ED", "%D0%BB%D0%BB%B7%D6%CF%ED", "%B8%D0%D0%BB%C2%A5%D6%F7%B5%C4%B7%D6%CF%ED", "%B8%D0%D0%BB%B7%D6%CF%ED", "%B8%D0%D0%BB%C2%A5%D6%F7%B7%D6%CF%ED"];
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=" + td_content + "&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);
	}
}