From d91f4d1ac79bd24768a03bc9cbb26867c586d484 Mon Sep 17 00:00:00 2001 From: pilar6195 Date: Mon, 1 Jul 2024 15:27:27 -0500 Subject: [PATCH] feat: prevent multiple instances of the script from running --- src/anilist-extras.user.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/anilist-extras.user.ts b/src/anilist-extras.user.ts index a711720..79bb50c 100644 --- a/src/anilist-extras.user.ts +++ b/src/anilist-extras.user.ts @@ -10,6 +10,14 @@ import '@/modules/modulesList'; /* Import Global Styles */ import globalStyles from '@/styles/global.scss'; +// @ts-expect-error - This is fine. +if (document.ALEXTRAS_LOADED) { + throw new Error('AniList Extras is already loaded. Ensure you are not running multiple instances of the script.'); +} + +// @ts-expect-error - This is fine. +document.ALEXTRAS_LOADED = true; + /* Add Global Styles to DOM */ addStyles(globalStyles);