gallery/script/nsfw-warning.ts

21 lines
437 B
TypeScript
Raw Normal View History

2023-09-06 19:17:21 -04:00
const nsfwOk = 'nsfw-ok';
2024-08-05 17:36:30 -04:00
const dialog = document.getElementById('nsfw-dialog')! as HTMLDialogElement;
2023-09-06 19:17:21 -04:00
function yes() {
localStorage.setItem(nsfwOk, '1');
2024-08-05 17:36:30 -04:00
dialog.close();
2023-09-06 19:17:21 -04:00
}
function setup() {
2024-08-05 17:36:30 -04:00
if (!localStorage.getItem(nsfwOk)) {
(dialog.querySelector('#nsfw-yes') as HTMLElement).onclick = yes;
2023-09-06 19:17:21 -04:00
// nsfw-no is a normal link
2024-08-05 17:36:30 -04:00
dialog.showModal();
2023-09-06 19:17:21 -04:00
}
}
document.addEventListener('DOMContentLoaded', setup);
export {};