Use history.replaceState ageVerified query and improve export-story script

This commit is contained in:
Bad Manners 2024-08-26 14:53:09 -03:00
parent 21a77ed254
commit fb30f1b416
16 changed files with 96 additions and 83 deletions

View file

@ -53,7 +53,6 @@ import { IconTriangleExclamation } from "./icons";
<AgeRestrictedScriptInline />
<script>
const ENABLE_VIEW_TRANSITIONS = false;
type AgeVerified = "true" | undefined;
const ageRestrictedModalSetup = () => {
@ -97,9 +96,6 @@ import { IconTriangleExclamation } from "./icons";
rejectButton.focus();
}
};
if (ENABLE_VIEW_TRANSITIONS) {
document.addEventListener("astro:page-load", ageRestrictedModalSetup);
} else {
ageRestrictedModalSetup();
}
ageRestrictedModalSetup();
</script>

View file

@ -1,4 +1,4 @@
---
---
<script is:inline>function a(){let b=document,c="#modal-age-restricted",d="true",e=b.querySelector("body > "+c),f="ageVerified",g="searchParams",h=localStorage;new URL(b.location)[g].get(f)===d&&(h[f]=d);e&&(h[f]===d?b.querySelectorAll("a[href][data-age-restricted]").forEach(x=>{let y=new URL(x.href);y[g].set(f,d);x.href=y.href}):((b.body.style.overflow="hidden"),b.querySelectorAll("body > :not("+c+")").forEach(x=>x.setAttribute("inert",d)),(e.style.display="block")))};document.addEventListener("astro:after-swap",a);a()</script>
<script is:inline>(function (){let b=document,c="#modal-age-restricted",d="true",e=b.querySelector("body > "+c),f="ageVerified",g="searchParams",h=localStorage,i=new URL(b.location),j=history;i[g].get(f)===d&&(h[f]=d,j&&(i[g].delete(f),j.replaceState({},"",i)));e&&(h[f]===d?b.querySelectorAll("a[href][data-age-restricted]").forEach(x=>{let y=new URL(x.href);y[g].set(f,d);x.href=y.href}):((b.body.style.overflow="hidden"),b.querySelectorAll("body > :not("+c+")").forEach(x=>x.setAttribute("inert",d)),(e.style.display="block")))})()</script>

View file

@ -5,7 +5,6 @@ import DarkModeScriptInline from "./DarkModeScriptInline.astro";
<DarkModeScriptInline />
<script>
const ENABLE_VIEW_TRANSITIONS = false;
type ColorScheme = "auto" | "dark" | "light" | undefined;
const colorSchemeSetup = () => {
@ -31,9 +30,6 @@ import DarkModeScriptInline from "./DarkModeScriptInline.astro";
button.setAttribute("aria-hidden", "false");
});
};
if (ENABLE_VIEW_TRANSITIONS) {
document.addEventListener("astro:page-load", colorSchemeSetup);
} else {
colorSchemeSetup();
}
colorSchemeSetup();
</script>

View file

@ -1,4 +1,4 @@
---
---
<script is:inline>function a(){var b="dark",c="auto",d="colorScheme",e=document.body.classList,f=localStorage,g=f&&f[d];g&&g!==c?g===b&&e.add(b):(f&&(f[d]=c),matchMedia("(prefers-color-scheme: dark)").matches&&e.add(b))};document.addEventListener("astro:after-swap",a);a()</script>
<script is:inline>(function (){var b="dark",c="auto",d="colorScheme",e=document.body.classList,f=localStorage,g=f&&f[d];g&&g!==c?g===b&&e.add(b):(f&&(f[d]=c),matchMedia("(prefers-color-scheme: dark)").matches&&e.add(b))})()</script>

View file

@ -123,8 +123,6 @@ const { link, instance, user, postId } = Astro.props;
</template>
<script>
const ENABLE_VIEW_TRANSITIONS = false;
interface MastodonPost {
link: string;
instance: string;
@ -322,9 +320,5 @@ const { link, instance, user, postId } = Astro.props;
loadCommentsButton.style.removeProperty("display");
}
if (ENABLE_VIEW_TRANSITIONS) {
document.addEventListener("astro:page-load", initCommentSection);
} else {
initCommentSection();
}
initCommentSection();
</script>