Auto Click Cloudflare Ignore & Proceed

Автоматически нажимает кнопку "Ignore & Proceed" в предупреждении Cloudflare

  1. // ==UserScript==
  2. // @name Auto Click Cloudflare Ignore & Proceed
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.3
  5. // @description Автоматически нажимает кнопку "Ignore & Proceed" в предупреждении Cloudflare
  6. // @author thebelg
  7. // @match *://*/*
  8. // @grant none
  9. // @license MIT
  10. // @run-at document-start
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. function clickIgnoreButton() {
  17. // Ищем кнопку по разным возможным селекторам
  18. const ignoreButtonSelectors = [
  19. 'button:contains("Ignore & Proceed")',
  20. 'a:contains("Ignore & Proceed")',
  21. 'button.ignore-button',
  22. 'a.ignore-button',
  23. 'button[class*="ignore"]',
  24. 'a[class*="ignore"]',
  25. '[onclick*="ignore"]',
  26. '[id*="ignore"]',
  27. '[class*="proceed"]'
  28. ];
  29.  
  30. // Перебираем селекторы и пытаемся найти и нажать на кнопку
  31. for (const selector of ignoreButtonSelectors) {
  32. try {
  33. // Поиск по тексту содержимого
  34. const buttonsByText = Array.from(document.querySelectorAll('button, a, input[type="button"], input[type="submit"]'))
  35. .filter(el => el.textContent && el.textContent.includes('Ignore') && el.textContent.includes('Proceed'));
  36.  
  37. if (buttonsByText.length > 0) {
  38. buttonsByText[0].click();
  39. console.log('Clicked ignore button by text content');
  40. return true;
  41. }
  42.  
  43. // Поиск по селектору
  44. const buttons = document.querySelectorAll(selector);
  45. if (buttons.length > 0) {
  46. buttons[0].click();
  47. console.log('Clicked ignore button by selector: ' + selector);
  48. return true;
  49. }
  50. } catch (e) {
  51. // Игнорируем ошибки селекторов
  52. }
  53. }
  54.  
  55. return false;
  56. }
  57.  
  58. // Функция, которая будет вызываться несколько раз для попытки нажатия на кнопку
  59. function attemptToClick() {
  60. if (clickIgnoreButton()) {
  61. console.log('Successfully clicked the ignore button');
  62. } else {
  63. console.log('Button not found yet');
  64. }
  65. }
  66.  
  67. // Запускаем попытки клика как можно раньше и часто
  68. // Начинаем с минимальной задержки и увеличиваем интервал
  69. for (let i = 0; i < 5; i++) {
  70. setTimeout(attemptToClick, 50 * i); // Первые попытки - очень быстро (50, 100, 150, 200, 250 мс)
  71. }
  72.  
  73. for (let i = 0; i < 10; i++) {
  74. setTimeout(attemptToClick, 300 + 100 * i); // Следующие попытки с интервалом в 100 мс
  75. }
  76.  
  77. // Запускаем при загрузке DOM для надежности
  78. document.addEventListener('DOMContentLoaded', function() {
  79. attemptToClick();
  80. // Еще несколько попыток после загрузки DOM
  81. setTimeout(attemptToClick, 50);
  82. setTimeout(attemptToClick, 100);
  83. setTimeout(attemptToClick, 200);
  84. });
  85.  
  86. // Установим MutationObserver для отслеживания появления кнопки в динамически загружаемом контенте
  87. function setupObserver() {
  88. if (!document.body) return;
  89.  
  90. const observer = new MutationObserver(function(mutations) {
  91. for (const mutation of mutations) {
  92. if (mutation.addedNodes && mutation.addedNodes.length > 0) {
  93. // Если были добавлены новые узлы, пробуем нажать на кнопку
  94. attemptToClick();
  95. }
  96. }
  97. });
  98.  
  99. observer.observe(document.body, {
  100. childList: true,
  101. subtree: true
  102. });
  103. }
  104.  
  105. // Запускаем наблюдатель как можно раньше
  106. if (document.body) setupObserver();
  107. else document.addEventListener('DOMContentLoaded', setupObserver);
  108. })();