prepare for next update

i don't feel like writing github commit description right now
This commit is contained in:
Index 2024-05-22 17:18:55 -05:00
parent 6ebc9cc596
commit c1bee43f08
17 changed files with 676 additions and 461 deletions

View file

@ -1,5 +1,70 @@
setTimeout(function () {}, 100)
const UserID = JSON.parse(window.localStorage.getItem('account_info')).ID
const BodyColors = [
"#f8f8f8",
"#cdcdcd",
"#111111",
"#ff0000",
"#a34b4b",
"#ffc9c9",
"#957977",
"#c4281c",
"#da867a",
"#694028",
"#cc8e69",
"#a05f35",
"#7c5c46",
"#eab892",
"#da8541",
"#aa5500",
"#ffcc99",
"#e29b40",
"#ffaf00",
"#ffb000",
"#d7c59a",
"#f5cd30",
"#fdea8d",
"#e5e4df",
"#c1be42",
"#ffff00",
"#ffffcc",
"#a4bd47",
"#7f8e64",
"#a1c48c",
"#3a7d15",
"#4b974b",
"#00ff00",
"#ccffcc",
"#27462d",
"#287f47",
"#789082",
"#9ff3e9",
"#12eed4",
"#f2f3f3",
"#00ffff",
"#008f9c",
"#04afec",
"#80bbdb",
"#b4d2e4",
"#0d69ac",
"#1b2a35",
"#afddff",
"#6e99ca",
"#74869d",
"#2154b9",
"#002060",
"#0000ff",
"#b1a7ff",
"#a3a2a5",
"#6225d1",
"#b480ff",
"#8c5b9f",
"#6b327c",
"#aa00aa",
"#635f62",
"#ff00bf",
"#ff66cc",
"#e8bac8"
]
let PageContainer = document.querySelector('.container.p-0.p-lg-5')
let ItemGrid;
@ -24,7 +89,7 @@ let Avatar = {
"rightLegColor": "#e0e0e0"
}
if (new URLSearchParams(new URL(window.location).search).get('sandbox') === 'true') {
if (new URLSearchParams(window.location.search).has('sandbox')) {
console.log('Avatar Sandbox!')
LoadFile(chrome.runtime.getURL('resources/avatar-sandbox.html'), function(html){
@ -110,6 +175,12 @@ if (new URLSearchParams(new URL(window.location).search).get('sandbox') === 'tru
UpdateAvatar()
});
});
} else {
const SandboxButton = document.createElement('a')
SandboxButton.classList = 'btn btn-outline-success w-100 mt-3'
SandboxButton.href = '?sandbox=true'
SandboxButton.innerHTML = '<i class="fas fa-shirt"></i> Avatar Sandbox'
document.getElementById('cont-move').parentElement.appendChild(SandboxButton)
}
function UpdateAvatar() {

View file

@ -15,6 +15,10 @@ chrome.storage.sync.get(['PolyPlus_Settings'], async function(result) {
IRLPrice()
}
if (Settings.ShowFriendCount === true) {
ShowFriendCount()
}
if (Settings.PinnedGamesOn === true || Settings.BestFriendsOn === true) {
Update()
}
@ -190,3 +194,22 @@ async function IRLPrice() {
}
})();
}
async function ShowFriendCount() {
let FriendCount = (await (await fetch('https://polytoria.com/api/friends?page=1')).json()).meta.total
/*
const FirstPage = (await (await fetch('https://polytoria.com/api/friends?page=1')).json())
if (FirstPage.meta.lastPage > 1) {
const LastPage = (await (await fetch('https://polytoria.com/api/friends?page=' + Pages)).json())
FriendCount = (12*(FirstPage.meta.pages-1)) + LastPage.data.length
} else {
FriendCount = FirstPage.data.length
}
*/
const CountText = document.createElement('small')
CountText.classList = 'text-muted fw-lighter'
CountText.style.fontSize = '0.8rem'
CountText.innerText = ' (' + FriendCount + ')'
document.querySelector('#home-friendsOnline h5').appendChild(CountText)
}

View file

