MediaWiki:Common.js
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
(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";
};
})();