You've already forked tf2wikipricing
feat: add australiums to price table
This commit is contained in:
@@ -217,6 +217,27 @@ async function inject() {
|
|||||||
|
|
||||||
priceRows.push({quality: quality, row: priceRow})
|
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(() => {
|
Promise.all(promises).then(() => {
|
||||||
priceRows.sort((a, b) => {
|
priceRows.sort((a, b) => {
|
||||||
// Sort 6 first always, then numerically
|
// Sort 6 first always, then numerically
|
||||||
|
|||||||
@@ -2,13 +2,16 @@ import { ItemPriceData } from "./priceService";
|
|||||||
import { formatPrice } from "./utils/formatting";
|
import { formatPrice } from "./utils/formatting";
|
||||||
import { $T } from "./utils/localization";
|
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 priceRow = document.createElement("tr");
|
||||||
|
|
||||||
const priceLabel = document.createElement("td");
|
const priceLabel = document.createElement("td");
|
||||||
priceLabel.className = "infobox-label";
|
priceLabel.className = "infobox-label";
|
||||||
const priceLabelLink = document.createElement("a");
|
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)
|
priceLabelLink.innerText = $T(qualityName)
|
||||||
priceLabel.appendChild(priceLabelLink);
|
priceLabel.appendChild(priceLabelLink);
|
||||||
priceLabel.innerHTML += ':'
|
priceLabel.innerHTML += ':'
|
||||||
|
|||||||
Reference in New Issue
Block a user