CloudFlare Challenge Optimized

Automates solving Cloudflare Challenges with optimal performance and maintainability

  1. // ==UserScript==
  2. // @name CloudFlare Challenge Optimized
  3. // @version 0.3
  4. // @description Automates solving Cloudflare Challenges with optimal performance and maintainability
  5. // @author AstralRift
  6. // @namespace https://gf.qytechs.cn/users/1300060
  7. // @match https://challenges.cloudflare.com/*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. let observer = null;
  16. let intervalId = null;
  17.  
  18. function attemptChallenge() {
  19. const targets = [
  20. "#cf-stage > div.ctp-checkbox-container > label > span",
  21. "input[value='Verify you are human']",
  22. ".ctp-checkbox-label"
  23. ];
  24.  
  25. for (let selector of targets) {
  26. const element = document.querySelector(selector);
  27. if (element) {
  28. element.click();
  29. return true;
  30. }
  31. }
  32. return false;
  33. }
  34.  
  35. function setupObserver() {
  36. observer = new MutationObserver(() => {
  37. if (attemptChallenge()) {
  38. disconnectObserver();
  39. clearInterval(intervalId);
  40. }
  41. });
  42.  
  43. observer.observe(document.body, { childList: true, subtree: true });
  44. }
  45.  
  46. function disconnectObserver() {
  47. if (observer) {
  48. observer.disconnect();
  49. observer = null;
  50. }
  51. }
  52.  
  53. function setupInterval() {
  54. const intervalFunction = () => {
  55. if (attemptChallenge()) {
  56. clearInterval(intervalId);
  57. disconnectObserver();
  58. }
  59. };
  60.  
  61. intervalId = setInterval(intervalFunction, 1000);
  62.  
  63. setTimeout(() => {
  64. clearInterval(intervalId);
  65. disconnectObserver();
  66. }, 60000);
  67. }
  68.  
  69. function handleChallenge() {
  70. if (!attemptChallenge()) {
  71. setupObserver();
  72. setupInterval();
  73. }
  74. }
  75.  
  76. handleChallenge();
  77. })();

QingJ © 2025

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