diff --git a/js/account/avatar-sandbox2.js b/js/account/avatar-sandbox2.js index cfc6f93..a4b8be9 100755 --- a/js/account/avatar-sandbox2.js +++ b/js/account/avatar-sandbox2.js @@ -293,10 +293,13 @@ async function FormatAvatar() { FormattedAvatar.tool = await FetchMesh(FormattedAvatar.tool); } - if (FormattedAvatar.face && typeof FormattedAvatar.face === 'number') { - FormattedAvatar.face = await FetchAsset(FormattedAvatar.face); - } else { - FormattedAvatar.face = 'https://c0.ptacdn.com/static/3dview/DefaultFace.png'; + if (FormattedAvatar.face === undefined) { FormattedAvatar.face = 'https://c0.ptacdn.com/static/3dview/DefaultFace.png'; } + if (!FormattedAvatar.face.startsWith('data:') && !FormattedAvatar.face.startsWith('http')) { + if (FormattedAvatar.face && typeof FormattedAvatar.face === 'number') { + FormattedAvatar.face = await FetchAsset(FormattedAvatar.face); + } else { + FormattedAvatar.face = 'https://c0.ptacdn.com/static/3dview/DefaultFace.png'; + } } if (typeof FormattedAvatar.shirt === 'number') { diff --git a/js/account/home.js b/js/account/home.js index 7cc4776..824b101 100755 --- a/js/account/home.js +++ b/js/account/home.js @@ -8,21 +8,26 @@ var BestFriendsData; let Utilities; -chrome.storage.sync.get(['PolyPlus_Settings'], async function (result) { - Settings = result.PolyPlus_Settings || Utilities.DefaultSettings; +(async () => { + Utilities = await import(chrome.runtime.getURL('resources/utils.js')); + Utilities = Utilities.default; - if (Settings.IRLPriceWithCurrency && Settings.IRLPriceWithCurrency.Enabled === true) { - IRLPrice(); - } - - if (Settings.HomeFriendCountOn === true) { - ShowFriendCount(); - } - - if (Settings.PinnedGamesOn === true || Settings.BestFriendsOn === true) { - Update(); - } -}); + chrome.storage.sync.get(['PolyPlus_Settings'], async function (result) { + Settings = Utilities.MergeObjects(result.PolyPlus_Settings || Utilities.DefaultSettings); + + if (Settings.IRLPriceWithCurrency && Settings.IRLPriceWithCurrency.Enabled === true) { + IRLPrice(); + } + + if (Settings.HomeFriendCountOn === true) { + ShowFriendCount(); + } + + if (Settings.PinnedGamesOn === true || Settings.BestFriendsOn === true) { + Update(); + } + }); +})(); let ContainerElement = `
`; diff --git a/js/store/item-view.js b/js/store/item-view.js index f8674ae..7953ac6 100755 --- a/js/store/item-view.js +++ b/js/store/item-view.js @@ -374,8 +374,8 @@ async function HoardersList(min, avatars) { Owners.push(...InitialOwners.inventories); // Get owners (up to 300, if needed) - if (InitialOwners.pages > 3) { - InitialOwners.pages = 3; + if (InitialOwners.pages > Utilities.Limits.HoardersListPages) { + InitialOwners.pages = Utilities.Limits.HoardersListPages; } if (InitialOwners.pages > 1 && OwnerPagesFetched < InitialOwners.pages) { for (let i = 1; i < InitialOwners.pages; i++) { diff --git a/resources/utils.js b/resources/utils.js index 80f7732..3f3ce85 100644 --- a/resources/utils.js +++ b/resources/utils.js @@ -103,7 +103,8 @@ export default { PinnedGames: 10, BestFriends: 15, ImprovedFrLists: 20, - ItemWishlist: 20 + ItemWishlist: 20, + HoardersListPages: 4 }, MeshTypes: ['hat', 'hair', 'head attachment', 'face accessory', 'neck accessory', 'head cover', 'back accessory', 'shoulder accessory', 'tool'], TextureTypes: ['shirt', 'pants', 'face'], @@ -235,5 +236,23 @@ export default { Script.remove(); }); Node.appendChild(Script); + }, + // MergeObjects function was written by ChatGPT cause I was lazy and it was awhile ago + MergeObjects: function(obj1, obj2) { + var mergedObj = {}; + + // Copy the values from obj1 to the mergedObj + for (var key in obj1) { + mergedObj[key] = obj1[key]; + } + + // Merge the values from obj2 into the mergedObj, favoring obj2 for non-existing keys in obj1 + for (var key in obj2) { + if (!obj1.hasOwnProperty(key)) { + mergedObj[key] = obj2[key]; + } + } + + return mergedObj; } }; diff --git a/settings.js b/settings.js index f074e23..4110b51 100644 --- a/settings.js +++ b/settings.js @@ -50,7 +50,7 @@ Elements.forEach((element) => { if (Select) { Select.addEventListener('change', function () { - if (Select.getAttribute('data-useValue') !== undefined) { + if (Select.getAttribute('data-useValue') !== null) { let Value = Select.options[Select.selectedIndex].value; if (!isNaN(Value)) { Value = parseInt(Value); @@ -150,7 +150,7 @@ Elements.forEach((element) => { function LoadCurrent() { chrome.storage.sync.get(['PolyPlus_Settings'], function (result) { - Settings = MergeObjects(result.PolyPlus_Settings || Utilities.DefaultSettings, Utilities.DefaultSettings); + Settings = Utilities.MergeObjects(result.PolyPlus_Settings || Utilities.DefaultSettings, Utilities.DefaultSettings); RecentSave = structuredClone(Settings) console.log('Current Settings: ', Settings); @@ -313,7 +313,7 @@ function LoadThemeJSON(string) { JSONTable[i] = ''; } } - Settings.ThemeCreator = MergeObjects(JSONTable, Utilities.DefaultSettings.ThemeCreator); + Settings.ThemeCreator = Utilities.MergeObjects(JSONTable, Utilities.DefaultSettings.ThemeCreator); Save(); console.log(JSONTable.length, JSONTable, 'applied'); document.getElementById('ThemeCreator').getElementsByTagName('button')[1].click(); @@ -326,25 +326,6 @@ function LoadThemeJSON(string) { } } -// MergeObjects function was written by ChatGPT cause I was lazy and it was awhile ago -function MergeObjects(obj1, obj2) { - var mergedObj = {}; - - // Copy the values from obj1 to the mergedObj - for (var key in obj1) { - mergedObj[key] = obj1[key]; - } - - // Merge the values from obj2 into the mergedObj, favoring obj2 for non-existing keys in obj1 - for (var key in obj2) { - if (!obj1.hasOwnProperty(key)) { - mergedObj[key] = obj2[key]; - } - } - - return mergedObj; -} - function AreIdentical(obj1, obj2) { if (obj1.length !== obj2.length) { return false } return JSON.stringify(obj1) === JSON.stringify(obj2)