From eb644e8f1e3cd8cb9b8629ba446ff1045837c967 Mon Sep 17 00:00:00 2001 From: Index Date: Mon, 1 Jul 2024 21:48:23 -0500 Subject: [PATCH] minor: reorder debug page --- js/extra-pages.js | 104 +++++++++++++++++++++++++++++++--------------- 1 file changed, 70 insertions(+), 34 deletions(-) diff --git a/js/extra-pages.js b/js/extra-pages.js index b0db59c..cf91549 100644 --- a/js/extra-pages.js +++ b/js/extra-pages.js @@ -266,11 +266,31 @@ if (window.location.pathname.split('/')[3] === 'polyplus' && window.location.has

This page is used for accessing most data-related objects stored by the extension.

-
-
+
+
+
+

Version: v${Version}

+

Data Size: Loading byte(s)

+ + Open GitHub +
+
+
+ Created by Index +

+ Beta Testers: + +
+
+
@@ -280,41 +300,15 @@ if (window.location.pathname.split('/')[3] === 'polyplus' && window.location.has .replaceAll('\n','
') .replaceAll(' ', ' ') .replaceAll('\t', '    ')} -
-
- -
-
- ${JSON.stringify((local.PolyPlus_InventoryCache || {data: [], requested: "never"}), null, 2) - .replaceAll('\n','
') - .replaceAll(' ', ' ') - .replaceAll('\t', '    ')} -
-
-
-
-
-
-
-

Version: v${Version}

-

Data Size: Loading byte(s)

- - Open GitHub -
-
@@ -330,8 +324,9 @@ if (window.location.pathname.split('/')[3] === 'polyplus' && window.location.has
@@ -344,10 +339,51 @@ if (window.location.pathname.split('/')[3] === 'polyplus' && window.location.has
+
+ +
+
+ ${JSON.stringify((local.PolyPlus_InventoryCache || {data: [], requested: "never"}), null, 2) + .replaceAll('\n','
') + .replaceAll(' ', ' ') + .replaceAll('\t', '    ')} +
+
+
`; + const CheckForUpdatesButton = document.getElementById('check-for-updates'); + function CheckForUpdates() { + CheckForUpdatesButton.removeEventListener('click', CheckForUpdates); + CheckForUpdatesButton.disabled = true; + fetch('https://polyplus.vercel.app/data/version.json') + .then((response) => { + if (!response.ok) { + throw new Error('Network not ok'); + } + return response.json(); + }) + .then((data) => { + if (data.version === Version || Math.floor((data.version - Version) * 10) === 0) { + CheckForUpdatesButton.innerText = 'No updates available'; + } else { + CheckForUpdatesButton.innerText = Math.floor((data.version - Version) * 10) + ' updates available'; + } + }) + .catch((error) => { + console.log(error); + }); + } + CheckForUpdatesButton.addEventListener('click', CheckForUpdates); + chrome.storage.sync.getBytesInUse(['PolyPlus_Settings', 'PolyPlus_PinnedGames', 'PolyPlus_ItemWishlist'], function (sync) { chrome.storage.local.getBytesInUse(['PolyPlus_InventoryCache'], function(local){ document.getElementById('data-size').innerText = (sync + local).toLocaleString();