From 279cf4da9d1415331c66892fe6f126e63f2089dd Mon Sep 17 00:00:00 2001 From: xenticore Date: Fri, 28 Mar 2025 23:48:29 -0400 Subject: [PATCH] feat: add australiums to price table --- src/content/content.ts | 21 +++++++++++++++++++++ src/content/uiRenderer.ts | 7 +++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/content/content.ts b/src/content/content.ts index d0eb5bf..052cf9e 100644 --- a/src/content/content.ts +++ b/src/content/content.ts @@ -217,6 +217,27 @@ async function inject() { priceRows.push({quality: quality, row: priceRow}) }) + + // Check item schema for Australium variant of current defindex + if(itemSchema[itemIndex].hasAustraliumVariant) { + promises.push(new Promise(async (resolve) => { + logDebug(`Fetching price for Australium ${itemName}`) + var data: ItemPriceData | null + try { + data = await fetchPrice(token, `${itemIndex};11;australium`, currentTime); + updateTime = new Date(data.update) + } catch { + log(`Australium ${itemName} is unpriced or unavailable, skipping...`) + } + + const priceRow = createPriceRow($T("Australium"), data, keyPrice, locale, "https://wiki.teamfortress.com/wiki/Australium_weapons") + + priceRows.push({quality: 99, row: priceRow}) + resolve() + return + })) + } + Promise.all(promises).then(() => { priceRows.sort((a, b) => { // Sort 6 first always, then numerically diff --git a/src/content/uiRenderer.ts b/src/content/uiRenderer.ts index 38c30ce..3d65acf 100644 --- a/src/content/uiRenderer.ts +++ b/src/content/uiRenderer.ts @@ -2,13 +2,16 @@ import { ItemPriceData } from "./priceService"; import { formatPrice } from "./utils/formatting"; import { $T } from "./utils/localization"; -export function createPriceRow(qualityName: string, data: ItemPriceData, keyPrice: ItemPriceData, locale: string): HTMLTableRowElement { +export function createPriceRow(qualityName: string, data: ItemPriceData, keyPrice: ItemPriceData, locale: string, wikiPage: string = null): HTMLTableRowElement { const priceRow = document.createElement("tr"); const priceLabel = document.createElement("td"); priceLabel.className = "infobox-label"; const priceLabelLink = document.createElement("a"); - priceLabelLink.href = locale === 'en' ? `https://wiki.teamfortress.com/wiki/${qualityName}` : `https://wiki.teamfortress.com/wiki/${qualityName}/${locale}` + if (wikiPage == null) { + wikiPage = `https://wiki.teamfortress.com/wiki/${qualityName}` + } + priceLabelLink.href = locale === 'en' ? wikiPage : `${wikiPage}/${locale}` priceLabelLink.innerText = $T(qualityName) priceLabel.appendChild(priceLabelLink); priceLabel.innerHTML += ':'