Add IRL prices to Guild Stores and Improved Theme Loading
- Updated the way the Theme Creator loads themes, it now loads instantly on page load! (credit to SK-Fast's old Poly+ extension for the realization) - Guild stores now have IRL prices listed if the "Show IRL Price with Brick Count" setting is enabled.
This commit is contained in:
parent
251e28edeb
commit
f4a8163745
3 changed files with 83 additions and 2 deletions
|
|
@ -12,7 +12,7 @@ let Theme = null;
|
|||
|
||||
// If theme exists, create a style element to represent it
|
||||
if (Settings.ThemeCreatorOn && Settings.ThemeCreatorOn === true) {
|
||||
Theme = document.createElement('style')
|
||||
//Theme = document.createElement('style')
|
||||
switch (Settings.ThemeCreator.BGImageSize) {
|
||||
case 0:
|
||||
Settings.ThemeCreator.BGImageSize = 'fit'
|
||||
|
|
@ -24,7 +24,7 @@ let Theme = null;
|
|||
Settings.ThemeCreator.BGImageSize = 'contain'
|
||||
break
|
||||
}
|
||||
Theme.innerHTML = `
|
||||
Theme = `
|
||||
:root {
|
||||
--polyplus-navbgcolor: ${Settings.ThemeCreator.NavBGColor};
|
||||
--polyplus-navbordercolor: ${Settings.ThemeCreator.NavBorderColor};
|
||||
|
|
@ -111,6 +111,10 @@ let Theme = null;
|
|||
color: var(--polyplus-sidebaritemlabelcolor) !important;
|
||||
}
|
||||
`
|
||||
|
||||
const ThemeBlob = new Blob([Theme], { type: 'text/css' })
|
||||
const ThemeURL = window.URL.createObjectURL(ThemeBlob)
|
||||
document.head.innerHTML += `<link href="${ThemeURL}" rel="stylesheet" type="text/css">`
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -119,6 +123,7 @@ let Theme = null;
|
|||
return
|
||||
}
|
||||
|
||||
/*
|
||||
// Check if Theme Exists, if so Load It
|
||||
if (Settings.ThemeCreatorOn && Settings.ThemeCreatorOn === true) {
|
||||
if (!(Settings.ThemeCreator.WebsiteLogo === null)) {
|
||||
|
|
@ -128,6 +133,7 @@ let Theme = null;
|
|||
if (Settings.ThemeCreatorOn && Settings.ThemeCreatorOn === true && Theme != null) {
|
||||
document.body.prepend(Theme)
|
||||
}
|
||||
*/
|
||||
|
||||
// Define Data
|
||||
const UserData = {
|
||||
|
|
|
|||
70
js/guilds.js
Normal file
70
js/guilds.js
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
const StoreItems = document.getElementById('store-items')
|
||||
|
||||
var Settings;
|
||||
let Utilities;
|
||||
|
||||
chrome.storage.sync.get(['PolyPlus_Settings'], function(result){
|
||||
Settings = result.PolyPlus_Settings
|
||||
|
||||
if (Settings.IRLPriceWithCurrencyOn === true) {
|
||||
(async () => {
|
||||
Utilities = await import(chrome.runtime.getURL('/js/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() {
|
||||
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") {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
IRLPrice(element)
|
||||
}
|
||||
}
|
||||
}
|
||||
observer.observe(StoreItems, {attributes: false,childList: true,subtree: false});
|
||||
}
|
||||
});
|
||||
|
||||
observer.observe(StoreItems, {attributes: false,childList: true,subtree: false});
|
||||
|
|
@ -109,6 +109,11 @@
|
|||
{
|
||||
"matches": ["https://polytoria.com/inbox/*", "https://polytoria.com/inbox?*"],
|
||||
"js": ["/js/account/inbox.js"]
|
||||
},
|
||||
|
||||
{
|
||||
"matches": ["https://polytoria.com/guilds/**"],
|
||||
"js": ["/js/guilds.js"]
|
||||
}
|
||||
],
|
||||
"background": {
|
||||
|
|
|
|||
Reference in a new issue