Плагин ограничение 18+

zoxmen

Проверенные
Сообщения
20
Реакции
3
Баллы
140
faster ну или вот с куки и таймером, 30 дней живёт сессия:
Код:
<style>
#age-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
}
#age-box {
    background: #1f1f1f;
    color: #fff;
    padding: 30px;
    max-width: 420px;
    width: 90%;
    text-align: center;
    border-radius: 10px;
}
#age-box button {
    margin: 10px;
    padding: 10px 22px;
    font-size: 15px;
    cursor: pointer;
    border: none;
    border-radius: 6px;
}
#age-yes { background: #2ecc71; color: #000; }
#age-no { background: #e74c3c; color: #fff; }
</style>

<div id="age-overlay" style="display:none;">
    <div id="age-box">
        <h2>Подтвердите возраст</h2>
        <p>Форум содержит материалы 18+</p>
        <button id="age-yes">Мне есть 18</button>
        <button id="age-no">Мне нет 18</button>
    </div>
</div>

<script>
(function () {

    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 match = document.cookie.match(new RegExp('(^| )' + name + '=([^;]+)'));
        return match ? match[2] : null;
    }

    if (getCookie('age_verified') === 'yes') return;

    var overlay = document.getElementById('age-overlay');
    overlay.style.display = 'flex';

    document.getElementById('age-yes').onclick = function () {
        setCookie('age_verified', 'yes', 30); // ← 30 дней
        overlay.remove();
    };

    document.getElementById('age-no').onclick = function () {
        window.location.href = 'https://www.google.com';
    };

})();
</script>

Красавчик! Спасибо!
 
Современный облачный хостинг провайдер | Aéza
Назад
Сверху Снизу