/* Developer & Debug Page Accessable at /my/settings/polyplus#dev and /my/settings/polyplus#debug */ document.title = 'Poly+ Debug - Polytoria'; const Version = chrome.runtime.getManifest().version; if (window.location.pathname.split('/')[3] === 'polyplus' && window.location.hash === '#dev') { document.addEventListener('DOMContentLoaded', function () { document.querySelector('#main-content .container').innerHTML = `

Poly+ Developer

This page is used by developers for debugging most data related things. It is unrecommended you modify any data on this page, but if you ever want to go ahead.

Version: v${Version}

Data Size: Loading byte(s)

Open GitHub

Created by Index

Beta Testers:

Set a value of the extension's local settings data

Quickly clear specific parts of the extension's local data

Quickly clear specific parts of the extension's local data


Tools

Danger Zone!

Quickly clear specific locations of the extension's local data

This will clear all local data associated with the extension

`; 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); document.getElementById('edit-setting').addEventListener('click', function () { const EditSettingName = document.getElementById('edit-setting-name'); const EditSettingValue = document.getElementById('edit-setting-value'); chrome.storage.sync.get(['PolyPlus_Settings'], function (result) { result = result.PolyPlus_Settings; let NewValue = EditSettingValue.value; switch (NewValue) { case 'true': NewValue = true; break; case 'false': NewValue = false; break; case 'null': NewValue = null; break; case 'undefined': NewValue = undefined; break; case parseInt(NewValue): NewValue = parseInt(NewValue); break; } result[EditSettingName.value] = NewValue; chrome.storage.sync.set({PolyPlus_Settings: result}, function () { alert('Successfully set: "' + EditSettingName.value + '" to ' + NewValue); }); }); }); document.getElementById('reset-settings').addEventListener('click', async function () { let Utilities = await import(chrome.runtime.getURL('resources/utils.js')); Utilities = Utilities.default; chrome.storage.sync.set({PolyPlus_Settings: Utilities.DefaultSettings}, function () { alert('Successfully reset settings to their defaults!'); }); }); document.getElementById('example-pinnedgames').addEventListener('click', function () { chrome.storage.sync.set({PolyPlus_PinnedGames: [6012, 3857, 2537]}, function () { alert('Successfully loaded example for Pinned Games!'); }); }); document.getElementById('example-bestfriends').addEventListener('click', function () { chrome.storage.sync.set({PolyPlus_BestFriends: [1, 2, 3]}, function () { alert('Successfully loaded example for Best Friends!'); }); }); document.getElementById('example-itemwishlist').addEventListener('click', function () { chrome.storage.sync.set({PolyPlus_ItemWishlist: [31495, 31493, 31492]}, function () { alert('Successfully loaded example for Item Wishlist!'); }); }); document.getElementById('clear-pinnedgames').addEventListener('click', function () { chrome.storage.sync.set({PolyPlus_PinnedGames: []}, function () { alert('Successfully cleared Pinned Games!'); }); }); document.getElementById('clear-bestfriends').addEventListener('click', function () { chrome.storage.sync.set({PolyPlus_BestFriends: []}, function () { alert('Successfully cleared Best Friends!'); }); }); document.getElementById('clear-itemwishlist').addEventListener('click', function () { chrome.storage.sync.set({PolyPlus_ItemWishlist: []}, function () { alert('Successfully cleared Item Wishlist!'); }); }); document.getElementById('delete-sync').addEventListener('click', function () { if (confirm("Are you sure you'd like to delete all sync data associated with the extension?") === false) { return; } chrome.storage.sync.clear(function () { alert('Successfully deleted all sync data associated with the extension!'); }); }); document.getElementById('delete-local').addEventListener('click', function () { if (confirm("Are you sure you'd like to delete all local data associated with the extension?") === false) { return; } chrome.storage.local.clear(function () { alert('Successfully deleted all local data associated with the extension!'); }); }); document.getElementById('delete-all-data').addEventListener('click', function () { if (confirm("Are you sure you'd like to delete all sync and local data associated with the extension?") === false) { return; } chrome.storage.sync.clear(function () { alert('Successfully deleted all sync data associated with the extension!'); }); chrome.storage.local.clear(function () { alert('Successfully deleted all local data associated with the extension!'); }); }); 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(); }) }); }); } else if (window.location.pathname.split('/')[3] === 'polyplus' && window.location.hash === '#debug') { document.addEventListener('DOMContentLoaded', function () { chrome.storage.sync.get(['PolyPlus_Settings', 'PolyPlus_PinnedGames', 'PolyPlus_BestFriends', 'PolyPlus_ItemWishlist', 'PolyPlus_AvatarSandboxOutfits', 'PolyPlus_TimePlayed'], function(sync) { chrome.storage.local.get(['PolyPlus_InventoryCache'], function(local){ document.querySelector('#main-content .container').innerHTML = `

Poly+ Debug

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:
${JSON.stringify((sync.PolyPlus_Settings || {}), null, 2) .replaceAll('\n','
') .replaceAll(' ', ' ') .replaceAll('\t', '    ')}
${JSON.stringify((sync.PolyPlus_PinnedGames || []), null, 2) .replaceAll('\n','
') .replaceAll(' ', ' ') .replaceAll('\t', '    ')}
${JSON.stringify((sync.PolyPlus_ItemWishlist || []), null, 2) .replaceAll('\n','
') .replaceAll(' ', ' ') .replaceAll('\t', '    ')}
${JSON.stringify((sync.PolyPlus_AvatarSandboxOutfits || []), null, 2) .replaceAll('\n','
') .replaceAll(' ', ' ') .replaceAll('\t', '    ')}
${JSON.stringify((sync.PolyPlus_TimePlayed || []), null, 2) .replaceAll('\n','
') .replaceAll(' ', ' ') .replaceAll('\t', '    ')}
${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', 'PolyPlus_TimePlayed', 'PolyPlus_AvatarSandboxOutfits'], function (sync) { chrome.storage.local.getBytesInUse(['PolyPlus_InventoryCache'], function(local){ document.getElementById('data-size').innerText = (sync + local).toLocaleString(); }) }); }) }) }); }