From 297579597102d0a95d7971ef23d896a6152e7665 Mon Sep 17 00:00:00 2001 From: Index Date: Tue, 16 Jul 2024 22:48:50 -0500 Subject: [PATCH] feat: add event items json generator to dev page --- js/extra-pages.js | 41 +++++++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/js/extra-pages.js b/js/extra-pages.js index dc63b46..c7d9595 100644 --- a/js/extra-pages.js +++ b/js/extra-pages.js @@ -75,17 +75,21 @@ if (window.location.pathname.split('/')[3] === 'polyplus' && window.location.has
-
RUN TESTS
+
Tools
- -

will add later

+ +
+ + + +

-
DANGER ZONE!
+
Danger Zone!

Quickly clear specific locations of the extension's local data

@@ -234,7 +238,32 @@ if (window.location.pathname.split('/')[3] === 'polyplus' && window.location.has }); }); - chrome.storage.sync.getBytesInUse(['PolyPlus_Settings', 'PolyPlus_PinnedGames', 'PolyPlus_ItemWishlist'], function (sync) { + const GenerateEventItems = document.getElementById('generate-event-items') + GenerateEventItems.addEventListener('click', async function(){ + const EventItemsJSON = [] + const ItemIDs = GenerateEventItems.previousElementSibling.value.split(',') + for (let id of ItemIDs) { + const ItemDetails = (await (await fetch('https://api.polytoria.com/v1/store/' + id.trim())).json()) + EventItemsJSON.push({ + id: parseInt(id), + name: ItemDetails.name, + event: GenerateEventItems.previousElementSibling.previousElementSibling.value, + thumbnail: ItemDetails.thumbnail + }) + } + + console.log(EventItemsJSON) + + navigator.clipboard.writeText(JSON.stringify(EventItemsJSON, null, 2)) + .then(() => { + alert('Successfully copied generated event items JSON!') + }) + .catch(() => { + alert('Failure when trying to copy generated event items JSON.') + }) + }) + + chrome.storage.sync.getBytesInUse(['PolyPlus_Settings', 'PolyPlus_PinnedGames', 'PolyPlus_ItemWishlist', 'PolyPlus_TimePlayed', 'PolyPlus_AvatarSandboxOutfits'], function (sync) { chrome.storage.local.getBytesInUse(['PolyPlus_InventoryCache'], function(local){ document.getElementById('data-size').innerText = (sync + local).toLocaleString(); }) @@ -420,7 +449,7 @@ if (window.location.pathname.split('/')[3] === 'polyplus' && window.location.has } CheckForUpdatesButton.addEventListener('click', CheckForUpdates); - chrome.storage.sync.getBytesInUse(['PolyPlus_Settings', 'PolyPlus_PinnedGames', 'PolyPlus_ItemWishlist'], function (sync) { + chrome.storage.sync.getBytesInUse(['PolyPlus_Settings', 'PolyPlus_PinnedGames', 'PolyPlus_ItemWishlist', 'PolyPlus_TimePlayed', 'PolyPlus_AvatarSandboxOutfits'], function (sync) { chrome.storage.local.getBytesInUse(['PolyPlus_InventoryCache'], function(local){ document.getElementById('data-size').innerText = (sync + local).toLocaleString(); })