CloudFlare Challenge Optimized

Automates solving Cloudflare Challenges with optimal performance and maintainability

目前为 2024-05-16 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name CloudFlare Challenge Optimized
  3. // @version 0.2
  4. // @description Automates solving Cloudflare Challenges with optimal performance and maintainability
  5. // @author AstralRift
  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 targets = [
  17. "#cf-stage > div.ctp-checkbox-container > label > span",
  18. "input[value='Verify you are human']",
  19. ".ctp-checkbox-label"
  20. ];
  21.  
  22. for (let selector of targets) {
  23. const element = document.querySelector(selector);
  24. if (element) {
  25. element.click();
  26. return true;
  27. }
  28. }
  29. return false;
  30. }
  31.  
  32. function setupObserver() {
  33. const observer = new MutationObserver(mutations => {
  34. if (attemptChallenge()) {
  35. observer.disconnect();
  36. }
  37. });
  38.  
  39. observer.observe(document.body, { childList: true, subtree: true });
  40. }
  41.  
  42. function setupInterval() {
  43. const intervalId = setInterval(() => {
  44. if (attemptChallenge()) {
  45. clearInterval(intervalId);
  46. }
  47. }, 2000);
  48.  
  49. setTimeout(() => {
  50. clearInterval(intervalId);
  51. observer.disconnect();
  52. }, 60000);
  53. }
  54.  
  55. function handleChallenge() {
  56. if (!attemptChallenge()) {
  57. setupObserver();
  58. setupInterval();
  59. }
  60. }
  61.  
  62. handleChallenge();
  63. })();