CloudFlare Challenge Optimized

Automates solving Cloudflare challenges

当前为 2024-05-15 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name CloudFlare Challenge Optimized
  3. // @version 0.1
  4. // @author AstralRift
  5. // @description Automates solving Cloudflare challenges
  6. // @namespace https://greasyfork.org/users/1300060
  7. // @match https://challenges.cloudflare.com/*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. function attemptChallenge() {
  16. const stageSpan = document.querySelector("#cf-stage > div.ctp-checkbox-container > label > span");
  17. if (stageSpan) {
  18. stageSpan.click();
  19. return true;
  20. }
  21.  
  22. const verifyButton = document.querySelector("input[value='Verify you are human']");
  23. if (verifyButton) {
  24. verifyButton.click();
  25. return true;
  26. }
  27.  
  28. const checkboxLabel = document.querySelector('.ctp-checkbox-label');
  29. if (checkboxLabel) {
  30. checkboxLabel.click();
  31. return true;
  32. }
  33.  
  34. return false;
  35. }
  36.  
  37. let challengeSolved = attemptChallenge();
  38.  
  39. if (!challengeSolved) {
  40. const observer = new MutationObserver(() => {
  41. if (attemptChallenge()) {
  42. observer.disconnect();
  43. }
  44. });
  45. observer.observe(document.body, { childList: true, subtree: true });
  46.  
  47. const intervalId = setInterval(() => {
  48. if (attemptChallenge()) {
  49. clearInterval(intervalId);
  50. }
  51. }, 2000);
  52.  
  53. setTimeout(() => {
  54. clearInterval(intervalId);
  55. observer.disconnect();
  56. }, 60000);
  57. }
  58. })();