Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <style>
- #overlay {
- position: fixed;
- top: 0;
- left: 0;
- width: 100%;
- height: 100%;
- background-color: rgba(0, 0, 0, 0.8);
- display: none; /* Initially hidden */
- justify-content: center;
- align-items: center;
- z-index: 1000;
- }
- #popup {
- background-color: white;
- border-radius: 8px;
- padding: 20px;
- text-align: center;
- width: 300px;
- box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
- }
- #popup h2 {
- margin-bottom: 20px;
- }
- .button {
- display: inline-block;
- padding: 10px 20px;
- margin: 10px;
- font-size: 16px;
- border: none;
- border-radius: 5px;
- cursor: pointer;
- transition: background-color 0.3s ease;
- }
- .button-yes {
- background-color: #e74c3c;
- color: white;
- }
- .button-yes:hover {
- background-color: #c0392b;
- }
- .button-no {
- background-color: #2ecc71;
- color: white;
- }
- .button-no:hover {
- background-color: #27ae60;
- }
- </style>
- <div id="overlay">
- <div id="popup">
- <h2>Вы бот?</h2>
- <button class="button button-yes" onclick="handleYes()">Да</button>
- <button class="button button-no" onclick="handleNo()">Нет</button>
- </div>
- </div>
- <script>
- function setCookie(name, value, days) {
- var date = new Date();
- date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
- document.cookie = name + "=" + value + "; expires=" + date.toUTCString() + "; path=/";
- }
- function getCookie(name) {
- var cookies = document.cookie.split('; ');
- for (var i = 0; i < cookies.length; i++) {
- var parts = cookies[i].split('=');
- if (parts[0] === name) return parts[1];
- }
- return null;
- }
- function handleYes() {
- alert('Боты не могут использовать этот сайт!');
- }
- function handleNo() {
- // Отправляем событие в Яндекс Метрику
- if (typeof ym !== 'undefined') {
- ym({{yandexMetrikaID}}, 'reachGoal', 'real_people'); // Замените {{yandexMetrikaID}} на ваш идентификатор счётчика и в Яндекс Метрике создаете JS-цель real_people для определения реальный человек к вам на сайт зашел или нет.
- }
- // Устанавливаем куки для предотвращения повторной проверки
- setCookie('isRealPerson', 'true', 30); // Куки действуют 30 дней
- // Убираем всплывающее окно и разрешаем пользоваться сайтом
- document.getElementById('overlay').style.display = 'none';
- document.body.style.overflow = 'auto';
- }
- // Проверяем куки, чтобы решить, показывать ли окно
- window.onload = function() {
- if (getCookie('isRealPerson') === 'true') {
- document.body.style.overflow = 'auto';
- } else {
- document.getElementById('overlay').style.display = 'flex';
- document.body.style.overflow = 'hidden';
- }
- };
- </script>
Advertisement
Add Comment
Please, Sign In to add comment