dati

自动答题

目前为 2018-09-28 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name dati
  3. // @name:zh-CN 大头答题
  4. // @namespace www.icycat.com
  5. // @description 自动答题
  6. // @description:zh-CN 检测大仙答案自动答题
  7. // @include https://www.douyu.com/1209
  8. // @version 1.0
  9. // @run-at document-end
  10. // ==/UserScript==
  11.  
  12.  
  13. var textTimer = setInterval(function() {
  14. textCheck();
  15. }, 1000);
  16.  
  17. function go(index) {
  18. clearInterval(textTimer);
  19. var liArray = $("div[class^='answerProblem'] ul li");
  20. if (liArray.length > 0) {
  21. $(liArray[index - 1]).trigger('click');
  22. console.log('答题完成,19分钟后自动刷新网页');
  23. setTimeout(function() {
  24. window.location.reload();
  25. }, 1140000);
  26. return;
  27. }
  28. setTimeout(() => {
  29. go(index)
  30. }, 50);
  31. }
  32.  
  33. function textCheck() {
  34. var user = $('[data-nn=37丶机器人]');
  35. if (user.length > 0) {
  36. var text = user[user.length - 1].parentNode.parentNode.querySelector('.chat-msg-item').innerText;
  37. text.substr(0, 1);
  38. console.log('检测到参考答案' + text.substr(0, 1));
  39. switch (text.substr(0, 1)) {
  40. case 'A':
  41. go(1);
  42. break;
  43. case 'B':
  44. go(2);
  45. break;
  46. case 'C':
  47. go(3);
  48. break;
  49. }
  50. }
  51. }