@ -1,4 +1,4 @@
const UserID = window.location.pathname.split('/')[2];
let UserID = window.location.pathname.split('/')[2];
const AvatarRow = document.getElementsByClassName('d-flex flex-row flex-nowrap overflow-x-scroll px-3 px-lg-0 mb-2 mb-lg-0')[0]
const AvatarHeading = document.querySelector('.section-title:has(i.fa-user-crown)')
@ -9,8 +9,9 @@ let CalculateButton;
let Utilities;
if (UserID && !isNaN(UserID)) {
if (UserID) {
(async () => {
UserID = (await (await fetch('https://api.polytoria.com/v1/users/')).json()).id
Utilities = await import(chrome.runtime.getURL('resources/utils.js'));
Utilities = Utilities.default
@ -94,15 +95,15 @@ if (UserID && !isNaN(UserID)) {
} else if (UserID && UserID[0] === "@") {
const Username = window.location.pathname.split('/')[2].substring(1)
let Reference = new URLSearchParams(new URL(window.location.href).search).get('ref')
if (Reference === null) {
let Reference = new URLSearchParams(new URL(window.location.href).search)
if (!Reference.has('ref')) {
Reference = ""
}
fetch("https://api.polytoria.com/v1/users/find?username=" + Username)
.then(response => {
if (!response.ok) {
window.location.href = window.location.origin + decodeURIComponent(Reference)
window.location.href = window.location.origin + decodeURIComponent(Reference.get('ref'))
} else {
return response.json()
}
@ -127,14 +128,14 @@ function BestFriends() {
FavoriteBtn = document.createElement('button');
FavoriteBtn.classList = 'btn btn-warning btn-sm ml-2';
if (!(BestFriends.length === 7)) {
if (!(BestFriends.length === Utilities.Limits.BestFriends)) {
if (Array.isArray(BestFriends) && BestFriends.includes(parseInt(UserID))) {
FavoriteBtn.innerText = 'Remove Best Friend Status';
} else {
FavoriteBtn.innerText = 'Best Friend';
}
} else {
FavoriteBtn.innerText = 'Remove Best Friend Status (max 7/7)'
FavoriteBtn.innerText = 'Remove Best Friend Status (max ' + Utilities.Limits.BestFriends + '/' + Utilities.Limits.BestFriends + ')'
}
if (UserID !== JSON.parse(window.localStorage.getItem('account_info')).ID && document.getElementById('add-friend-button').classList.contains('btn-success') === false) {
FavoriteBtn.addEventListener('click', function() {
@ -180,14 +181,14 @@ function BestFriends() {
chrome.storage.sync.get(['PolyPlus_BestFriends'], function(result) {
BestFriends = result.PolyPlus_BestFriends || [];
if (!(BestFriends.length === 7)) {
if (!(BestFriends.length === Utilities.Limits.BestFriends)) {
if (Array.isArray(BestFriends) && BestFriends.includes(parseInt(UserID))) {
FavoriteBtn.innerText = 'Remove Best Friend Status'
} else {
FavoriteBtn.innerText = 'Best Friend'
}
} else {
FavoriteBtn.innerText = 'Remove Best Friend Status (max 7/7)'
FavoriteBtn.innerText = 'Remove Best Friend Status (max ' + Utilities.Limits.BestFriends + '/' + Utilities.Limits.BestFriends + ')'
}
});
}
@ -206,8 +207,9 @@ function BestFriends() {
async function OutfitCost() {
const AvatarCost = {
Total: 0,
Limiteds: 0,
Exclusives: 0
Collectibles: 0,
Offsale: 0,
HasProfileTheme: false
}
for (let item of AvatarRow.children) {
const ItemID = item.getElementsByTagName('a')[0].href.split('/')[4]
@ -221,10 +223,13 @@ async function OutfitCost() {
.then(data => {
let Price = data.price
if (data.isLimited === true) {
AvatarCost.Limiteds += 1
AvatarCost.Collectibles += 1
Price = data.averagePrice
} else if (data.sales === 0) {
AvatarCost.Exclusives += 1
AvatarCost.Offsale += 1
Price = 0
} else if (data.type === 'profileTheme') {
AvatarCost.HasProfileTheme = true
Price = 0
}
@ -235,7 +240,7 @@ async function OutfitCost() {
const ResultText = document.createElement('small')
ResultText.classList = 'fw-normal text-success'
ResultText.style.letterSpacing = '0px'
ResultText.innerHTML = `(<i class="pi pi-brick mx-1"></i> ${ (AvatarCost.Limiteds > 0 || AvatarCost.Exclusives > 0) ? '~' : '' }${ AvatarCost.Total.toLocaleString() }${ (AvatarCost.Limiteds > 0) ? `, ${AvatarCost.Limiteds} limited` : '' }${ (AvatarCost.Exclusives > 0) ? `, ${AvatarCost.Exclusives} exclusive` : '' })`
ResultText.innerHTML = `(<i class="pi pi-brick mx-1"></i> ${ (AvatarCost.Collectibles > 0 || AvatarCost.Offsale > 0 || AvatarCost.HasProfileTheme === true) ? '~' : '' }${ AvatarCost.Total.toLocaleString() } | ${ (AvatarCost.Collectibles > 0) ? AvatarCost.Collectibles + ' collectible' : '' }${ (AvatarCost.Offsale > 0) ? `, ${AvatarCost.Offsale} offsale` : '' }${ (AvatarCost.HasProfileTheme === true) ? ', profile theme excluded' : '' })`
CalculateButton.remove()
AvatarHeading.appendChild(ResultText)

View file

@ -12,7 +12,6 @@ let Theme = null;
// If theme exists, create a style element to represent it
if (Settings.ThemeCreatorOn && Settings.ThemeCreatorOn === true) {
//Theme = document.createElement('style')
switch (Settings.ThemeCreator.BGImageSize) {
case 0:
Settings.ThemeCreator.BGImageSize = 'fit'
@ -113,8 +112,9 @@ 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 = window.URL.createObjectURL(ThemeBlob)
const ThemeURL = URL.createObjectURL(ThemeBlob)
document.head.innerHTML += `<link href="${ThemeURL}" rel="stylesheet" type="text/css">`
});
@ -137,7 +137,6 @@ let Theme = null;
// Define Data
const UserData = {
Username: document.querySelector('a.text-reset.text-decoration-none[href^="/users"]').innerText.replace(/\s+/g,''),
ID: document.querySelector('.text-reset.text-decoration-none[href^="/users/"]').getAttribute('href').split('/')[2],
Bricks: document.querySelector('.brickBalanceCont').innerText.replace(/\s+/g,'')
}
@ -145,13 +144,11 @@ let Theme = null;
window.localStorage.setItem('account_info', JSON.stringify(UserData))
document.body.setAttribute('data-URL', window.location.pathname)
// Add PolyPlus Settings link to Sidebar
const Parent = document.querySelector('ul.nav.nav-flush')
const Clone = Parent.querySelectorAll('li.nav-item')[0].cloneNode(true)
Clone.getElementsByTagName('a')[0].href = '/my/settings/polyplus'
Clone.getElementsByTagName('span')[0].innerText = "Poly+"
const Icon = Clone.querySelector('i')
Icon.classList = 'fa-regular fa-sparkles'
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})`});
}
if (Settings.ModifyNavOn && Settings.ModifyNavOn === true) {
let NavbarItems = document.querySelectorAll('.navbar-nav.me-auto a.nav-link[href]')
@ -165,18 +162,8 @@ let Theme = null;
}
}
if (Settings.HideUpgradeBtnOn && Settings.HideUpgradeBtnOn === true) {
document.querySelector('.nav-sidebar a[href="/upgrade"].nav-link.py-1.nav-sidebar-link').remove()
}
if (Settings.IRLPriceWithCurrencyOn && 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.innerText = element.innerText + ` ($${IRLResult.result} ${IRLResult.display})`});
}
if (Settings.HideNotifBadgesOn && Settings.HideNotifBadgesOn === true) {
document.querySelectorAll('.notif-nav.notif-sidebar').forEach(element => {element.remove();});
if (Settings.HideNotifBadgesOn === true) {
document.getElementsByClassName('notif-nav notif-sidebar').forEach(element => {element.remove();});
}
});
})();

View file

@ -23,24 +23,6 @@ chrome.storage.sync.get(['PolyPlus_Settings'], function(result){
}
});
/*
async function IRLPrice() {
Array.from(document.getElementsByClassName('polyplus-price-tag')).forEach(tag => {tag.remove()})
for (let item of Array.from(StoreItems.children)) {
const Price = item.getElementsByClassName('text-success')[0]
if (Price !== undefined && Price.innerText !== "Free") {
const IRLResult = await Utilities.CalculateIRL(Price.innerText, Settings.IRLPriceWithCurrencyCurrency)
let Span = document.createElement('span')
Span.classList = 'text-muted polyplus-price-tag'
Span.style.fontSize = '0.7rem'
Span.innerText = " ($" + IRLResult.result + " " + IRLResult.display + ")"
Price.appendChild(Span)
}
}
}
*/
async function IRLPrice(item) {
const Price = item.getElementsByClassName('text-success')[0]
if (Price !== undefined && Price.innerText !== "Free") {

View file

@ -7,8 +7,6 @@ const LibraryTypes = [
"Mesh"
]
var Success = true;
if (LibraryTypes.indexOf(LibraryType) !== -1) {
chrome.storage.sync.get(['PolyPlus_Settings'], function(result){
Settings = result.PolyPlus_Settings || {};

View file

@ -1,46 +1,41 @@
let Comments = document.getElementById('comments')
const Type = window.location.pathname.split('/')[1]
!(() => {
let Comments = document.getElementById('comments')
const Type = window.location.pathname.split('/')[1]
let CreatorID;
switch (Type) {
case 'store':
let CreatorID;
if (Type === 'store') {
if (document.querySelector('h5 .text-reset[href^="/users/"]')) {
CreatorID = document.querySelector('h5 .text-reset[href^="/users/"]').getAttribute('href').split('/')[2]
} else {CreatorID = 1}
break
case 'places':
} else {
CreatorID = 1
}
} else if (Type === 'places') {
CreatorID = document.querySelector('.mcard .col .text-muted [href^="/users/"]').getAttribute('href').split('/')[2]
break
/*
case 'feed':
} else if (Type === 'feed') {
CreatorID = document.querySelector('p a[href^="/users/"].text-reset').getAttribute('href').split('/')[2]
break
*/
case 'guilds':
} else if (Type === 'guilds') {
CreatorID = document.querySelector('[class^="userlink-"][href^="/users/"]').getAttribute('href').split('/')[2]
Comments = document.getElementById('wall-posts')
break
}
Array.from(Comments.children).forEach(element => {
LoadCreatorTag(element)
});
}
const Observer = new MutationObserver(function (list){
const Observer = new MutationObserver(function (list){
for (let record of list) {
for (let element of record.addedNodes) {
if (element.classList === 'card mb-3') {
LoadCreatorTag(element)
}
}
});
Observer.observe(Comments, {attributes: false, childList: true, subtree: false})
}
});
Observer.observe(Comments, {attributes: false, childList: true, subtree: false})
function LoadCreatorTag(element) {
let NameElement;
if (!(Type === 'guilds')) {
NameElement = element.querySelector('.text-reset[href^="/users/"]')
} else {
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/"]')
}
let UserID = NameElement.getAttribute('href').split('/')[2]
if (UserID === CreatorID) {
let Tag = document.createElement('span')
@ -53,4 +48,9 @@ function LoadCreatorTag(element) {
//new window.bootstrap.Tooltip(Tag, {toggle:"tooltip",title:"This user is the creator of this asset!"})
}
}
}
Array.from(Comments.children).forEach(element => {
LoadCreatorTag(element)
});
})();

View file

@ -8,7 +8,7 @@ var Settings;
var PinnedGamesData = []
let GamePinned;
let InfoColumns = document.querySelectorAll('#main-content .col:has(#likes-data-container) .card:last-child ul')
let InfoColumns = document.querySelectorAll('#main-content .col:has(#likes-data-container) .card:has(.fas.fa-chart-bar) ul')
let CalculateRevenueButton;
const AchievementsTab = document.getElementById('achievements-tabpane')
@ -414,8 +414,12 @@ async function PlaceRevenue() {
}
/*
let AchievementCost = 0
let FreeAchievements = null;
for (let achievement of Achievements.achievements) {
// decrease total by price of achievement creation based on when the achievement was created
if ()
}
*/
@ -430,54 +434,6 @@ async function PlaceRevenue() {
function round5(number) { const remainder = number % 5; if (remainder < 2.5) { return number - remainder; } else { return number + (5 - remainder); } }
function ImprovedAchievements() {
const AchievementCount = Achievements.length
let AchievementsEarned = 0
for (let achievement of Achievements) {
Achieved = (achievement.getElementsByClassName('fad fa-check-circle')[0] !== undefined)
if (Achieved === true) {
achievement.style.borderColor = 'gold'
AchievementsEarned++
}
}
const PercentageEarned = ((AchievementsEarned*100)/AchievementCount).toFixed(0)
const ProgressBar = document.createElement('div')
ProgressBar.role = 'progressbar'
ProgressBar.classList = 'progress'
ProgressBar.style.background = '#000'
ProgressBar.ariaValueNow = PercentageEarned
ProgressBar.ariaValueMin = "0"
ProgressBar.ariaValueMax = "100"
ProgressBar.innerHTML = `<div class="progress-bar progress-bar-striped text-bg-warning" style="width: ${PercentageEarned}%">${PercentageEarned}%</div>`
AchievementsTab.prepend(document.createElement('hr'))
AchievementsTab.prepend(ProgressBar)
fetch('https://api.polytoria.com/v1/users/')
.then(response => {
if (!response.ok) {
throw new Error('Network not ok')
}
return response.json()
})
.then(data => {
const UserCount = data.total
for (let achievement of Achievements) {
const OwnerText = achievement.getElementsByClassName('text-muted small my-0')[0]
// thanks to Stackoverflow on how to remove everything except numbers from string
const OwnerCount = parseInt(OwnerText.innerText.replace(/[^0-9]/g, ''))
const PercentageOfPlayers = ((OwnerCount*100)/UserCount).toFixed(2)
OwnerText.innerHTML += " (" + PercentageOfPlayers + "%)"
}
})
.catch(error => {console.log(error)});
}
function AchievementProgressBar() {
const AchievementCount = Achievements.length
let AchievementsEarned = 0
@ -506,7 +462,7 @@ function AchievementProgressBar() {
}
function AchievementEarnedPercentage() {
fetch('https://api.polytoria.com/v1/users/')
fetch('https://api.polytoria.com/v1/places/' + PlaceID)
.then(response => {
if (!response.ok) {
throw new Error('Network not ok')
@ -514,15 +470,37 @@ function AchievementEarnedPercentage() {
return response.json()
})
.then(data => {
const UserCount = data.total
const UserCount = data.uniqueVisits
for (let achievement of Achievements) {
const OwnerText = achievement.getElementsByClassName('text-muted small my-0')[0]
// thanks to Stackoverflow on how to remove everything except numbers from string
const OwnerCount = parseInt(OwnerText.innerText.replace(/[^0-9]/g, ''))
const PercentageOfPlayers = ((OwnerCount*100)/UserCount).toFixed(2)
OwnerText.innerHTML += " (" + PercentageOfPlayers + "%)"
OwnerText.innerHTML += " (" + PercentageOfPlayers + "%, " + GetAchievementDifficulty(PercentageOfPlayers) + ")"
}
})
.catch(error => {console.log(error)});
}
function GetAchievementDifficulty(percent) {
if (percent >= 90 && percent <= 100) {
return 'Freebie'
} else if (percent >= 80 && percent <= 89.9) {
return 'Cake Walk'
} else if (percent >= 50 && percent <= 79.9) {
return 'Easy'
} else if (percent >= 30 && percent <= 49.9) {
return 'Moderate'
} else if (percent >= 20 && percent <= 29.9) {
return 'Challenging'
} else if (percent >= 10 && percent <= 19.9) {
return 'Hard'
} else if (percent >= 5 && percent <= 9.9) {
return 'Extreme'
} else if (percent >= 1 && percent <= 4.9) {
return 'Insane'
} else if (percent >= 0 && percent <= 0.9) {
return 'Impossible'
}
}

View file

@ -1,5 +1,5 @@
const SettingsURL = chrome.runtime.getURL('settings.html')
const InExtensionSettings = (window.location.pathname.split('/')[3] === "polyplus")
const InExtensionSettings = (window.location.pathname.split('/')[3] === "polyplus" && window.location.hash !== "#dev")
if (InExtensionSettings === true) {
window.location.href = SettingsURL + window.location.hash
}

View file

@ -1,28 +1,16 @@
const ItemID = window.location.pathname.split('/')[2]
const ItemType = document.querySelector('.row .badge').innerHTML
const MeshTypes = [
"hat",
"hair",
"head attachment",
"face accessory",
"neck accessory",
"head cover",
"back accessory",
"shoulder accessory",
"tool"
]
var Utilities;
var Settings;
var ItemWishlist;
var PurchaseBtn;
var WishlistBtn;
var ItemOwned;
var InitialOwners;
var Utilities;
(async () => {
if (!(window.location.href.split('/')[4]) || ItemType === "achievement") {return}
Utilities = await import(chrome.runtime.getURL('resources/utils.js'));
Utilities = Utilities.default
@ -43,23 +31,21 @@ var ItemOwned;
HandleItemWishlist()
}
if (Settings.TryOnItemsOn === true) {
if (Settings.TryOnItemsOn === true && (Utilities.MeshTypes.indexOf(ItemType.toLowerCase()) !== -1 || Utilities.TextureTypes.indexOf(ItemType.toLowerCase()) !== -1)) {
TryOnItems()
}
if (Settings.ReplaceItemSalesOn === true) {
const Sales = document.querySelectorAll('.col:has(h6):has(h3.small)')[2]
if (Sales.children[1].innerText === '0') {
const Owners = (await (await fetch('https://api.polytoria.com/v1/store/' + ItemID + '/owners?limit=1')).json()).total
InitialOwners = (await (await fetch('https://api.polytoria.com/v1/store/' + ItemID + '/owners?limit=100')).json())
Sales.children[0].innerText = 'Owners'
Sales.children[1].innerText = Owners.toLocaleString()
Sales.children[1].innerText = Owners.total.toLocaleString()
}
}
if (new URLSearchParams(window.location.search).get('hoardersList') === 'true') {
HoardersList(1)
} else if ((Settings.HoardersListOn === true && document.getElementById('resellers') !== null)) {
if ((Settings.HoardersListOn === true && document.getElementById('resellers') !== null)) {
HoardersList(2)
}
})
@ -78,13 +64,13 @@ chrome.storage.onChanged.addListener(function(changes, namespace) {
} else {
if (!(ItemWishlist.length === 25)) {
WishlistBtn.removeAttribute('disabled')
WishlistBtn.classList = 'btn btn-primary btn-sm'
WishlistBtn.classList = 'btn btn-warning btn-sm'
WishlistBtn.innerHTML = `
<i class="fa fa-star" style="margin-right: 2.5px;"></i> Wishlist Item
`
} else {
WishlistBtn.setAttribute('disabled', true)
WishlistBtn.classList = 'btn btn-primary btn-sm'
WishlistBtn.classList = 'btn btn-warning btn-sm'
WishlistBtn.innerHTML = `
<i class="fa fa-star" style="margin-right: 2.5px;"></i> Wishlist Item
`
@ -96,6 +82,7 @@ chrome.storage.onChanged.addListener(function(changes, namespace) {
async function IRLPrice() {
const Price = PurchaseBtn.getAttribute('data-price')
if (Price === null || Price === "0") { return }
const Span = document.createElement('span')
Span.classList = 'text-muted polyplus-own-tag'
Span.style.fontSize = '0.7rem'
@ -131,7 +118,7 @@ function HandleItemWishlist() {
<i class="fa fa-star" style="margin-right: 2.5px;"></i> Un-Wishlist Item
`
} else {
WishlistBtn.classList = 'btn btn-primary btn-sm'
WishlistBtn.classList = 'btn btn-warning btn-sm'
WishlistBtn.innerHTML = `
<i class="fa fa-star" style="margin-right: 2.5px;"></i> Wishlist Item
`
@ -145,7 +132,7 @@ function HandleItemWishlist() {
let i = ItemWishlist.indexOf(parseInt(ItemID))
if (i !== -1) {
ItemWishlist.splice(i, 1)
WishlistBtn.classList = 'btn btn-primary btn-sm'
WishlistBtn.classList = 'btn btn-warning btn-sm'
WishlistBtn.innerHTML = `
<i class="fa fa-star" style="margin-right: 2.5px;"></i> Wishlist Item
`
@ -171,6 +158,7 @@ function HandleItemWishlist() {
}
function TryOnItems() {
console.log(Utilities, Utilities.MeshTypes, Utilities.TextureTypes)
const Avatar = {
"useCharacter": true,
"items": [],
@ -194,33 +182,14 @@ function TryOnItems() {
const TryOnBtn = document.createElement('button')
TryOnBtn.classList = 'btn btn-outline-warning'
TryOnBtn.style = 'position: absolute; bottom: 60px; right: 10px;'
if (document.getElementsByClassName('3dviewtoggler')[0] === undefined) {
TryOnBtn.style.bottom = '15px;'
}
TryOnBtn.setAttribute('data-bs-toggle', 'tooltip')
TryOnBtn.setAttribute('data-bs-title', 'Try this item on your avatar')
TryOnBtn.innerHTML = '<i class="fa-duotone fa-vial"></i>'
TryOnBtn.addEventListener('click', function (){
TryOnModal.showModal()
});
let TryOnModal = document.createElement('dialog')
TryOnModal.classList = 'polyplus-modal'
TryOnModal.setAttribute('style', 'width: 450px; border: 1px solid #484848; background-color: #181818; border-radius: 20px; overflow: hidden;')
TryOnModal.innerHTML = `
<div class="text-muted mb-2" style="font-size: 0.8rem;">
<h5 class="mb-0" style="color: #fff;">Preview</h5>
Try this avatar on your avatar before purchasing it!
</div>
<div class="modal-body">
<button class="btn btn-primary w-100 mx-auto" onclick="this.parentElement.parentElement.close();">Close</button>
</div>
`
document.body.prepend(TryOnModal)
ItemThumbnail.parentElement.appendChild(TryOnBtn)
TryOnModal.children[1].prepend(TryIFrame)
Utilities.InjectResource('registerTooltips')
fetch("https://api.polytoria.com/v1/users/:id/avatar".replace(':id', JSON.parse(window.localStorage.getItem('account_info')).ID))
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');
@ -255,7 +224,7 @@ function TryOnItems() {
Avatar.leftLegColor = "#" + data.colors.leftLeg
Avatar.rightLegColor = "#" + data.colors.rightLeg
if (MeshTypes.indexOf(AssetType.toLowerCase()) !== -1) {
if (Utilities.MeshTypes.indexOf(AssetType.toLowerCase()) !== -1) {
fetch("https://api.polytoria.com/v1/assets/serve-mesh/:id".replace(':id', window.location.pathname.split('/')[2]))
.then(response => {
if (!response.ok) {
@ -276,7 +245,7 @@ function TryOnItems() {
.catch(error => {
console.error('Fetch error:', error);
});
} else {
} else if (Utilities.TextureTypes.indexOf(AssetType.toLowerCase()) !== -1) {
fetch("https://api.polytoria.com/v1/assets/serve/:id/Asset".replace(':id', window.location.pathname.split('/')[2]))
.then(response => {
if (!response.ok) {
@ -286,13 +255,16 @@ function TryOnItems() {
})
.then(data => {
switch (AssetType) {
case 'shirt':
case 'Shirt':
console.log('IS SHIRT')
Avatar.shirt = data.url
break
case 'pants':
case 'Pants':
console.log('IS PANTS')
Avatar.pants = data.url
break
case 'face':
case 'Face':
console.log('IS FACE')
Avatar.face = data.url
break
}
@ -307,21 +279,80 @@ function TryOnItems() {
.catch(error => {
console.error('Fetch error:', error);
});
TryOnModal.showModal()
});
let TryOnModal = document.createElement('dialog')
TryOnModal.classList = 'polyplus-modal'
TryOnModal.setAttribute('style', 'width: 450px; border: 1px solid #484848; background-color: #181818; border-radius: 20px; overflow: hidden;')
TryOnModal.innerHTML = `
<div class="row text-muted mb-2" style="font-size: 0.8rem;">
<div class="col">
<h5 class="mb-0" style="color: #fff;">Preview</h5>
Try this avatar on your avatar before purchasing it!
</div>
<div class="col-md-2">
<button class="btn btn-info w-100 mx-auto" onclick="this.parentElement.parentElement.parentElement.close();">X</button>
</div>
</div>
<div class="modal-body"></div>
`
document.body.prepend(TryOnModal)
ItemThumbnail.parentElement.appendChild(TryOnBtn)
TryOnModal.children[1].prepend(TryIFrame)
Utilities.InjectResource('registerTooltips')
}
async function HoardersList(min) {
let Page = 0
let Tabs = null
if (new URLSearchParams(window.location.search).get('hoardersList') !== 'true') {
Tabs = document.getElementById('store-tabs')
let Tabs = document.getElementById('store-tabs')
const Tab = document.createElement('li')
Tab.classList = 'nav-item'
Tab.innerHTML = `
<a class="nav-link">
<i class="fas fa-calculator me-1"></i>
<span class="d-none d-sm-inline"><span class="pilltitle">Hoarders</span>
</a>
`
Tabs.appendChild(Tab)
const TabContent = document.createElement('div')
TabContent.classList = 'd-none'
TabContent.innerHTML = `
<small class="d-block text-center text-muted" style="font-size: 0.8rem;">
loading... (this may take a few seconds)
</small>
<lottie-player id="avatar-loading" src="https://c0.ptacdn.com/static/images/lottie/poly-brick-loading.2b51aa85.json" background="transparent" speed="1" style="width: 20%;height: auto;margin: -16px auto 50px;margin-top: 0px;" loop="" autoplay=""></lottie-player>
`
document.getElementById('owners').parentElement.appendChild(TabContent)
// Add tab logic
Array.from(Tabs.children).forEach(tab => {
tab.addEventListener('click', function() {
if (tab === Tab) {
Array.from(Tabs.children).forEach(tab => {tab.children[0].classList.remove('active')})
Array.from(document.getElementById('owners').parentElement.children).forEach(tab => {tab.classList.add('d-none')})
tab.children[0].classList.add('active')
TabContent.classList.remove('d-none')
}
})
})
Tab.addEventListener('click', async function(){
const Owners = []
const InitialOwners = (await (await fetch('https://api.polytoria.com/v1/store/' + ItemID + '/owners?limit=100')).json())
if (InitialOwners === undefined) {
InitialOwners = (await (await fetch('https://api.polytoria.com/v1/store/' + ItemID + '/owners?limit=100')).json())
}
Owners.push(...InitialOwners.inventories)
// Get owners (up to 300, if needed)
if (InitialOwners.pages > 1) {
if (InitialOwners.pages > 3) {InitialOwners.pages = 3}
for (let i = 1; i < InitialOwners.pages; i++) {
console.log(i)
const PageResult = (await (await fetch('https://api.polytoria.com/v1/store/' + ItemID + '/owners?limit=100&page=' + (i+1))).json()).inventories
console.log(PageResult)
Owners.push(...PageResult)
@ -329,6 +360,7 @@ async function HoardersList(min) {
}
const Formatted = {}
// Count copies & store serials of owners
for (let owner of Owners) {
if (Formatted[owner.user.id] !== undefined) {
Formatted[owner.user.id].copies++
@ -342,47 +374,21 @@ async function HoardersList(min) {
}
}
const Hoarders = new Promise(async (resolve, reject) => {
const Sorted = Object.values(Formatted).filter((x, index) => x.copies >= min).sort((a, b) => b.copies - a.copies)
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;
if (Sorted.indexOf(hoarder) === Sorted.length-1) { resolve(Sorted) }
}
})
Hoarders.then(async (hoarders) => {
const AmountOfHoarders = hoarders.length
const Groups = []
let Hoarders = Object.values(Formatted).filter((x, index) => x.copies >= min).sort((a, b) => b.copies - a.copies)
let AmountOfHoarders = Hoarders.length
while (hoarders.length > 0) {
Groups.push(hoarders.splice(0, 4))
}
if (min === 1) {
console.log('HOARDER LIST: ', Groups)
return
// Break hoarders into groups of 4
let Groups = []
while (Hoarders.length > 0) {
Groups.push(Hoarders.splice(0, 4))
}
const Tab = document.createElement('li')
Tab.classList = 'nav-item'
Tab.innerHTML = `
<a class="nav-link">
<i class="fas fa-calculator me-1"></i>
<span class="d-none d-sm-inline"><span class="pilltitle">Hoarders (${AmountOfHoarders})</span>
</a>
`
Tabs.appendChild(Tab)
const TabContent = document.createElement('div')
TabContent.classList = 'd-none'
TabContent.innerHTML = `
<div id="hoarders-container">
<div id="p+hoarders-container">
${ Groups[Page].map((x) => `
<div class="card mb-3">
<div class="card-body">
<div class="row">
<div class="col-auto">
<img src="${x.user.avatar}" alt="${x.user.username}" width="72" class="rounded-circle border border-2 border-secondary bg-dark">
</div>
<div class="col d-flex align-items-center">
<div>
<h6 class="mb-1">
@ -392,6 +398,11 @@ async function HoardersList(min) {
</div>
</div>
<div class="col-auto d-flex align-items-center">
<!--
<div>
<h5 style="margin: 0px;margin-right: 10px;">${ ((x.copies/InitialOwners.total)*100).toFixed(2) }%</h5>
</div>
-->
<a class="btn btn-warning" type="button" href="/trade/new/${x.user.id}">
<i class="fad fa-exchange-alt me-1"></i>
<span class="d-none d-sm-inline">Trade</span>
@ -405,112 +416,112 @@ async function HoardersList(min) {
</div>
<nav aria-label="Hoarders">
<ul class="pagination justify-content-center">
<li style="margin-top: auto; margin-bottom: auto;">
<select class="form-select form-select-sm" style="height: 37px !important;" id="p+hoarders-min-copies">
<option value="2">Min. 2+ Copies</option>
<option value="3">Min. 3+ Copies</option>
<option value="5">Min. 5+ Copies</option>
<option value="10">Min. 10+ Copies</option>
<option value="10">Min. 15+ Copies</option>
</select>
</li>
<li class="page-item disabled">
<a class="page-link" href="#!" tabindex="-1" id="hoarders-prev-pg">
<i class="fad fa-chevron-left"></i>
</a>
<a class="page-link" href="#!" id="p+hoarders-first-pg">«</a>
</li>
<li class="page-item disabled">
<a class="page-link" href="#!" tabindex="-1" id="p+hoarders-prev-pg"></a>
</li>
<li class="page-item active">
<a class="page-link" href="#!" id="hoarders-current-pg">
1
<a class="page-link">
<span class="visually-hidden">Page</span>
<span id="p+hoarders-current-pg">1</span>
</a>
</li>
<li class="page-item">
<a class="page-link" href="#!" id="hoarders-next-pg">
<i class="fad fa-chevron-right"></i>
</a>
<a class="page-link" href="#!" id="p+hoarders-next-pg"></a>
</li>
<li class="page-item">
<a class="page-link" href="#!" id="p+hoarders-last-pg">»</a>
</li>
</ul>
</nav>
`
document.getElementById('owners').parentElement.appendChild(TabContent)
Utilities.InjectResource('registerTooltips')
Array.from(Tabs.children).forEach(tab => {
tab.addEventListener('click', function() {
if (tab === Tab) {
Array.from(Tabs.children).forEach(tab => {tab.children[0].classList.remove('active')})
Array.from(document.getElementById('owners').parentElement.children).forEach(tab => {tab.classList.add('d-none')})
tab.children[0].classList.add('active')
TabContent.classList.remove('d-none')
}
})
})
const Container = document.getElementById('p+hoarders-container')
const Container = document.getElementById('hoarders-container')
// Pagination is annoying
const First = document.getElementById('p+hoarders-first-pg')
const Prev = document.getElementById('p+hoarders-prev-pg')
const Current = document.getElementById('p+hoarders-current-pg')
const Next = document.getElementById('p+hoarders-next-pg')
const Last = document.getElementById('p+hoarders-last-pg')
const Prev = document.getElementById('hoarders-prev-pg')
const Current = document.getElementById('hoarders-current-pg')
const Next = document.getElementById('hoarders-next-pg')
const MinCopies = document.getElementById('p+hoarders-min-copies')
if (Page > 0) {
Prev.parentElement.classList.remove('disabled')
First.parentElement.classList.remove('disabled')
} else {
Prev.parentElement.classList.add('disabled')
First.parentElement.classList.add('disabled')
}
if (Page < Groups.length-1) {
Next.parentElement.classList.remove('disabled')
Last.parentElement.classList.remove('disabled')
} else {
Next.parentElement.classList.add('disabled')
Last.parentElement.classList.add('disabled')
}
First.addEventListener('click', function() {
if (Page > 0) {
Page = 0
UpdateHoardersList()
}
})
Prev.addEventListener('click', function() {
if (Page > 0) {
Page--
Current.innerText = Page+1
Container.innerHTML = Groups[Page].map((x) => `
<div class="card mb-3">
<div class="card-body">
<div class="row">
<div class="col-auto">
<img src="${x.user.avatar}" alt="${x.user.username}" width="72" class="rounded-circle border border-2 border-secondary bg-dark">
</div>
<div class="col d-flex align-items-center">
<div>
<h6 class="mb-1">
<a class="text-reset" href="/users/${x.user.id}">${x.user.username}</a>
</h6>
<small class="text-muted">${x.copies} Copies <i class="fa-solid fa-circle-info" data-bs-toggle="tooltip" data-bs-title="#${x.serials.sort((a, b) => a - b).join(', #')}"></i></small>
</div>
</div>
<div class="col-auto d-flex align-items-center">
<a class="btn btn-warning" type="button" href="/trade/new/${x.user.id}">
<i class="fad fa-exchange-alt me-1"></i>
<span class="d-none d-sm-inline">Trade</span>
</a>
</div>
</div>
</div>
</div>
`).join('')
Utilities.InjectResource('registerTooltips')
if (Page > 0) {
Prev.parentElement.classList.remove('disabled')
} else {
Prev.parentElement.classList.add('disabled')
}
if (Page < Groups.length-1) {
Next.parentElement.classList.remove('disabled')
} else {
Next.parentElement.classList.add('disabled')
}
UpdateHoardersList()
}
})
Next.addEventListener('click', function() {
if (Page < Groups.length-1) {
Page++
UpdateHoardersList()
}
})
Last.addEventListener('click', function() {
if (Page < Groups.length-1) {
Page = Groups.length-1
UpdateHoardersList()
}
})
MinCopies.addEventListener('change', function(){
Page = 0
min = parseInt(MinCopies.options[MinCopies.selectedIndex].value)
console.log(min)
Hoarders = Object.values(Formatted).filter((x, index) => x.copies >= min).sort((a, b) => b.copies - a.copies)
AmountOfHoarders = Hoarders.length
Groups = []
while (Hoarders.length > 0) {
Groups.push(Hoarders.splice(0, 4))
}
UpdateHoardersList()
})
const UpdateHoardersList = function() {
console.log(Hoarders, AmountOfHoarders, Groups)
Current.innerText = Page+1
Container.innerHTML = Groups[Page].map((x) => `
<div class="card mb-3">
<div class="card-body">
<div class="row">
<div class="col-auto">
<img src="${x.user.avatar}" alt="${x.user.username}" width="72" class="rounded-circle border border-2 border-secondary bg-dark">
</div>
<div class="col d-flex align-items-center">
<div>
<h6 class="mb-1">
@ -534,15 +545,18 @@ async function HoardersList(min) {
if (Page > 0) {
Prev.parentElement.classList.remove('disabled')
First.parentElement.classList.remove('disabled')
} else {
Prev.parentElement.classList.add('disabled')
First.parentElement.classList.add('disabled')
}
if (Page < Groups.length-1) {
Next.parentElement.classList.remove('disabled')
Last.parentElement.classList.remove('disabled')
} else {
Next.parentElement.classList.add('disabled')
Last.parentElement.classList.add('disabled')
}
}
})
})
}

View file

@ -15,10 +15,6 @@ chrome.storage.sync.get(['PolyPlus_Settings'], async function(result){
Utilities = await import(chrome.runtime.getURL('resources/utils.js'));
Utilities = Utilities.default
Update()
});
async function Update() {
if (Settings.IRLPriceWithCurrencyOn === true) {
Array.from(ItemGrid.children).forEach(element => {
LoadIRLPrices(element)
@ -33,22 +29,22 @@ async function Update() {
}
if (Settings.EventItemsCatOn === true) {
console.log('is event yay!!')
EventItems()
}
}
});
let UpdateCount = 0
const observer = new MutationObserver(async function (list){
UpdateCount++
console.log(Settings.EventItemsCatOn, document.getElementById('event-items-pagination'), EventItemsShown, UpdateCount)
if (Settings.EventItemsCatOn === true) {
if (document.getElementById('event-items-pagination') === null) {
ItemGrid.classList.add('itemgrid')
ItemGrid.parentElement.classList.remove('col-lg-9')
document.getElementById('pagination').style.display = 'block'
if (document.getElementById('storecat-eventitems') !== null) {
document.getElementById('storecat-eventitems').checked = false
}
} else {
ItemGrid.classList.remove('itemgrid')
ItemGrid.parentElement.classList.add('col-lg-9')
document.getElementById('pagination').style.display = 'none'
}
}
@ -139,7 +135,7 @@ function EventItems() {
Object.values(EventData.eventDetails).forEach((x, index) => {Events.push({
...x,
items: EventData.items.filter((x) => x.event === Object.keys(EventData.eventDetails)[index])
items: EventData.items.filter((x) => x.event === Object.keys(EventData.eventDetails)[index]).sort((a, b) => a.id - b.id)
})})
while (Events.length > 0) {
Groups.push(Events.splice(0, 5))
@ -156,6 +152,14 @@ function EventItems() {
<h6 class="dash-ctitle2">${x.date}</h6>
<h5 class="dash-ctitle">${x.name}</h5>
</div>
${ (x.link !== undefined) ? `
<div class="col-auto d-flex align-items-center">
<a class="text-muted" href="${x.link}">
<span class="d-none d-lg-inline">${ (x.link.startsWith('https://polytoria.com/places/')) ? 'Event Place' : 'Blog Post' }</span>
<i class="fas fa-angle-right ms-2"></i>
</a>
</div>
` : '' }
</div>
<div class="card card-dash mcard mb-3" style="animation-delay: 0.27s;">
<div class="card-body p-0 m-1 scrollFadeContainer">
@ -211,23 +215,34 @@ function EventItems() {
const Container = document.getElementById('p+ei')
const Pagination = document.getElementById('event-items-pagination')
//const First = document.getElementById('p+ei-pagination-first')
const First = document.getElementById('p+ei-pagination-first')
const Prev = document.getElementById('p+ei-pagination-prev')
const Current = document.getElementById('p+ei-pagination-current')
const Next = document.getElementById('p+ei-pagination-next')
//const Last = document.getElementById('p+ei-pagination-last')
const Last = document.getElementById('p+ei-pagination-last')
if (Page > 0) {
Prev.parentElement.classList.remove('disabled')
First.parentElement.classList.remove('disabled')
} else {
Prev.parentElement.classList.add('disabled')
First.parentElement.classList.add('disabled')
}
if (Page < Groups.length-1) {
Next.parentElement.classList.remove('disabled')
Last.parentElement.classList.remove('disabled')
} else {
Next.parentElement.classList.add('disabled')
Last.parentElement.classList.add('disabled')
}
First.addEventListener('click', function() {
if (Page > 0) {
Page = 0
UpdateEventItems()
}
})
Prev.addEventListener('click', function() {
if (Page > 0) {
Page--
@ -242,6 +257,13 @@ function EventItems() {
}
})
Last.addEventListener('click', function() {
if (Page < Groups.length-1) {
Page = Groups.length-1
UpdateEventItems()
}
})
const UpdateEventItems = function() {
Current.innerText = Page+1
Container.innerHTML = Groups[Page].map((x, index) => `
@ -278,13 +300,17 @@ function EventItems() {
if (Page > 0) {
Prev.parentElement.classList.remove('disabled')
First.parentElement.classList.remove('disabled')
} else {
Prev.parentElement.classList.add('disabled')
First.parentElement.classList.add('disabled')
}
if (Page < Groups.length-1) {
Next.parentElement.classList.remove('disabled')
Last.parentElement.classList.remove('disabled')
} else {
Next.parentElement.classList.add('disabled')
Last.parentElement.classList.add('disabled')
}
}
})

View file

@ -3,10 +3,9 @@
"author": "Index",
"name": "Poly+",
"version": "1.11",
"version_name": "Pre-Release Build (stable: v1.1.1)",
"version_name": "Pre-Release Build (v1.1.1)",
"description": "Power-up your Polytoria experience with Poly+! Created by Index.",
"homepage_url": "https://polyplus.vercel.app/",
"download_url": "https://github.com/indexxing/PolyPlus/releases",
"permissions": ["storage", "contextMenus", "tabs", "scripting", "alarms", "notifications"],
"content_scripts": [
{
@ -29,7 +28,7 @@
},
{
"matches": ["https://polytoria.com/my/settings/polyplus-debug/*"],
"matches": ["https://polytoria.com/my/settings/polyplus#dev"],
"js": ["/js/debug.js"]
},
@ -38,11 +37,6 @@
"js": ["/js/places/place-view.js"]
},
{
"matches": ["https://polytoria.com/join-place/**"],
"js": ["/js/places/place-join.js"]
},
{
"matches": ["https://polytoria.com/create/place/**"],
"js": ["/js/places/place-edit.js"]
@ -54,7 +48,7 @@
},
{
"matches": ["https://polytoria.com/users/**"],
"matches": ["https://polytoria.com/u/**"],
"js": ["/js/account/profile.js"]
},
@ -105,7 +99,7 @@
},
{
"matches": ["https://polytoria.com/my/avatar?sandbox=true"],
"matches": ["https://polytoria.com/my/avatar*"],
"js": ["/js/account/avatar-sandbox2.js"]
},

View file

@ -23,7 +23,7 @@
<div class="card mcard mb-3">
<h6 class="card-header">
<i class="fad fa-user-crown"></i>
Avatar
Avatar Sandbox
</h6>
<div class="card-body">
<iframe id="viewFrame" style="width: 100%; height: 314px; border-radius: 0.65rem;"></iframe>
@ -64,7 +64,7 @@
</button>
</div>
</div>
<div class="card mcard">
<div class="card mcard mb-3">
<h6 class="card-header">
<i class="fad fa-palette"></i>
Body Colors
@ -83,6 +83,7 @@
</div>
</div>
</div>
<small class="text-muted text-center" style="font-size: 0.7rem;">feature of Poly+</small>
</div>
<div class="col-12 col-lg-9">
<ul class="nav nav-pills nav-justified mb-3" id="tabs">

View file

@ -1,3 +1,2 @@
var tooltips = document.querySelectorAll('[data-bs-toggle="tooltip"]')
var list = [...tooltips].map(tool => new bootstrap.Tooltip(tool))
console.log(document.currentScript)

View file

@ -67,11 +67,32 @@ export default {
TryOnItemsOn: true,
OutfitCostOn: true,
ShowPlaceRevenueOn: true,
ReplaceItemSalesOn: false
ReplaceItemSalesOn: false,
HoardersListOn: true,
LibraryDownloadsOn: true
},
Limits: {
PinnedGames: 10
PinnedGames: 10,
BestFriends: 10,
ImprovedFrLists: 25,
ItemWishlist: 30
},
MeshTypes: [
"hat",
"hair",
"head attachment",
"face accessory",
"neck accessory",
"head cover",
"back accessory",
"shoulder accessory",
"tool"
],
TextureTypes: [
"Shirt",
"Pants",
"Face"
],
CalculateIRL: async function(bricks, to, brickPackage) {
/*
Disabled for now: currency retrieval from currencies.json
@ -84,57 +105,84 @@ export default {
const UnitPrice = data.Data[brickPackage][to]
*/
let Icon = "$"
let Result = "N/A";
let Display = "Currency Not Found";
// is the icon abbreviated text, or an entity
let IsIconAbbr = false
bricks = ParseFullNumber(bricks.replace(/,/g, ''))
switch (to) {
// U.S. Dollar
case 0:
Result = (bricks * 0.0099).toFixed(2)
Display = "USD"
break
// Euro
case 1:
Icon = "&#8364;"
Result = (bricks * 0.009).toFixed(2)
Display = "EUR"
break
// Canadian Dollar
case 2:
Icon = "CAD$"
IsIconAbbr = true
Result = (bricks * 0.0131).toFixed(2)
Display = "CAD"
break
// Great British Pound
case 3:
Icon = "&#163;"
Result = (bricks * 0.0077).toFixed(2)
Display = "GBP"
break
// Mexican Peso
case 4:
Icon = "MXN$"
IsIconAbbr = true
Result = (bricks * 0.1691).toFixed(2)
Display = "MXN"
break
// Australia Dollar
case 5:
Icon = "AU$"
IsIconAbbr = true
Result = (bricks * 0.0144).toFixed(2)
Display = "AUD"
break
// Turkish Lira
case 6:
Icon = "&#8378;"
Result = (bricks * 0.2338).toFixed(2)
Display = "TRY"
break
// Brazillian Real
case 7:
Icon = "R$"
IsIconAbbr = true
Result = (bricks * 0.49).toFixed(2)
Display = "BRL"
break
}
@ -142,7 +190,9 @@ export default {
return {
result: Result,
display: Display
display: Display,
icon: Icon,
isIconAbbr: IsIconAbbr
}
},
InjectResource: function(path, element) {

View file

@ -328,7 +328,7 @@
<button class="btn btn-sm toggle-btn" data-setting="PinnedGamesOn">Toggle</button>
</span>
<br>
<span class="desc">Pin your favorite places to the top of the homepage! (limit: 5 places)</span>
<span class="desc">Pin your favorite places to the top of the homepage! (limit: <span id="PinnedGames-limit"></span> places)</span>
</p>
<p class="setting-container" id="forum-mentions">
<span class="indicator">&nbsp;</span>
@ -339,7 +339,7 @@
<br>
<span class="desc">Get a quick link to the popular person everyone is talking about's profile!</span>
<br>
<span style="font-size: 0.8rem; color: orange;">* Forum Mentions do not notify the user.</span>
<span style="font-size: 0.8rem; color: orange;">* Forum Mentions do not notify the user or show up as a notification on their account.</span>
</p>
<p class="setting-container" id="best-friends">
<span class="indicator">&nbsp;</span>
@ -348,7 +348,7 @@
<button class="btn btn-sm toggle-btn" data-setting="BestFriendsOn">Toggle</button>
</span>
<br>
<span class="desc">Prioritize the bestest of friends on applicable friend lists! (limit: 7 best friends)</span>
<span class="desc">Prioritize the bestest of friends on applicable friend lists! (limit: <span id="BestFriends-limit"></span> best friends)</span>
</p>
<p class="setting-container" id="improved-friend-lists">
<span class="indicator">&nbsp;</span>
@ -360,7 +360,7 @@
<span class="desc">
Accept or decline all friend requests with the click of a button or multi-remove existing friends!
<br>
<span style="font-size: 0.8rem; color: orange;">* You can only remove up to 25 friends at once.</span>
<span style="font-size: 0.8rem; color: orange;">* You can only remove up to <span id="ImprovedFrLists-limit"></span> friends at once.</span>
</span>
</p>
<p class="setting-container" id="irl-price-with-brick-count">
@ -434,6 +434,8 @@
</span>
<br>
<span class="desc">Easily find what you're looking for with more search filters side-wide! (this does not affect the main site search on the navbar)</span>
<br>
<span style="font-size: 0.8rem; color: orange;">* This currently only has a "Creator" username filter on the forum search page, more search filters are yet to come.</span>
</p>
<p class="setting-container" id="apply-membership-theme">
<span class="indicator">&nbsp;</span>
@ -484,6 +486,7 @@
Wishlist that item that you REALLY want!
</span>
</p>
<!--
<p class="setting-container" id="hide-upgrade-button">
<span class="indicator">&nbsp;</span>
<span class="title">
@ -493,6 +496,7 @@
<br>
<span class="desc">Hide the ugly blue "Upgrade" button on the sidebar!</span>
</p>
-->
<p class="setting-container" id="try-on-items">
<span class="indicator">&nbsp;</span>
<span class="title">
@ -535,10 +539,14 @@
<span class="indicator">&nbsp;</span>
<span class="title">
Collectibles' Hoarders List
<button class="btn btn-sm toggle-btn" data-setting="HoardersListOn">Toggle</button>
<button class="btn btn-sm toggle-btn" data-setting="Enabled" data-parent="HoardersList">Toggle</button>
</span>
<br>
<span class="desc">List all the users that have more than 1 copy of a collectible!</span>
<span class="form-check form-switch">
<input class="form-check-input" type="checkbox" role="switch" id="hoarders-list-avatars" data-setting="AvatarsEnabled" data-parent="HoardersList">
<label class="form-check-label" for="hoarders-list-avatars">Show Avatar Icons (more requests, resulting in more ratelimiting potentially)</label>
</span>
</p>
<p class="setting-container" id="hoarders-list">
<span class="indicator">&nbsp;</span>
@ -549,6 +557,24 @@
<br>
<span class="desc">Quickly download a model (as a <code>.ptmd</code> file), mesh, decal, or sound right from the page showing you details about the asset!</span>
</p>
<p class="setting-container" id="event-items-store">
<span class="indicator">&nbsp;</span>
<span class="title">
"Event Items" Store Category
<button class="btn btn-sm toggle-btn" data-setting="EventItemsCatOn">Toggle</button>
</span>
<br>
<span class="desc">List all the on-going and past event items separated by their event with a store category!</span>
</p>
<p class="setting-container" id="event-items-store">
<span class="indicator">&nbsp;</span>
<span class="title">
Show Friend Count on Homepage
<button class="btn btn-sm toggle-btn" data-setting="HomeFriendsCountOn">Toggle</button>
</span>
<br>
<span class="desc">See how many friends you have on your homepage/dashboard, just scroll to the "friends" section and you'll see it next to the heading!</span>
</p>
<div class="card">
<div class="card-body">
<h3>EXPERIMENTAL SETTINGS</h3>
@ -591,16 +617,16 @@
<br>
<span style="font-size: 0.8rem; color: orange;">* The styling for this feature is not yet done.</span>
</p>
<p class="setting-container" id="event-items-store">
<p class="setting-container" id="avatar-sandbox">
<span class="indicator">&nbsp;</span>
<span class="title">
"Event Items" Store Category
<button class="btn btn-sm toggle-btn" data-setting="EventItemsCatOn">Toggle</button>
Avatar Sandbox
<button class="btn btn-sm toggle-btn" data-setting="AvatarSandboxOn">Toggle</button>
</span>
<br>
<span class="desc">List all the on-going and past event items separated by their event with a store category!</span>
<span class="desc">Create an avatar with all the item possibilities available to your heart's content!</span>
<br>
<span style="font-size: 0.8rem; color: orange;">* This feature is expected to break when messing with store filters.</span>
<span style="font-size: 0.8rem; color: orange;">* This feature is not polished - things like modifying avatar "Body Colors", pagination, outfits, etc haven't been added.</span>
</p>
</div>
</div>

View file

@ -10,8 +10,12 @@ var Utilities;
Utilities = Utilities.default
ExpectedSettings = Utilities.DefaultSettings
LoadCurrent()
document.getElementById('PinnedGames-limit').innerText = Utilities.Limits.PinnedGames
document.getElementById('BestFriends-limit').innerText = Utilities.Limits.BestFriends
document.getElementById('ImprovedFrLists-limit').innerText = Utilities.Limits.ImprovedFrLists
document.getElementById('ItemWishlist-limit').innerText = Utilities.Limits.ItemWishlist
})();
// Handle buttons at the bottom of the page
@ -50,13 +54,54 @@ Elements.forEach(element => {
let Button = element.getElementsByTagName('button')[0]
let Options = element.getElementsByTagName('button')[1]
let Select = element.getElementsByTagName('select') || []
let Checkbox = element.getElementsByTagName('input') || []
console.log(Checkbox)
if (Button) {
Button.addEventListener('click', function() {
if (!(Button.getAttribute('data-parent'))) {
ToggleSetting(Button.getAttribute('data-setting'), element)
} else {
let Parent = Button.getAttribute('data-parent')
if (!isNaN(parseInt(Parent))) {
Parent = parseInt(Parent)
}
if (!Settings[Parent]) {
Settings[Parent] = {}
console.log('empty btn')
}
console.log(Button.getAttribute('data-setting'), Parent, Settings[Parent])
ToggleSetting(Button.getAttribute('data-setting'), element, Parent)
}
});
}
Array.from(Checkbox).forEach(check => {
console.log('anotha one')
check.addEventListener('click', function(){
console.log('clicky')
if (!(check.getAttribute('data-parent'))) {
console.log('no dad?')
ToggleSetting(check.getAttribute('data-setting'), element)
} else {
console.log('dad came back with milk')
let Parent = check.getAttribute('data-parent')
if (!isNaN(parseInt(Parent))) {
Parent = parseInt(Parent)
}
if (!Settings[Parent]) {
Settings[Parent] = {}
console.log('empty')
}
console.log(check.getAttribute('data-setting'), Parent, Settings[Parent])
ToggleSetting(check.getAttribute('data-setting'), null, Parent)
}
})
})
if (Options) {
Options.addEventListener('click', function() {
let Modal = document.getElementById(Options.getAttribute('data-modal') + '-Modal')
@ -192,20 +237,36 @@ function LoadCurrent() {
});
}
function ToggleSetting(Name, Element) {
const ToggleBtn = Element.getElementsByClassName('toggle-btn')[0]
function ToggleSetting(Name, Element, Parent) {
document.title = "*unsaved | Poly+ Settings"
let Status;
if (!Parent) {
Status = Settings[Name]
if (Settings[Name] === true) {
Settings[Name] = false;
ToggleBtn.innerText = 'Enable'
} else {
Settings[Name] = true;
}
} else {
Status = Settings[Parent][Name]
if (Settings[Parent][Name] === true) {
Settings[Parent][Name] = false;
} else {
Settings[Parent][Name] = true;
}
}
if (Element !== null) {
const ToggleBtn = Element.getElementsByClassName('toggle-btn')[0]
if (Status === false) {
ToggleBtn.innerText = 'Enable'
} else {
ToggleBtn.innerText = 'Disable'
}
Element.classList.toggle('enabled')
Element.classList.toggle('disabled')
ToggleBtn.classList.toggle('btn-success')
ToggleBtn.classList.toggle('btn-danger')
}
if (SaveBtn.getAttribute('disabled')) {
SaveBtn.removeAttribute('disabled')