gallery/script/nsfw-warning.ts

25 lines
468 B
TypeScript
Raw Normal View History

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