CSDN自动评论_生效范围修改

自动评论,返还下载积分

目前为 2015-11-22 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name CSDN自动评论_生效范围修改
  3. // @author AC 原作:King.Sollyu
  4. // @namespace Sollyu
  5. // @description 自动评论,返还下载积分
  6. // @require http://code.jquery.com/jquery-1.9.0.min.js
  7. // @include http://download.csdn.net/*
  8. // @icon https://coding.net/u/zb227/p/zbImg/git/raw/master/icon.jpg
  9. // @version 2.3
  10. // ==/UserScript==
  11. // 2015-05-20.2.1 修改弹出位置,修改脚本生效位置,提供简易跳转
  12. // 2015-05-20.2.1 在Chrome中可用
  13. // 2013-01-25.1.0 CSDN自动评论
  14.  
  15. /*
  16. 需要先跳转到http://download.csdn.net/my/downloads
  17. */
  18.  
  19. //多少时间评论一次,单位:秒
  20. var tTime=65;
  21.  
  22. // 预定义的评论内容,可按照格式自行添加,注意最后一行后面没有逗号
  23. var contentPL=new Array(
  24. "很全面,很好用,谢谢分享.",
  25. "挺不错的资料,谢谢分享.",
  26. "很全,什么都有了,感谢.",
  27. "比相关书籍介绍的详细,顶一个.",
  28. "还行,适合于初级入门的学习.",
  29. "很好的资料,很齐全,谢谢.",
  30. "还可以,就是感觉有点乱.",
  31. "感謝LZ收集,用起來挺方便.",
  32. "感觉还行,只是感觉用着不是特别顺手.",
  33. "很有学习价值的文档,感谢.",
  34. "内容很丰富,最可贵的是资源不需要很多积分.",
  35. "这个真的非常好,借鉴意义蛮大.",
  36. "有不少例子可以参考,目前正需要.",
  37. "下载后不能正常使用.",
  38. "例子简单实用,但如果再全面些就更好了."
  39. );
  40.  
  41. var queueList = {};
  42.  
  43. // css
  44. var csdnHelperCss=document.createElement('style');
  45. csdnHelperCss.type='text/css';
  46. $(csdnHelperCss).html('.popWindow{position:fixed;z-index:10000;top:100px;right:650px;}.popWindow>span{display:block;text-align:left;color:cyan;text-shadow:0 0 2px white;background-color:#555;box-shadow:-1px -1px 4px gray;margin:5px 0 0 0;padding:00 6px 0 6px;cursor:pointer;font-size: 13px;}');
  47.  
  48. $('body').prepend(csdnHelperCss);
  49. $('body').prepend('<div class="popWindow"></div>');
  50.  
  51. //将本页待评论资源自动加入评论队列
  52. $(".btn-comment").each(function(){
  53. if(this.tagName!="A")
  54. return;
  55. var reg=/\/([_a-zA-Z0-9]+)\/([0-9]+)#/;
  56. var src=$(this).attr('href').match(reg);
  57. addQueue(src[1],src[2],(new Date()).getTime());
  58. $(this).parent().html("已加入评论队列");
  59. });
  60.  
  61. // 若待评论数大于0则提示用户滞留在本窗口
  62. console.debug("本次任务总数--->"+getJsonLength(queueList));
  63. if(getJsonLength(queueList) > 0){
  64. popWindow("待评论任务数:"+getJsonLength(queueList),0);
  65. popWindow("请保持在本界面,以便进行评价",6000);
  66. setInterval(searchToPost,tTime*1000);
  67. searchToPost();
  68. }else{
  69. popWindow("读取异常,可以跳转到<BR><center><a href=http://download.csdn.net/my/downloads><b><font color=Green>我的下载</font></b></a>查看</center>",0);
  70. }
  71.  
  72. function getJsonLength(jsonData){
  73. var jsonLength = 0;
  74. for(var item in jsonData){
  75. jsonLength++;
  76. }
  77. return jsonLength;
  78. }
  79.  
  80. // 添加评论队列
  81. function addQueue(owner,sourceID,stamp){
  82. queueList[stamp] = {owner, sourceID};
  83. console.log(stamp, queueList[stamp]);
  84. popWindow('已添加到任务队列,['+owner+','+sourceID+']',2000);
  85. }
  86.  
  87. // 显示消息
  88. function popWindow(str,delayTime){
  89. var obj = $('.popWindow').append('<span>'+str+'</span>').children().last();
  90. if(delayTime>0)
  91. obj.delay(delayTime).hide(1500,function(){$(this).remove();});
  92. }
  93.  
  94. function searchToPost(){
  95. // 查询有没有可以评论的资源
  96. for (var stamp in queueList){
  97. var res = queueList[stamp];
  98. post(res['owner'], res['sourceID'], stamp);
  99. break;
  100. }
  101. }
  102. // 发送评论
  103. function post(owner,sourceID,stamp){
  104. $.ajax({
  105. type:"get",
  106. url:"http://download.csdn.net/index.php/comment/post_comment",
  107. headers:{
  108. "Referer":"http://download.csdn.net/detail/"+owner+"/"+sourceID,
  109. "Content-type":"application/x-www-form-urlencoded; charset=UTF-8",
  110. "X-Requested-With":"XMLHttpRequest"
  111. },
  112. data:{
  113. "content":contentPL[Math.round(Math.random()*(contentPL.length-1))],
  114. "jsonpcallback":"jsonp"+(new Date()).getTime(),
  115. "rating":"5",
  116. "sourceid":sourceID,
  117. "t":(new Date()).getTime()
  118. },
  119. success:function(res){
  120. var index = res.indexOf("({");
  121. var data = eval(res.substr(index));
  122. var resMsg="----";
  123. console.log(data.succ);
  124. if(data.succ>0){
  125. delete queueList[stamp];
  126. resMsg = '任务成功! 已评论['+owner+','+sourceID+']<br/>-----剩余任务数:' + getJsonLength(queueList);
  127. console.debug(resMsg);
  128. popWindow(resMsg,(tTime+20)*1000);
  129. $('.popWindow').children().each(
  130. function(){
  131. if(this.innerHTML.indexOf("待评论任务数")>=0)
  132. this.innerHTML=("待评论任务数:"+getJsonLength(queueList));
  133. });
  134. }
  135. else{
  136. resMsg = '任务评论失败['+owner+','+sourceID+']'+"<br/>----原因:"+data.msg;
  137. console.debug(resMsg.replace(/<br\/>/,""));
  138. popWindow(resMsg,60000);
  139. if(data.msg.indexOf("您已经发表过评论")>=0){
  140. delete queueList[stamp];
  141. }
  142. }
  143. }
  144. });
  145. }

QingJ © 2025

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