This repository has been archived on 2026-01-04. You can view files and clone it, but cannot push or open issues or pull requests.
polyplus/js/guilds.js
Index fc230ec3b8 rewrote settings and new features
- rewrote settings

- reorganized several settings as nested objects

- added avatars enabled sub-setting of collectibles hoarder list

- added default min copies

- new feature: "Timed-Item Owner Check"

- new feature: "Hide User Ads"
2024-05-27 17:01:25 -05:00

52 lines
No EOL
1.9 KiB
JavaScript

const StoreItems = document.getElementById('store-items')
var Settings;
let Utilities;
chrome.storage.sync.get(['PolyPlus_Settings'], function(result){
Settings = result.PolyPlus_Settings
if (Settings.IRLPriceWithCurrency.Enabled === true) {
(async () => {
Utilities = await import(chrome.runtime.getURL('resources/utils.js'));
Utilities = Utilities.default
for (let item of Array.from(StoreItems.children)) {
IRLPrice(item)
}
const PreviousPage = document.querySelector('#store-prev a')
const NextPage = document.querySelector('#store-next a')
//PreviousPage.addEventListener('click', IRLPrice)
//NextPage.addEventListener('click', IRLPrice)
})();
}
});
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.IRLPriceWithCurrency.Currency)
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)
}
}
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.IRLPriceWithCurrency.Enabled === true) {
IRLPrice(element)
}
}
}
observer.observe(StoreItems, {attributes: false,childList: true,subtree: false});
}
});
observer.observe(StoreItems, {attributes: false,childList: true,subtree: false});