gallery/script/nsfw-warning.ts

29 lines
525 B
TypeScript
Raw Normal View History

2023-09-06 19:17:21 -04:00
const nsfwOk = 'nsfw-ok';
function alreadyYes() {
return localStorage.getItem(nsfwOk) == '1';
2023-09-06 19:17:21 -04:00
}
function dismiss() {
2024-07-07 14:44:05 -04:00
const dialog = document.getElementById('nsfw-dialog')!;
2023-09-06 19:17:21 -04:00
dialog.parentElement?.removeChild(dialog);
}
function yes() {
localStorage.setItem(nsfwOk, '1');
dismiss();
}
function setup() {
if (alreadyYes()) {
dismiss();
} else {
document.getElementById('nsfw-yes')!.onclick = yes;
// nsfw-no is a normal link
}
}
document.addEventListener('DOMContentLoaded', setup);
export {};