HacPai 模拟人工抢红包(内部)

https://hacpai.com/cr

目前為 2020-05-11 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name HacPai 模拟人工抢红包(内部)
  3. // @namespace https://github.com/adlered
  4. // @version 1.0.0
  5. var version = "1.0.0";
  6. // @description https://hacpai.com/cr
  7. // @author Adler
  8. // @connect hacpai.com/cr
  9. // @include https://hacpai.com/cr*
  10. // @require https://code.jquery.com/jquery-1.11.0.min.js
  11. // @note 20-05-11 1.0.0 初版发布
  12. // ==/UserScript==
  13.  
  14. var redpack_icon = "<svg style='fill: #D23F31' viewBox='0 0 32 32'> <path d='M11.273 12.766c-3.168-0.488-6.006-1.592-8.496-3.191l0.087 0.052v20.147c0.021 1.234 1.027 2.226 2.264 2.226 0 0 0 0 0 0h21.822c1.252-0.005 2.264-1.021 2.264-2.273 0 0 0 0 0-0v0-20.109c-2.405 1.556-5.246 2.664-8.298 3.133l-0.12 0.015c-0.559 2.141-2.476 3.696-4.756 3.696s-4.197-1.555-4.749-3.662l-0.008-0.034zM26.95 0h-21.822c-0 0-0 0-0 0-1.237 0-2.242 0.992-2.264 2.224l-0 0.002v3.12c2.32 2.174 5.299 3.67 8.607 4.156l0.087 0.011c0.803-1.705 2.506-2.863 4.48-2.863s3.678 1.159 4.468 2.833l0.013 0.030c3.396-0.5 6.375-1.999 8.703-4.184l-0.009 0.008v-3.063c0 0 0 0 0-0 0-1.252-1.012-2.268-2.263-2.273h-0z'></path> <path d='M19.33 11.529c-0.005-1.814-1.477-3.282-3.291-3.282-1.818 0-3.291 1.474-3.291 3.291s1.474 3.291 3.291 3.291v0c0 0 0 0 0 0 1.818 0 3.291-1.474 3.291-3.291 0-0.003 0-0.007 0-0.010v0.001z'></path></svg>";
  15. var avaliableRedpack = new Array();
  16.  
  17. (function() {
  18. log_init();
  19. init();
  20. run();
  21. listen();
  22. })();
  23.  
  24. function init() {
  25. $(".hongbao__item").each(function(index,domEle) {
  26. let dataId = $(domEle).attr("data-id");
  27. let unCatched = $(domEle).attr("style") === undefined;
  28. if (unCatched) {
  29. // 加入抢红包缓存表
  30. add(dataId);
  31. }
  32. });
  33. }
  34.  
  35. function run() {
  36. // 循环时间
  37. let delay = 3000;
  38.  
  39. setInterval(function() {
  40. let redpack = avaliableRedpack.pop();
  41. if (redpack !== undefined) {
  42. catchRedpack(redpack, randomDelay("1500-3000"));
  43. }
  44. }, delay);
  45. }
  46.  
  47. function listen() {
  48. // 循环时间
  49. let delay = 500;
  50. let lastest;
  51.  
  52. setInterval(function() {
  53. let item = $(".hongbao__item");
  54. let dataId = item.attr("data-id");
  55. let unCatched = item.attr("style") === undefined;
  56. if (lastest !== dataId) {
  57. if (unCatched) {
  58. // 加入抢红包缓存表
  59. add(dataId);
  60. }
  61. lastest = dataId;
  62. }
  63. }, delay);
  64. }
  65.  
  66. var catchTimes = 0;
  67. var catchCount = 0;
  68.  
  69. function catchRedpack(dataId, rand) {
  70. setTimeout(function() {
  71. $('*[data-id="' + dataId + '"]').click();
  72. setTimeout(function() {
  73. let got = $(".hongbao__count").text().replace(/[^0-9]/ig,"");
  74. $(".dialog").remove();
  75. let date = new Date(parseInt(dataId));
  76. let time = date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
  77. catchTimes++;
  78. let count = parseInt(got);
  79. if (!isNaN(count)) {
  80. catchCount += count;
  81. log(redpack_icon + " " + time + " 的红包抢到 " + got + " 积分,自动延时:" + rand + " ms;累计 " + catchTimes + " 次,共 " + catchCount + " 积分。");
  82. } else {
  83. log(redpack_icon + " " + time + " 的红包已抢到,自动延时:" + rand + " ms;累计 " + catchTimes + " 次。");
  84. }
  85. }, 2000);
  86. }, rand);
  87. }
  88.  
  89. function randomDelay(range) {
  90. // x 上限,y 下限
  91. let x = parseInt(range.split("-")[1]);
  92. let y = parseInt(range.split("-")[0]);
  93. let rand = parseInt(Math.random() * (x - y + 1) + y);
  94. return rand;
  95. }
  96.  
  97. function add(dataId) {
  98. // 加入抢红包缓存表
  99. console.info("已加入缓存:" + dataId);
  100. avaliableRedpack.push(dataId);
  101. }
  102.  
  103. function log_init() {
  104. $("#chatContent").after("<br><span class='chats__content' id='assistant'>" + redpack_icon + " 抢红包助手就绪</span>");
  105. }
  106.  
  107. function log(text) {
  108. $("#assistant").html(text);
  109. }
  110.  
  111. function logAppend(text, newline) {
  112. if (newline) {
  113. text = text + "<br><br>";
  114. }
  115. $("#assistant").html($("#assistant").html() + text);
  116. }

QingJ © 2025

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