script fixes
This commit is contained in:
parent
411f2feb44
commit
cd5801dd7d
2 changed files with 3 additions and 7 deletions
|
@ -1,12 +1,8 @@
|
||||||
const nsfwOk = 'nsfw-ok';
|
const nsfwOk = 'nsfw-ok';
|
||||||
|
|
||||||
function alreadyYes() {
|
|
||||||
return localStorage.getItem(nsfwOk) == '1';
|
|
||||||
}
|
|
||||||
|
|
||||||
function dismiss() {
|
function dismiss() {
|
||||||
const dialog = document.getElementById('nsfw-dialog')!;
|
const dialog = document.getElementById('nsfw-dialog')!;
|
||||||
dialog.parentElement?.removeChild(dialog);
|
dialog.parentElement!.removeChild(dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
function yes() {
|
function yes() {
|
||||||
|
@ -15,7 +11,7 @@ function yes() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function setup() {
|
function setup() {
|
||||||
if (alreadyYes()) {
|
if (localStorage.getItem(nsfwOk)) {
|
||||||
dismiss();
|
dismiss();
|
||||||
} else {
|
} else {
|
||||||
document.getElementById('nsfw-yes')!.onclick = yes;
|
document.getElementById('nsfw-yes')!.onclick = yes;
|
||||||
|
|
|
@ -47,7 +47,7 @@ function setImage(id: string, src: string, href: string, cw: string): void {
|
||||||
function activateButton(button: HTMLInputElement, doPush = true): void {
|
function activateButton(button: HTMLInputElement, doPush = true): void {
|
||||||
setImage(button.id, button.value,
|
setImage(button.id, button.value,
|
||||||
button.dataset.link!,
|
button.dataset.link!,
|
||||||
button.dataset.warning!);
|
button.dataset.warning ?? '');
|
||||||
|
|
||||||
if (doPush) history.pushState(null, '', '#' + button.id);
|
if (doPush) history.pushState(null, '', '#' + button.id);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue