28 lines
525 B
TypeScript
28 lines
525 B
TypeScript
const nsfwOk = 'nsfw-ok';
|
|
|
|
function alreadyYes() {
|
|
return localStorage.getItem(nsfwOk) == '1';
|
|
}
|
|
|
|
function dismiss() {
|
|
const dialog = document.getElementById('nsfw-dialog')!;
|
|
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 {};
|