gallery/script/nsfw-warning.ts
2024-07-11 15:04:55 +02:00

24 lines
468 B
TypeScript

const nsfwOk = 'nsfw-ok';
function dismiss() {
const dialog = document.getElementById('nsfw-dialog')!;
dialog.parentElement!.removeChild(dialog);
}
function yes() {
localStorage.setItem(nsfwOk, '1');
dismiss();
}
function setup() {
if (localStorage.getItem(nsfwOk)) {
dismiss();
} else {
document.getElementById('nsfw-yes')!.onclick = yes;
// nsfw-no is a normal link
}
}
document.addEventListener('DOMContentLoaded', setup);
export {};