WordPress 系博客验证码 自动填表

支持“胡萝卜周”、“殁漂遥”、“独孤求软”、“蓝点网”,理论上是支持 WordPress 模板的网站,但是需要自行添加 include

  1. // ==UserScript==
  2. // @name WordPress 系博客验证码 自动填表
  3. // @author 极品小猫
  4. // @version 1.2.4
  5. // @description 支持“胡萝卜周”、“殁漂遥”、“独孤求软”、“蓝点网”,理论上是支持 WordPress 模板的网站,但是需要自行添加 include
  6. // @namespace https://gf.qytechs.cn/zh-CN/users/3128
  7. // @grant GM_setValue
  8. // @grant GM_getValue
  9. // @grant GM_addStyle
  10. // @grant GM_xmlhttpRequest
  11. // @grant unsafeWindow
  12. // @grant GM_info
  13. // @include http://www.carrotchou.blog/*.html
  14. // @include https://mpyit.com/*.html*
  15. // @include https://www.mpyit.com/*.html*
  16. // @include http://www.dugubest.com/archives/*
  17. // @include https://huajiakeji.com/downloadstart.html#*
  18. // @include https://www.landiannews.com/archives/*
  19. // @exclude http*://mail.*
  20. // @require http://cdn.staticfile.org/jquery/2.1.4/jquery.min.js
  21. // @run-at document-idle
  22. // @license MIT
  23. // ==/UserScript==
  24.  
  25. let u=unsafeWindow,
  26. urls=location.href,
  27. host=location.hostname,
  28. hosts=location.hostname.replace(/^www\./i,''),
  29. paths=location.pathname,
  30. searchs=location.search.replace(/^\?/,''),
  31. ToDay=getDate(),
  32. CodeData={};
  33.  
  34. if(typeof(GM_getValue('CodeData'))=='undefined') GM_setValue('CodeData', {});
  35. else CodeData=GM_getValue('CodeData');
  36.  
  37. let WordPress = ['carrotchou.blog', 'mpyit.com', 'dugubest.com','landiannews.com']; //WordPress 模板网站清单
  38.  
  39. let HostList={
  40. 'WordPress':{//WordPress 模板博客通用规则
  41. 'id':'#verifycode, [name="huoduan_laomome"], #gogogo',
  42. 'val': '',//默认密码
  43. 'btn':'#verifybtn',
  44. callback: function(){
  45. let config=CodeData[hosts];
  46.  
  47. //重新记录密码
  48. if(config.verifycode=='none') {
  49. config.verifycode=this.val;
  50. config.date=ToDay;
  51. CodeData[hosts]=config;
  52. GM_setValue('CodeData', CodeData);
  53. }
  54. },
  55. pre : function(conf, e){ //预定义行为
  56. let config=CodeData[hosts]||{date:"", verifycode:""};
  57.  
  58. //密码检测阶段1,日期不符
  59. /*
  60. if((!config.date||config.date!==ToDay)&&config.verifycode=='none') {
  61. config.verifycode=prompt('填写今天的暗号:', config.verifycode);
  62. }
  63. */
  64.  
  65. //密码检测阶段2,暗号出错
  66. $('script:not([src]):not([type="text/javascript"])').each(function(){
  67. if(/暗号出错|验证码错误/.test(this.textContent)&&config.verifycode!=='none') {
  68. config.verifycode=prompt('验证码错误,请重写(输入none则今天不会再打扰你了):', config.verifycode);
  69. }
  70. });
  71.  
  72. //密码检测阶段3,循环检测没有输入密码
  73. while((!config.verifycode||config.verifycode=='null')&&config.verifycode!=='none') config.verifycode=prompt('没有写入暗号,请重写(输入none则不会再打扰你了):', config.verifycode||'none');
  74.  
  75. config.date=ToDay;
  76. CodeData[hosts]=config;
  77. GM_setValue('CodeData', CodeData);
  78.  
  79. conf.val=config.verifycode;
  80. document.body.oncopy=function(){return false;};
  81. return conf;
  82. }
  83. }
  84. }
  85. for(let i in WordPress) HostList[WordPress[i]]=HostList['WordPress']; //生成 HostList
  86. if((u.wpp_params||u.wp&&(u.wp_url||u.wppay_ajax_url)) && !HostList[hosts]) HostList[hosts]=HostList['WordPress'];
  87.  
  88. if(HostList[hosts]) {
  89. let conf=HostList[hosts];
  90.  
  91. //检查密码框目标是否存在
  92. if($(conf['id']).length>0) {
  93. if(conf['pre']) conf=conf['pre'](conf); //执行预定义行为
  94.  
  95. $(document).ready(function(){
  96. //用户名填表
  97. var t=setInterval(function(){
  98. if($('#username,[name="username"], #password,[name="password"]').length>0) {
  99. setTimeout(function(){
  100. $('#username,[name="username"]').val(conf.username).keydown();
  101. $('#password,[name="password"]').val(conf.password).keydown();
  102. },100)
  103. clearInterval(t);
  104. }
  105. },1000);
  106.  
  107. if(conf['callback']) $(conf['btn']).on('click', conf['callback']); //绑定密码重置
  108. if(conf['val']&&conf['val']!=='none') { //存在密码时,自动填写
  109. $(conf['id']).val(conf['val']);
  110. $(conf['btn']).click();
  111. }
  112. });
  113. }
  114.  
  115. //跳转链处理
  116. $('body').on('click', 'a', function(e){
  117. if(/\/go\?url=/i.test(this.href)) this.href=getUrlParam('url', this.href);
  118. });
  119. }
  120.  
  121. function getUrlParam(name, url, option, newVal) {
  122. var search = url ? url.replace(/^.+\?/,'') : location.search;
  123. var reg = new RegExp("(?:^|&)(" + name + ")=([^&]*)(?:&|$)", "i");
  124. var str = search.replace(/^\?/,'').match(reg);
  125.  
  126. if (str !== null) {
  127. switch(option) {
  128. case 0:
  129. return unescape(str[0]);
  130. case 1:
  131. return unescape(str[1]);
  132. case 2:
  133. return unescape(str[2]);
  134. case 'new':
  135. return url.replace(str[1]+'='+str[2], str[1]+'='+newVal);
  136. default:
  137. return unescape(str[2]);
  138. }
  139. } else {
  140. return false;
  141. }
  142. }
  143.  
  144. function getDate(type) {
  145. var myDate = new Date();
  146.  
  147. var year=myDate.getFullYear();
  148. var month=myDate.getMonth()+1;
  149. var day=myDate.getDate();
  150.  
  151. switch(type) {
  152. case '/': return year+type+month+type+day;
  153. break;
  154. default :
  155. return year+'-'+month+'-'+day;
  156. }
  157. }

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址