29 lines
530 B
TypeScript
29 lines
530 B
TypeScript
|
const nsfwOk = 'nsfw-ok';
|
||
|
|
||
|
function alreadyYes() {
|
||
|
return localStorage.getItem(nsfwOk) !== undefined;
|
||
|
}
|
||
|
|
||
|
function dismiss() {
|
||
|
let 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 {};
|