20190210: setTimeout用法修正,就懒得写更新日志了,顺带把框框去掉了【部分代码已回滚
20190208: 核心内容没动,但是有个看脸触发的bug,反正手动刷新一次能解决就不管了吧~
使用书签前务必等待页面读条完毕,之前已经触发了乱码的话,可以点一下其他楼层的评分或回复,然后新的框会取代旧的,注意别回错贴了~
之前提到的签到入口http://www.mcbbs.net/plugin.php?id=dc_signin:sign,请一定从该入口签到,论坛默认的签到界面调用的官方脚本很长,咱懒得去想该咋打补丁了【x
之前的帖子:http://www.mcbbs.net/thread-813253-1-1.html,原理:http://www.mcbbs.net/thread-835702-1-1.html
希望从默认签到入口签到的可以参考http://www.mcbbs.net/thread-843668-1-1.html
使用方法:就像上次那样吧=v=
- 用了 throw new Error 强行让脚本报错来停止后继事务
- 暂时只在电脑版chrome测试
这次防火墙比上次高级,我看控制台有时候重发了十几遍直到服务器未响应的……超过十秒没动静的话请刷新重试【话说这样和之前有差别咩……- 其它的等想到了再补叭……
TODO:好想加一个GUI……已加,看看反馈……关于点了提交之后没响应,在控制台里应该会看到一行一行刷的detected ccdefend之类的东西,同时网络那栏也会有自动重试的请求出来的!加了个用户体验爆炸的框……
- [
- {
- "date":"2019-02-08",
- "desc":"论坛模板v2.0重构:(ZhaiSoul)gamerteam更新:2018/12/06",
- "poem":"没有bug的代码是没有灵魂的!"
- },
- {
- "date":"2019-01-05",
- "desc":"把之前的代码搬回来了,尝试性加个弹窗,计数器不重置是特性!"
- },
- {
- "date":"2018-12-18-rc2",
- "desc":"终于看完签到插件怎么从服务器获取token的逻辑了,为嘛感觉比dz自己的代码还复杂 = ="
- },
- {
- "date":"2018-12-18-rc1",
- "desc":"重新利用起自带的evalscript(),终于填完了同时支持两种格式ccdefend的坑"
- },
- {
- "date":"2018-08-10-v1",
- "desc":"往_ajaxget函数多塞了一段判断ccdefend出现时的处理逻辑,改动过的地方应该都加上了注释,原始的_ajaxget代码来自discuz"
- }
- ]
- // GUI初始化
- a68counter = 0;
- a68wait = 2000;
- cookie_start = document.cookie.indexOf('ccdefend');
- cookie_end = document.cookie.indexOf(";", cookie_start);
- cookie_end = cookie_end > cookie_start ? cookie_end : document.cookie.length;
- a68ccdefend = document.cookie.substring(cookie_start + name.length + 1, cookie_end);
- // 验证XHR内容,提取cookies并写入浏览器
- function is_ccdefend(s) {
- // portal处登录,评分,楼层左下回复:
- // <script type="text/javascript">var v='76d6751f93d24a571d2d4cedeb330733'; document.cookie='ccdefend='+v+'; path=/'; window.location.reload();</script>
- //
- flag = 0;
- if (s.indexOf('; document.cookie=\'ccdefend=\'+v+\'; path=/\'; window.location.reload();') != -1) {
- flag = 1;
- s = s.replace(' window.location.reload();', '');
- s = s.replace(' type="text/javascript"', '');
- if (s.indexOf("script") == -1) {
- s = '<script>' + s + '</script>';
- }
- console.info(s);
- evalscript(s);
- cookie_start = document.cookie.indexOf('ccdefend');
- cookie_end = document.cookie.indexOf(";", cookie_start);
- cookie_end = cookie_end > cookie_start ? cookie_end : document.cookie.length;
- newcookie = document.cookie.substring(cookie_start + name.length + 1, cookie_end);
- if(a68ccdefend == newcookie)
- {
- // console.info(v);
- showDialog('自动刷新失败<br />请手动刷新页面', 'confirm', '未知错误', '', 1);
- throw new Error('failed to change');
- }
- a68ccdefend = newcookie;
- a68counter++;
- showDialog('1秒后自动刷新请求,无需重复点击提交按钮~<br />当前重试次数:' + a68counter + '<br />【这个窗口可以关', 'confirm', '自动处理中!', '', 1);
- if (a68counter > 9) {
- showDialog('重试次数过多,服务器可能过载<br />请打开记事本保存帖子内容,并刷新页面重试', 'confirm', '重试过多', '', 1);
- throw new Error('too many failed');
- }
- }
- return flag
- }
- function _ajaxget(url, showid, waitid, loading, display, recall) {
- waitid = typeof waitid == 'undefined' || waitid === null ? showid : waitid;
- var x = new Ajax();
- x.setLoading(loading);
- x.setWaitId(waitid);
- x.display = typeof display == 'undefined' || display == null ? '' : display;
- x.showId = $(showid);
- if (url.substr(strlen(url) - 1) == '#') {
- url = url.substr(0, strlen(url) - 1);
- x.autogoto = 1
- }
- var __url = url; // 保留原始url
- var url = url + '&inajax=1&ajaxtarget=' + showid;
- x.get(url, function(s, x) {
- if (is_ccdefend(s)) {
- setTimeout(_ajaxget, a68wait, __url, showid, waitid, loading, display, recall);
- throw new Error('detected ccdefend');
- }
- var evaled = false;
- if (s.indexOf('ajaxerror') != -1) {
- evalscript(s);
- evaled = true
- }
- if (!evaled && (typeof ajaxerror == 'undefined' || !ajaxerror)) {
- if (x.showId) {
- x.showId.style.display = x.display;
- ajaxinnerhtml(x.showId, s);
- ajaxupdateevents(x.showId);
- if (x.autogoto) scroll(0, x.showId.offsetTop)
- }
- }
- ajaxerror = null;
- if (recall && typeof recall == 'function') {
- recall()
- } else if (recall) {
- eval(recall)
- }
- if (!evaled) evalscript(s)
- })
- }
- // 重新获取多处Geetest验证token
- parse_xml_callback = function() {
- if ((xmlHttp.readyState == 4) && (xmlHttp.status == 200)) {
- if (is_ccdefend(xmlHttp.responseText)) {
- setTimeout(reloadGeetest, a68wait);
- throw new Error('detected ccdefend');
- }
- var obj = JSON.parse(xmlHttp.responseText);
- initGeetest({
- gt: obj.gt,
- challenge: obj.challenge,
- offline: !obj.success,
- timeout: '5000',
- product: "bind",
- width: "300px"
- }, handler)
- }
- };
- function reloadGeetest() {
- xmlHttp.open("GET", "./plugin.php?id=geetest3&model=start&t=" + (new Date()).getTime());
- xmlHttp.send(null);
- xmlHttp.onreadystatechange = parse_xml_callback
- }
- // 页面底部的回复框
- function checkpostrule(showid, extra) {
- var x = new Ajax();
- x.get('forum.php?mod=ajax&action=checkpostrule&inajax=yes&' + extra, function(s) {
- if (is_ccdefend(s)) {
- setTimeout(checkpostrule, a68wait, showid, extra);
- throw new Error('detected ccdefend');
- }
- ajaxinnerhtml($(showid), s);
- evalscript(s)
- })
- }
- function checkpostrule_post(theform) {
- if (!seccodecheck && !secqaacheck && !theform.sechash) {
- var x = new Ajax();
- x.get('forum.php?mod=ajax&action=checkpostrule&ac=' + postaction + '&inajax=yes', function(s) {
- if (s) {
- if (is_ccdefend(s)) {
- setTimeout(checkpostrule_post, a68wait, theform);
- throw new Error('detected ccdefend');
- }
- ajaxinnerhtml($('seccheck'), s);
- evalscript(s);
- seccodecheck = true
- } else {
- postsubmit(theform)
- }
- })
- } else {
- postsubmit(theform)
- }
- }
- ipNotice(); // 异地登录提示
- if (typeof xmlHttp != "undefined") reloadGeetest();
复制代码 还是那句话,不要在不理解到底会怎样的情况下往控制台或书签里输任何东西……- javascript:a68counter=0;a68wait=2000;cookie_start=document.cookie.indexOf('ccdefend');cookie_end=document.cookie.indexOf(";",cookie_start);cookie_end=cookie_end>cookie_start?cookie_end:document.cookie.length;a68ccdefend=document.cookie.substring(cookie_start+name.length+1,cookie_end);function is_ccdefend(s){flag=0;if(s.indexOf('; document.cookie=\'ccdefend=\'+v+\'; path=/\'; window.location.reload();')!=-1){flag=1;s=s.replace(' window.location.reload();','');s=s.replace(' type="text/javascript"','');if(s.indexOf("script")==-1){s='<script>'+s+'</script>'}console.info(s);evalscript(s);cookie_start=document.cookie.indexOf('ccdefend');cookie_end=document.cookie.indexOf(";",cookie_start);cookie_end=cookie_end>cookie_start?cookie_end:document.cookie.length;newcookie=document.cookie.substring(cookie_start+name.length+1,cookie_end);if(a68ccdefend==newcookie){showDialog('自动刷新失败<br />请手动刷新页面','confirm','未知错误','',1);throw new Error('failed to change');}a68ccdefend=newcookie;a68counter++;showDialog('1秒后自动刷新请求,无需重复点击提交按钮~<br />当前重试次数:'+a68counter+'<br />【这个窗口可以关','confirm','自动处理中!','',1);if(a68counter>9){showDialog('重试次数过多,服务器可能过载<br />请打开记事本保存帖子内容,并刷新页面重试','confirm','重试过多','',1);throw new Error('too many failed');}}return flag}function _ajaxget(url,showid,waitid,loading,display,recall){waitid=typeof waitid=='undefined'||waitid===null?showid:waitid;var x=new Ajax();x.setLoading(loading);x.setWaitId(waitid);x.display=typeof display=='undefined'||display==null?'':display;x.showId=$(showid);if(url.substr(strlen(url)-1)=='#'){url=url.substr(0,strlen(url)-1);x.autogoto=1}var __url=url;var url=url+'&inajax=1&ajaxtarget='+showid;x.get(url,function(s,x){if(is_ccdefend(s)){setTimeout(_ajaxget,a68wait,__url,showid,waitid,loading,display,recall);throw new Error('detected ccdefend');}var evaled=false;if(s.indexOf('ajaxerror')!=-1){evalscript(s);evaled=true}if(!evaled&&(typeof ajaxerror=='undefined'||!ajaxerror)){if(x.showId){x.showId.style.display=x.display;ajaxinnerhtml(x.showId,s);ajaxupdateevents(x.showId);if(x.autogoto)scroll(0,x.showId.offsetTop)}}ajaxerror=null;if(recall&&typeof recall=='function'){recall()}else if(recall){eval(recall)}if(!evaled)evalscript(s)})}parse_xml_callback=function(){if((xmlHttp.readyState==4)&&(xmlHttp.status==200)){if(is_ccdefend(xmlHttp.responseText)){setTimeout(reloadGeetest,a68wait);throw new Error('detected ccdefend');}var obj=JSON.parse(xmlHttp.responseText);initGeetest({gt:obj.gt,challenge:obj.challenge,offline:!obj.success,timeout:'5000',product:"bind",width:"300px"},handler)}};function reloadGeetest(){xmlHttp.open("GET","./plugin.php?id=geetest3&model=start&t="+(new Date()).getTime());xmlHttp.send(null);xmlHttp.onreadystatechange=parse_xml_callback}function checkpostrule(showid,extra){var x=new Ajax();x.get('forum.php?mod=ajax&action=checkpostrule&inajax=yes&'+extra,function(s){if(is_ccdefend(s)){setTimeout(checkpostrule,a68wait,showid,extra);throw new Error('detected ccdefend');}ajaxinnerhtml($(showid),s);evalscript(s)})}function checkpostrule_post(theform){if(!seccodecheck&&!secqaacheck&&!theform.sechash){var x=new Ajax();x.get('forum.php?mod=ajax&action=checkpostrule&ac='+postaction+'&inajax=yes',function(s){if(s){if(is_ccdefend(s)){setTimeout(checkpostrule_post,a68wait,theform);throw new Error('detected ccdefend');}ajaxinnerhtml($('seccheck'),s);evalscript(s);seccodecheck=true}else{postsubmit(theform)}})}else{postsubmit(theform)}}ipNotice();if(typeof xmlHttp!="undefined")reloadGeetest();
复制代码 changelog:20190101:刚发现,重复评分的问题依旧能人为触发……
之前帖子里放的源代码部分其实有尝试修复编辑功能的半成品,急用的话就拿来用吧……
近几天发现直接签到都没问题了,这里的脚本是赶时间对付前段时间签到困难附带评分的那部分,也可以单纯只拿来评分
20190102:嘛,如果点提交的时候只是弹一个蓝色空白框框,没有人机验证的话说明签到依旧炸了……不过右上角公告说最近要搬家了,开心<3
之前提到的签到入口http://www.mcbbs.net/plugin.php?id=dc_signin:sign ,20180207: 发现快捷回帖框拉cookie的逻辑应该是炸了……待修复 顺带,5号的版本新增了限制重试频率的机制,之前的版本请尽快更新,避免误封…… 20190105: 稍微更新了一下,核心代码没啥改动,签到应该不需要手动干预了,开始作死试一下能不能把评分附件和编辑之类的修好……
也就是说应该不会有重复评分的问题了【也许吧……评分的时候不要重复点提交,我刚才评了个人气+6的……
|