From e1c382be28a187702dc302a1cd6eedecd4d09295 Mon Sep 17 00:00:00 2001 From: zumbiepig <121742281+zumbiepig@users.noreply.github.com> Date: Sat, 31 Aug 2024 15:47:08 -0700 Subject: [PATCH] add toggle function --- src/resources/scripts/main.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/resources/scripts/main.ts b/src/resources/scripts/main.ts index 4bd9395..99de418 100644 --- a/src/resources/scripts/main.ts +++ b/src/resources/scripts/main.ts @@ -287,6 +287,18 @@ const mods = { storage.local.set('mods', mods); } }, + toggle: function (mod: string): void { + const mods: string[] = storage.local.get('mods') ?? []; + const modIndex = mods.indexOf(mod); + if (modIndex === -1) { + mods.push(mod); + mods.sort(); + storage.local.set('mods', mods); + } else { + mods.splice(modIndex, 1); + storage.local.set('mods', mods); + } + } }; const serviceworker = {