-
-
-
Clear Specific Data Locations
-
Quickly clear specific locations of the extension's local data
-
-
Delete Sync Storage (primary, storage is backed up to Google account)
-
Delete Local Storage (secondary, storage is only on local device)
+
+
+
+
+
Version: v${Version}
+
Data Size: Loading byte(s)
+
Check for Updates
+
Open GitHub
+
+
+
+ Created by
Index
+
+ Beta Testers:
+
+
+
+
Edit Setting Value
+
Set a value of the extension's local settings data
+
+
+
+ Submit
+
+
+
Load Example Data
+
Quickly clear specific parts of the extension's local data
+
+ Load Example Pinned Games
+ Load Example Best Friends
+ Load Example Item Wishlist
+
+
+
Clear Specific Local Data
+
Quickly clear specific parts of the extension's local data
+
+ Reset Settings to Defaults
+ Clear Pinned Games
+ Clear Best Friends
+ Clear Item Wishlist
+
+
+
+
+
+
+
+
Test "IRL Price with Brick Count"
+
will add later
+
+
+
+
+
+
+
+
+
Clear Specific Data Locations
+
Quickly clear specific locations of the extension's local data
+
+ Delete Sync Storage (primary, storage is backed up to Google account)
+ Delete Local Storage (secondary, storage is only on local device)
+
+
+
Delete All Data
+
This will clear all local data associated with the extension
+
Delete All Data
+
-
-
Delete All Data
-
This will clear all local data associated with the extension
-
Delete All Data
-
-
-`
+ `
-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
+ 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)});
}
- result[EditSettingName.value] = NewValue
+ CheckForUpdatesButton.addEventListener('click', CheckForUpdates);
- chrome.storage.sync.set({ 'PolyPlus_Settings': result }, function() {
- alert('Successfully set: "' + EditSettingName.value + '" to ' + NewValue)
+ 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('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-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-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('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-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-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('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-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-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!')
- });
-});
+ 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!')
+ });
+ });
-chrome.storage.sync.getBytesInUse(["PolyPlus_Settings", "PolyPlus_PinnedGames", "PolyPlus_BestFriends", "PolyPlus_ItemWishlist"], function(bytes){
- document.getElementById('data-size').innerText = bytes.toLocaleString()
-});
\ No newline at end of file
+ chrome.storage.sync.getBytesInUse(["PolyPlus_Settings", "PolyPlus_PinnedGames", "PolyPlus_BestFriends", "PolyPlus_ItemWishlist"], function(bytes){
+ document.getElementById('data-size').innerText = bytes.toLocaleString()
+ });
+ })
+}
\ No newline at end of file
diff --git a/js/everywhere.js b/js/everywhere.js
index af395e6..111378c 100755
--- a/js/everywhere.js
+++ b/js/everywhere.js
@@ -1,5 +1,5 @@
var Settings;
-let Theme = null;
+let Theme = ``;
(async () => {
let Utilities = await import(chrome.runtime.getURL('resources/utils.js'));
@@ -11,7 +11,7 @@ let Theme = null;
Settings = MergeObjects(RawSettings || Utilities.DefaultSettings, Utilities.DefaultSettings);
// If theme exists, create a style element to represent it
- if (Settings.ThemeCreatorOn && Settings.ThemeCreatorOn === true) {
+ if (Settings.ThemeCreator.Enabled && Settings.ThemeCreator.Enabled === true) {
switch (Settings.ThemeCreator.BGImageSize) {
case 0:
Settings.ThemeCreator.BGImageSize = 'fit'
@@ -111,43 +111,57 @@ let Theme = null;
}
`
}
-
- // Credit to @SK-Fast (also known as DevPixels) for the improved loading code (taken from his original Poly+, and reformatted to Index Poly+)
- const ThemeBlob = new Blob([Theme], { type: 'text/css' })
- const ThemeURL = URL.createObjectURL(ThemeBlob)
- document.head.innerHTML += `
`
});
+
+ if (Settings.HideUserAdsOn === true) {
+ if (Settings.HideUserAdsOn.Banners === true) {
+ Theme += `
+ div[style^="max-width: 728px;"]:has(.text-center a[href^="/ads/"]) {
+ display: none;
+ }
+ `
+ }
+
+ if (Settings.HideUserAdsOn.Rectangles === true) {
+ Theme += `
+ div[style^="max-width: 300px;"]:has(.text-center a[href^="/ads/"]) {
+ display: none;
+ }
+ `
+ }
+ }
+
+ if (Settings.HideNotifBadgesOn === true) {
+ Theme += `
+ .notif-nav .notif-sidebar {
+ display: none;
+ }
+ `
+ }
+
+ // Credit to @SK-Fast (also known as DevPixels) for the improved loading code (taken from his original Poly+, and reformatted to Index Poly+)
+ const ThemeBlob = new Blob([Theme], { type: 'text/css' })
+ const ThemeURL = URL.createObjectURL(ThemeBlob)
+ document.head.innerHTML += `
`
document.addEventListener('DOMContentLoaded', async function() {
if (document.getElementsByClassName('card-header')[0] && document.getElementsByClassName('card-header')[0].innerText === ' Page not found') {
return
}
-
- /*
- // Check if Theme Exists, if so Load It
- if (Settings.ThemeCreatorOn && Settings.ThemeCreatorOn === true) {
- if (!(Settings.ThemeCreator.WebsiteLogo === null)) {
- document.querySelector('.nav-sidebar img').setAttribute('src', Settings.ThemeCreator.WebsiteLogo)
- }
- }
- if (Settings.ThemeCreatorOn && Settings.ThemeCreatorOn === true && Theme != null) {
- document.body.prepend(Theme)
- }
- */
-
- // Define Data
- const UserData = {
- ID: document.querySelector('.text-reset.text-decoration-none[href^="/users/"]').getAttribute('href').split('/')[2],
- Bricks: document.querySelector('.brickBalanceCont').innerText.replace(/\s+/g,'')
- }
-
- window.localStorage.setItem('account_info', JSON.stringify(UserData))
+
+ Utilities.InjectResource('getUserDetails')
document.body.setAttribute('data-URL', window.location.pathname)
- if (Settings.IRLPriceWithCurrencyOn === true) {
- const IRLResult = await Utilities.CalculateIRL(UserData.Bricks, Settings.IRLPriceWithCurrencyCurrency)
- const BrickBalanceCount = [document.querySelector('.text-success .brickBalanceCount'), document.querySelector('.text-success .brickBalanceCont')]
- BrickBalanceCount.forEach(element => {element.innerHTML += ` (${IRLResult.icon}${IRLResult.result} ${IRLResult.display})`});
+ const UserData = JSON.parse(window.localStorage.getItem('p+account_info'))
+
+ if (Settings.IRLPriceWithCurrency.Enabled === true) {
+ const IRLResult = await Utilities.CalculateIRL(document.querySelector('.brickBalanceCont').innerText.replace(/\s+/g,''), Settings.IRLPriceWithCurrency.Currency)
+ // Desktop
+ document.querySelector('.text-success .brickBalanceCount').innerHTML += ` (${IRLResult.icon}${IRLResult.result} ${IRLResult.display})`
+
+ // Mobile
+ document.querySelector('.text-success .brickBalanceCont').innerHTML += ` (${IRLResult.icon}${IRLResult.result} ${IRLResult.display})`
+ //document.querySelector('.text-success .brickBalanceCont').innerHTML += `
(${IRLResult.icon}${IRLResult.result} ${IRLResult.display})
`
}
if (Settings.ModifyNavOn && Settings.ModifyNavOn === true) {
@@ -161,6 +175,12 @@ let Theme = null;
}
}
}
+
+ /*
+ if (Settings.HideUserAdsOn === true) {
+ Array.from(document.querySelectorAll('.text-center:has(a[href^="/ads"])')).forEach(ad => {ad.remove()})
+ }
+ */
if (Settings.HideNotifBadgesOn === true) {
document.getElementsByClassName('notif-nav notif-sidebar').forEach(element => {element.remove();});
diff --git a/js/guilds.js b/js/guilds.js
index dbc9c61..89fec4e 100644
--- a/js/guilds.js
+++ b/js/guilds.js
@@ -6,7 +6,7 @@ let Utilities;
chrome.storage.sync.get(['PolyPlus_Settings'], function(result){
Settings = result.PolyPlus_Settings
- if (Settings.IRLPriceWithCurrencyOn === true) {
+ if (Settings.IRLPriceWithCurrency.Enabled === true) {
(async () => {
Utilities = await import(chrome.runtime.getURL('resources/utils.js'));
Utilities = Utilities.default
@@ -26,7 +26,7 @@ chrome.storage.sync.get(['PolyPlus_Settings'], function(result){
async function IRLPrice(item) {
const Price = item.getElementsByClassName('text-success')[0]
if (Price !== undefined && Price.innerText !== "Free") {
- const IRLResult = await Utilities.CalculateIRL(Price.innerText, Settings.IRLPriceWithCurrencyCurrency)
+ const IRLResult = await Utilities.CalculateIRL(Price.innerText, Settings.IRLPriceWithCurrency.Currency)
let Span = document.createElement('span')
Span.classList = 'text-muted polyplus-price-tag'
@@ -40,7 +40,7 @@ const observer = new MutationObserver(async function (list){
for (const record of list) {
for (const element of record.addedNodes) {
if (element.tagName === "DIV" && element.classList.value === 'col-auto mb-3') {
- if (Settings.IRLPriceWithCurrencyOn === true) {
+ if (Settings.IRLPriceWithCurrency.Enabled === true) {
IRLPrice(element)
}
}
diff --git a/js/op-comments.js b/js/op-comments.js
index e885f62..11a89b9 100755
--- a/js/op-comments.js
+++ b/js/op-comments.js
@@ -30,7 +30,6 @@
Observer.observe(Comments, {attributes: false, childList: true, subtree: false})
const LoadCreatorTag = function(element) {
- console.log(element)
let NameElement = element.querySelector('.text-reset[href^="/users/"]')
if (Type === 'guilds') {
NameElement = element.querySelector('[class^="userlink-"][href^="/users/"]')
diff --git a/js/places/place-edit.js b/js/places/place-edit.js
index 3d0960c..790b427 100755
--- a/js/places/place-edit.js
+++ b/js/places/place-edit.js
@@ -95,13 +95,13 @@ function RequestGameProfile() {
async function CopyOwnedPlace() {
console.log('ran function')
if (PlaceData === null) {
- PlaceData = await fetch('https://api.polytoria.com/v1/places/' + PlaceID)
+ PlaceData = await fetch('https://api.polytoria.com/v1/places/' + 2640)
PlaceData = await PlaceData.json()
}
- if (PlaceData.creator.id !== parseInt(JSON.parse(window.localStorage.getItem('account_info')).ID)) {
+ if (PlaceData.creator.id !== parseInt(JSON.parse(window.localStorage.getItem('p+account_info')).ID)) {
console.log('returned')
- return
+ //return
}
const DIV = document.createElement('div')
diff --git a/js/places/place-view.js b/js/places/place-view.js
index 1b5a6f5..41baf83 100644
--- a/js/places/place-view.js
+++ b/js/places/place-view.js
@@ -1,5 +1,5 @@
const PlaceID = window.location.pathname.split('/')[2]
-const UserID = JSON.parse(window.localStorage.getItem('account_info')).ID
+const UserID = JSON.parse(window.localStorage.getItem('p+account_info')).ID
const GameCreator = document.querySelector('#main-content .card-body .col div.text-muted a[href^="/users/"]').getAttribute('href').split('/')[2]
let Utilities;
@@ -65,7 +65,7 @@ const Gamepasses = Array.from(GamepassesTab.getElementsByClassName('card')) || [
}
}
- if (Settings.IRLPriceWithCurrencyOn === true) {
+ if (Settings.IRLPriceWithCurrency.Enabled === true) {
IRLPrice()
}
@@ -370,7 +370,7 @@ async function IRLPrice() {
const Gamepasses = document.querySelector('#gamepasses-tabpane .row.flex-row').children
for (let gamepass of Gamepasses) {
const Price = gamepass.getElementsByClassName('text-success')[0]
- const IRLResult = await Utilities.CalculateIRL(Price.innerText, Settings.IRLPriceWithCurrencyCurrency)
+ const IRLResult = await Utilities.CalculateIRL(Price.innerText, Settings.IRLPriceWithCurrency.Currency)
let Span = document.createElement('span')
Span.classList = 'text-muted polyplus-price-tag'
diff --git a/js/store/item-view.js b/js/store/item-view.js
index c0d7510..c35705e 100755
--- a/js/store/item-view.js
+++ b/js/store/item-view.js
@@ -1,5 +1,6 @@
const ItemID = window.location.pathname.split('/')[2]
const ItemType = document.querySelector('.row .badge').innerHTML
+console.log(ItemType)
var Settings;
var ItemWishlist;
@@ -7,6 +8,7 @@ var PurchaseBtn;
var WishlistBtn;
var ItemOwned;
var InitialOwners;
+var OwnerPagesFetched = 0;
var Utilities;
@@ -23,7 +25,13 @@ var Utilities;
}
ItemOwned = (PurchaseBtn.innerText === ' Item owned' || document.querySelector('.btn[onclick="sellItem()"]') !== null)
- if (Settings.IRLPriceWithCurrencyOn === true && ItemOwned === false) {
+ if (PurchaseBtn.getAttribute('data-seller-name')) {
+ PurchaseBtn.setAttribute('data-bs-toggle', 'tooltip')
+ PurchaseBtn.setAttribute('data-bs-title', 'Sold by ' + PurchaseBtn.getAttribute('data-seller-name'))
+ Utilities.InjectResource('registerTooltips')
+ }
+
+ if (Settings.IRLPriceWithCurrency.Enabled === true && ItemOwned === false) {
IRLPrice()
}
@@ -44,9 +52,14 @@ var Utilities;
Sales.children[1].innerText = Owners.total.toLocaleString()
}
}
-
- if ((Settings.HoardersListOn === true && document.getElementById('resellers') !== null)) {
- HoardersList(2)
+
+ if (document.getElementById('resellers') !== null) {
+ if (Settings.HoardersList.Enabled === true) {
+ console.log(parseInt(Settings.HoardersList.MinCopies))
+ HoardersList(parseInt(Settings.HoardersList.MinCopies), Settings.HoardersList.AvatarsEnabled)
+ }
+ } else if (document.getElementById('timer') && /\d/.test(document.getElementById('timer').innerText)) {
+ CheckOwner()
}
})
})();
@@ -87,7 +100,7 @@ async function IRLPrice() {
Span.classList = 'text-muted polyplus-own-tag'
Span.style.fontSize = '0.7rem'
Span.style.fontWeight = 'normal'
- const IRLResult = await Utilities.CalculateIRL(Price, Settings.IRLPriceWithCurrencyCurrency)
+ const IRLResult = await Utilities.CalculateIRL(Price, Settings.IRLPriceWithCurrency.Currency)
Span.innerText = "($" + IRLResult.result + " " + IRLResult.display + ")"
PurchaseBtn.appendChild(Span)
}
@@ -158,7 +171,6 @@ function HandleItemWishlist() {
}
function TryOnItems() {
- console.log(Utilities, Utilities.MeshTypes, Utilities.TextureTypes)
const Avatar = {
"useCharacter": true,
"items": [],
@@ -175,47 +187,47 @@ function TryOnItems() {
let AssetType = document.querySelector('.px-4.px-lg-0.text-muted.text-uppercase.mb-3 .badge').innerHTML
const ItemThumbnail = document.getElementsByClassName('store-thumbnail')[0]
- const IFrame = document.getElementsByClassName('store-thumbnail-3d')[0]
+ //const IFrame = document.getElementsByClassName('store-thumbnail-3d')[0]
const TryIFrame = document.createElement('iframe')
TryIFrame.style = 'width: 100%; height: auto; aspect-ratio: 1; border-radius: 20px;'
const TryOnBtn = document.createElement('button')
- TryOnBtn.classList = 'btn btn-outline-warning'
+ TryOnBtn.classList = 'btn btn-warning'
TryOnBtn.style = 'position: absolute; bottom: 60px; right: 10px;'
if (document.getElementsByClassName('3dviewtoggler')[0] === undefined) {
- TryOnBtn.style.bottom = '15px;'
+ TryOnBtn.style.bottom = '15px'
}
- TryOnBtn.setAttribute('data-bs-toggle', 'tooltip')
- TryOnBtn.setAttribute('data-bs-title', 'Try this item on your avatar')
+ //TryOnBtn.setAttribute('data-bs-toggle', 'tooltip')
+ //TryOnBtn.setAttribute('data-bs-title', 'Try this item on your avatar')
TryOnBtn.innerHTML = '
'
TryOnBtn.addEventListener('click', function (){
- fetch("https://api.polytoria.com/v1/users/" + JSON.parse(window.localStorage.getItem('account_info')).ID + "/avatar")
- .then(response => {
- if (!response.ok) {
- throw new Error('Network response was not ok');
- }
- return response.json();
- })
- .then(data => {
- data.assets.forEach(item => {
- switch (item.type) {
- case 'hat':
- Avatar.items[Avatar.items.length] = item.path || ''
- break
- case 'face':
- Avatar.face = item.path || ''
- break
- case 'tool':
- Avatar.tool = item.path || ''
- break
- case 'shirt':
- Avatar.shirt = item.path || ''
- break
- case 'pants':
- Avatar.pants = item.path || ''
- break
+ fetch("https://api.polytoria.com/v1/users/" + JSON.parse(window.localStorage.getItem('p+account_info')).ID + "/avatar")
+ .then(response => {
+ if (!response.ok) {
+ throw new Error('Network response was not ok');
}
- });
+ return response.json();
+ })
+ .then(data => {
+ data.assets.forEach(item => {
+ switch (item.type) {
+ case 'hat':
+ Avatar.items[Avatar.items.length] = item.path || ''
+ break
+ case 'face':
+ Avatar.face = item.path || ''
+ break
+ case 'tool':
+ Avatar.tool = item.path || ''
+ break
+ case 'shirt':
+ Avatar.shirt = item.path || ''
+ break
+ case 'pants':
+ Avatar.pants = item.path || ''
+ break
+ }
+ });
Avatar.headColor = "#" + data.colors.head
Avatar.torsoColor = "#" + data.colors.torso
@@ -233,7 +245,7 @@ function TryOnItems() {
return response.json();
})
.then(data => {
- if (AssetType === 'tool') {
+ if (ItemType === 'tool') {
Avatar.tool = data.url
} else {
Avatar.items.push(data.url)
@@ -303,10 +315,10 @@ function TryOnItems() {
ItemThumbnail.parentElement.appendChild(TryOnBtn)
TryOnModal.children[1].prepend(TryIFrame)
- Utilities.InjectResource('registerTooltips')
+ //Utilities.InjectResource('registerTooltips')
}
-async function HoardersList(min) {
+async function HoardersList(min, avatars) {
let Page = 0
let Tabs = document.getElementById('store-tabs')
@@ -342,7 +354,11 @@ async function HoardersList(min) {
})
})
+ let Fetched = false
Tab.addEventListener('click', async function(){
+ if (Fetched === true) { return }
+ Fetched = true
+
const Owners = []
if (InitialOwners === undefined) {
InitialOwners = (await (await fetch('https://api.polytoria.com/v1/store/' + ItemID + '/owners?limit=100')).json())
@@ -350,8 +366,10 @@ async function HoardersList(min) {
Owners.push(...InitialOwners.inventories)
// Get owners (up to 300, if needed)
- if (InitialOwners.pages > 1) {
- if (InitialOwners.pages > 3) {InitialOwners.pages = 3}
+ if (InitialOwners.pages > 3) {
+ InitialOwners.pages = 3
+ }
+ if (InitialOwners.pages > 1 && OwnerPagesFetched < InitialOwners.pages) {
for (let i = 1; i < InitialOwners.pages; i++) {
const PageResult = (await (await fetch('https://api.polytoria.com/v1/store/' + ItemID + '/owners?limit=100&page=' + (i+1))).json()).inventories
console.log(PageResult)
@@ -374,7 +392,16 @@ async function HoardersList(min) {
}
}
- let Hoarders = Object.values(Formatted).filter((x, index) => x.copies >= min).sort((a, b) => b.copies - a.copies)
+ let Hoarders = await new Promise(async (resolve, reject) => {
+ const Sorted = Object.values(Formatted).filter((x, index) => x.copies >= min).sort((a, b) => b.copies - a.copies)
+ if (avatars === true) {
+ for (let hoarder of Sorted) {
+ const Avatar = (await (await fetch('https://api.polytoria.com/v1/users/' + hoarder.user.id)).json()).thumbnail.icon;
+ hoarder.user.avatar = Avatar;
+ }
+ }
+ resolve(Sorted)
+ })
let AmountOfHoarders = Hoarders.length
// Break hoarders into groups of 4
@@ -385,10 +412,15 @@ async function HoardersList(min) {
TabContent.innerHTML = `
- ${ Groups[Page].map((x) => `
+ ${ (Groups[Page] !== undefined) ? Groups[Page].map((x) => `
+ ${ (avatars === true) ? `
+
+
+
+ ` : '' }
@@ -412,7 +444,15 @@ async function HoardersList(min) {
`).join('')
- }
+ : `
+
+
+
+
No hoarders
+
This item is fresh and doesn't have any hoarders yet! Come back later!
+
+
+ `}