支持“胡萝卜周”、“殁漂遥”、“独孤求软”,理论上是支持 WordPress 模板的网站,但是需要自行添加 include
当前为
// ==UserScript==
// @name WordPress 系博客验证码 自动填表
// @author 极品小猫
// @version 1.1.2
// @description 支持“胡萝卜周”、“殁漂遥”、“独孤求软”,理论上是支持 WordPress 模板的网站,但是需要自行添加 include
// @namespace https://greasyfork.org/zh-CN/users/3128
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_addStyle
// @grant GM_xmlhttpRequest
// @grant unsafeWindow
// @grant GM_info
// @include http://www.carrotchou.blog/*.html
// @include https://www.mpyit.com/*.html
// @include http://www.dugubest.com/archives/*
// @exclude http*://mail.*
// @require http://cdn.staticfile.org/jquery/2.1.4/jquery.min.js
// @run-at document-idle
// ==/UserScript==
let u=unsafeWindow,
urls=location.href,
host=location.hostname,
hosts=location.hostname.replace(/^www\./i,''),
paths=location.pathname,
searchs=location.search.replace(/^\?/,''),
ToDay=getDate(),
CodeData={};
if(typeof(GM_getValue('CodeData'))=='undefined') GM_setValue('CodeData', {});
else CodeData=GM_getValue('CodeData');
let WordPress = ['carrotchou.blog', 'mpyit.com', 'dugubest.com']; //WordPress 模板网站清单
let HostList={
'WordPress':{//WordPress 模板博客通用规则
'id':'#gogogo, #verifycode',
'val': '',//默认密码
'btn':'#verifybtn',
callback: function(){
let config=CodeData[hosts];
//重新记录密码
if(config.verifycode=='none') {
config.verifycode=conf.val;
config.date=ToDay;
CodeData[hosts]=config;
GM_setValue('CodeData', CodeData);
}
},
pre : function(conf, e){
let config=CodeData[hosts]||{date:"", verifycode:""};
//密码检测阶段1,日期不符
/*
if((!config.date||config.date!==ToDay)&&config.verifycode=='none') {
config.verifycode=prompt('填写今天的暗号:', config.verifycode);
}
*/
//密码检测阶段2,暗号出错
$('script:not([src]):not([type="text/javascript"])').each(function(){
if(/暗号出错|验证码错误/.test(this.textContent)&&config.verifycode!=='none') {
config.verifycode=prompt('验证码错误,请重写(输入none则今天不会再打扰你了):', config.verifycode);
}
});
//密码检测阶段3,无效密码
while((!config.verifycode||config.verifycode=='null')&&config.verifycode!=='none') config.verifycode=prompt('没有写入暗号,请重写(输入none则不会再打扰你了):', config.verifycode);
config.date=ToDay;
CodeData[hosts]=config;
GM_setValue('CodeData', CodeData);
conf.val=config.verifycode;
document.body.oncopy=function(){return null;};
return conf;
}
}
}
for(let i in WordPress) HostList[WordPress[i]]=HostList['WordPress']; //生成 HostList
if(u.wpp_params && !HostList[hosts]) HostList[hosts]=HostList['WordPress'];
if(HostList[hosts]) {
let conf=HostList[hosts];
console.log($(conf['id']))
if($(conf['id']).length>0) {
if(conf['pre']) conf=conf['pre'](conf);
$(document).ready(function(){
//用户名填表
var t=setInterval(function(){
if($('#username,[name="username"], #password,[name="password"]').length>0) {
setTimeout(function(){
$('#username,[name="username"]').val(conf.username).keydown();
$('#password,[name="password"]').val(conf.password).keydown();
},100)
clearInterval(t);
}
},1000);
if(conf['callback']) $(conf['btn']).on('click', conf['callback']);
$(conf['id']).val(conf['val']);
$(conf['btn']).click();
});
}
}
function getDate(type) {
var myDate = new Date();
var year=myDate.getFullYear(); //获取当前年
var month=myDate.getMonth()+1; //获取当前月
var day=myDate.getDate(); //获取当前日
switch(type) {
case '/': return year+type+month+type+day;
break;
default :
return year+'-'+month+'-'+day;
}
}