MediaWiki:Common.js: Difference between revisions

From AlphaX Wiki
Jump to navigation Jump to search
Created page with "(function () { if (localStorage.getItem("ageVerified") === "yes") { return; } var overlay = document.createElement("div"); overlay.style.position = "fixed"; overlay.style.top = "0"; overlay.style.left = "0"; overlay.style.width = "100%"; overlay.style.height = "100%"; overlay.style.background = "rgba(0,0,0,0.95)"; overlay.style.color = "white"; overlay.style.zIndex = "99999"; overlay.style.display = "flex"; ov..."
 
No edit summary
Line 1: Line 1:
(function () {
(function () {


     if (localStorage.getItem("ageVerified") === "yes") {
    const AGE_KEY = "ageVerifiedTime";
    const MAX_AGE = 30 * 24 * 60 * 60 * 1000;
 
    const saved = localStorage.getItem(AGE_KEY);
 
     if (saved && (Date.now() - saved < MAX_AGE)) {
         return;
         return;
     }
     }


     var overlay = document.createElement("div");
     const style = document.createElement("style");
     overlay.style.position = "fixed";
     style.innerHTML = `
    overlay.style.top = "0";
        #age-overlay{
    overlay.style.left = "0";
            position:fixed;
    overlay.style.width = "100%";
            top:0;
    overlay.style.height = "100%";
            left:0;
    overlay.style.background = "rgba(0,0,0,0.95)";
            width:100%;
    overlay.style.color = "white";
            height:100%;
    overlay.style.zIndex = "99999";
            backdrop-filter:blur(8px);
     overlay.style.display = "flex";
            background:rgba(0,0,0,0.8);
     overlay.style.alignItems = "center";
            display:flex;
     overlay.style.justifyContent = "center";
            align-items:center;
     overlay.style.fontFamily = "Arial, sans-serif";
            justify-content:center;
    overlay.style.textAlign = "center";
            z-index:999999;
            font-family:Arial,sans-serif;
        }
 
        #age-box{
            background:#111;
            color:white;
            padding:40px;
            border-radius:10px;
            max-width:420px;
            text-align:center;
            box-shadow:0 0 40px rgba(0,0,0,0.7);
        }
 
        #age-box h2{
            margin-top:0;
        }
 
        #age-buttons{
            margin-top:20px;
        }
 
        #age-buttons button{
            padding:12px 22px;
            margin:8px;
            font-size:16px;
            border:none;
            border-radius:6px;
            cursor:pointer;
        }
 
        #age-yes{
            background:#2ecc71;
            color:white;
        }
 
        #age-no{
            background:#e74c3c;
            color:white;
        }
 
        #age-links{
            margin-top:15px;
            font-size:12px;
            opacity:0.7;
        }
 
        #age-links a{
            color:#aaa;
            margin:0 8px;
        }
     `;
 
     document.head.appendChild(style);
 
     const overlay = document.createElement("div");
     overlay.id = "age-overlay";


     overlay.innerHTML = `
     overlay.innerHTML = `
         <div style="max-width:500px;padding:30px;">
         <div id="age-box">
 
             <h2>18+ Age Verification</h2>
             <h2>18+ Age Verification</h2>
             <p>This website contains adult content.</p>
             <p>This website contains adult content.</p>
             <p>You must be 18 years or older to enter.</p>
             <p>You must be at least <b>18 years old</b> to enter.</p>
 
            <div id="age-buttons">
                <button id="age-yes">I am 18+</button>
                <button id="age-no">Leave</button>
            </div>


             <button id="ageYes" style="padding:12px 25px;margin:10px;font-size:16px;cursor:pointer;">
             <div id="age-links">
                 I am 18+
                <a href="/index.php?title=Impressum">Impressum</a>
             </button>
                 <a href="/index.php?title=Datenschutz">Privacy</a>
             </div>


            <button id="ageNo" style="padding:12px 25px;margin:10px;font-size:16px;cursor:pointer;">
                Leave
            </button>
         </div>
         </div>
     `;
     `;
Line 38: Line 104:
     document.body.appendChild(overlay);
     document.body.appendChild(overlay);


     document.getElementById("ageYes").onclick = function () {
     document.getElementById("age-yes").onclick = function(){
         localStorage.setItem("ageVerified", "yes");
         localStorage.setItem(AGE_KEY, Date.now());
         overlay.remove();
         overlay.remove();
     };
     };


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


})();
})();

Revision as of 14:39, 15 March 2026

(function () {

    const AGE_KEY = "ageVerifiedTime";
    const MAX_AGE = 30 * 24 * 60 * 60 * 1000;

    const saved = localStorage.getItem(AGE_KEY);

    if (saved && (Date.now() - saved < MAX_AGE)) {
        return;
    }

    const style = document.createElement("style");
    style.innerHTML = `
        #age-overlay{
            position:fixed;
            top:0;
            left:0;
            width:100%;
            height:100%;
            backdrop-filter:blur(8px);
            background:rgba(0,0,0,0.8);
            display:flex;
            align-items:center;
            justify-content:center;
            z-index:999999;
            font-family:Arial,sans-serif;
        }

        #age-box{
            background:#111;
            color:white;
            padding:40px;
            border-radius:10px;
            max-width:420px;
            text-align:center;
            box-shadow:0 0 40px rgba(0,0,0,0.7);
        }

        #age-box h2{
            margin-top:0;
        }

        #age-buttons{
            margin-top:20px;
        }

        #age-buttons button{
            padding:12px 22px;
            margin:8px;
            font-size:16px;
            border:none;
            border-radius:6px;
            cursor:pointer;
        }

        #age-yes{
            background:#2ecc71;
            color:white;
        }

        #age-no{
            background:#e74c3c;
            color:white;
        }

        #age-links{
            margin-top:15px;
            font-size:12px;
            opacity:0.7;
        }

        #age-links a{
            color:#aaa;
            margin:0 8px;
        }
    `;

    document.head.appendChild(style);

    const overlay = document.createElement("div");
    overlay.id = "age-overlay";

    overlay.innerHTML = `
        <div id="age-box">

            <h2>18+ Age Verification</h2>

            <p>This website contains adult content.</p>
            <p>You must be at least <b>18 years old</b> to enter.</p>

            <div id="age-buttons">
                <button id="age-yes">I am 18+</button>
                <button id="age-no">Leave</button>
            </div>

            <div id="age-links">
                <a href="/index.php?title=Impressum">Impressum</a>
                <a href="/index.php?title=Datenschutz">Privacy</a>
            </div>

        </div>
    `;

    document.body.appendChild(overlay);

    document.getElementById("age-yes").onclick = function(){
        localStorage.setItem(AGE_KEY, Date.now());
        overlay.remove();
    };

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

})();