VKirill

Untitled

Jan 4th, 2025
317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.73 KB | None | 0 0
  1. <style>
  2. #overlay {
  3. position: fixed;
  4. top: 0;
  5. left: 0;
  6. width: 100%;
  7. height: 100%;
  8. background-color: rgba(0, 0, 0, 0.8);
  9. display: none; /* Initially hidden */
  10. justify-content: center;
  11. align-items: center;
  12. z-index: 1000;
  13. }
  14.  
  15. #popup {
  16. background-color: white;
  17. border-radius: 8px;
  18. padding: 20px;
  19. text-align: center;
  20. width: 300px;
  21. box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  22. }
  23.  
  24. #popup h2 {
  25. margin-bottom: 20px;
  26. }
  27.  
  28. .button {
  29. display: inline-block;
  30. padding: 10px 20px;
  31. margin: 10px;
  32. font-size: 16px;
  33. border: none;
  34. border-radius: 5px;
  35. cursor: pointer;
  36. transition: background-color 0.3s ease;
  37. }
  38.  
  39. .button-yes {
  40. background-color: #e74c3c;
  41. color: white;
  42. }
  43.  
  44. .button-yes:hover {
  45. background-color: #c0392b;
  46. }
  47.  
  48. .button-no {
  49. background-color: #2ecc71;
  50. color: white;
  51. }
  52.  
  53. .button-no:hover {
  54. background-color: #27ae60;
  55. }
  56. </style>
  57. <div id="overlay">
  58. <div id="popup">
  59. <h2>Вы бот?</h2>
  60. <button class="button button-yes" onclick="handleYes()">Да</button>
  61. <button class="button button-no" onclick="handleNo()">Нет</button>
  62. </div>
  63. </div>
  64.  
  65. <script>
  66. function setCookie(name, value, days) {
  67. var date = new Date();
  68. date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
  69. document.cookie = name + "=" + value + "; expires=" + date.toUTCString() + "; path=/";
  70. }
  71.  
  72. function getCookie(name) {
  73. var cookies = document.cookie.split('; ');
  74. for (var i = 0; i < cookies.length; i++) {
  75. var parts = cookies[i].split('=');
  76. if (parts[0] === name) return parts[1];
  77. }
  78. return null;
  79. }
  80.  
  81. function handleYes() {
  82. alert('Боты не могут использовать этот сайт!');
  83. }
  84.  
  85. function handleNo() {
  86. // Отправляем событие в Яндекс Метрику
  87. if (typeof ym !== 'undefined') {
  88. ym({{yandexMetrikaID}}, 'reachGoal', 'real_people'); // Замените {{yandexMetrikaID}} на ваш идентификатор счётчика и в Яндекс Метрике создаете JS-цель real_people для определения реальный человек к вам на сайт зашел или нет.
  89. }
  90.  
  91. // Устанавливаем куки для предотвращения повторной проверки
  92. setCookie('isRealPerson', 'true', 30); // Куки действуют 30 дней
  93.  
  94. // Убираем всплывающее окно и разрешаем пользоваться сайтом
  95. document.getElementById('overlay').style.display = 'none';
  96. document.body.style.overflow = 'auto';
  97. }
  98.  
  99. // Проверяем куки, чтобы решить, показывать ли окно
  100. window.onload = function() {
  101. if (getCookie('isRealPerson') === 'true') {
  102. document.body.style.overflow = 'auto';
  103. } else {
  104. document.getElementById('overlay').style.display = 'flex';
  105. document.body.style.overflow = 'hidden';
  106. }
  107. };
  108. </script>
Advertisement
Add Comment
Please, Sign In to add comment