MediaWiki:Common.js: Difference between revisions
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 ( | 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; | ||
} | } | ||
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; | |||
overlay. | align-items:center; | ||
overlay. | 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 = ` | overlay.innerHTML = ` | ||
<div | <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 | <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> | </div> | ||
`; | `; | ||
| Line 38: | Line 104: | ||
document.body.appendChild(overlay); | document.body.appendChild(overlay); | ||
document.getElementById(" | document.getElementById("age-yes").onclick = function(){ | ||
localStorage.setItem( | localStorage.setItem(AGE_KEY, Date.now()); | ||
overlay.remove(); | overlay.remove(); | ||
}; | }; | ||
document.getElementById(" | 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";
};
})();