Merge branch 'develop'

This commit is contained in:
xenticore
2025-04-07 17:32:38 -04:00
4 changed files with 69 additions and 3 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "tf2wikipricing",
"version": "0.5.0",
"version": "0.6.0",
"description": "Adds item pricing to the Team Fortress 2 wiki",
"devDependencies": {
"@happy-dom/global-registrator": "^17.4.4",

View File

@@ -3,7 +3,7 @@ import styleCss from './style.css'
import { logDebug, log, logError } from './utils/log'
import { getPricesToken, priceUsingPricesTF } from './pricing/pricestf'
import itemQualities from 'tf2-static-schema/static/qualities.json';
import { getItemIndexByName, getTradableStatusByDefindex, ItemSchema, prepareSchema, wipeSchema } from './schemaService'
import { getItemIndexByName, getTradableStatusByDefindex, ItemSchema, ItemSlot, prepareSchema, wipeSchema } from './schemaService'
import { $T, extractLocaleFromURL } from './utils/localization'
import { fetchPrice, fetchKeyPrice, ItemPriceData } from './priceService'
import { createPriceRow, createStoreButton } from './uiRenderer'
@@ -190,7 +190,8 @@ async function inject() {
enum PriceRowCategory {
None,
Festive,
Botkiller
Botkiller,
KillstreakKit
}
interface PriceRow {
@@ -255,6 +256,7 @@ async function inject() {
festiveHeading.innerText = $T("Festive")
festiveHeading.style.fontSize = '1em';
festiveHeading.style.backgroundColor = '#F5C087';
festiveHeadingRow.style.display = 'none';
festiveHeadingRow.appendChild(festiveHeading);
promises.push(new Promise(async (resolve) => {
@@ -291,6 +293,51 @@ async function inject() {
}))
}
var killstreakKitHeadingRow: HTMLTableRowElement | null
// Check for Killstreak Kits
if(itemSchema[itemIndex].slot == ItemSlot.Primary ||
itemSchema[itemIndex].slot == ItemSlot.Secondary ||
itemSchema[itemIndex].slot == ItemSlot.Melee)
{
/// Create subheading
killstreakKitHeadingRow = document.createElement("tr")
const heading = document.createElement("th")
heading.className = "infobox-subheader"
heading.colSpan = 2
heading.innerText = $T("Killstreak Kit")
heading.style.fontSize = '1em';
heading.style.backgroundColor = '#F5C087';
killstreakKitHeadingRow.style.display = 'none';
killstreakKitHeadingRow.appendChild(heading);
[1,2,3].map((tier) => {
promises.push(new Promise(async (resolve) => {
logDebug(`Fetching price for ${itemName} Killstreak Kit Tier ${tier}`)
var data: ItemPriceData | null
try {
var kitIndex: number
switch (tier) {
default:
case 1: kitIndex = 6527; break;
case 2: kitIndex = 6523; break;
case 3: kitIndex = 6526; break;
}
data = await fetchPrice(token, `${kitIndex};6;uncraftable;kt-${tier};td-${itemIndex}`, currentTime);
updateTime = new Date(data.update)
} catch {
log(`${itemName} Killstreak Kit Tier ${tier} is unpriced or unavailable, skipping...`)
resolve()
return
}
const priceRow = createPriceRow($T(`kt-${tier}`), data, keyPrice, locale, "https://wiki.teamfortress.com/wiki/Killstreak_Kit")
priceRows.push({order: tier, row: priceRow, category: PriceRowCategory.KillstreakKit})
resolve()
return
}))
})
}
// Silver Mk.I, Gold Mk.II, Rust, Blood, Carbonado, Diamond, Silver Mk.II, Gold Mk.II
const botkillerOrder = [
"Silver",
@@ -312,6 +359,7 @@ async function inject() {
festiveHeading.innerText = $T("Botkiller")
festiveHeading.style.fontSize = '1em';
festiveHeading.style.backgroundColor = '#F5C087';
botKillerHeadingRow.style.display = 'none';
botKillerHeadingRow.appendChild(festiveHeading);
itemSchema[itemIndex].botkillerVariants.map((variantIndex) => {
@@ -339,6 +387,7 @@ async function inject() {
})
}
if(killstreakKitHeadingRow) priceInfoboxHeadingRow.insertAdjacentElement('afterend', killstreakKitHeadingRow);
if(botKillerHeadingRow) priceInfoboxHeadingRow.insertAdjacentElement('afterend', botKillerHeadingRow);
if(festiveHeadingRow) priceInfoboxHeadingRow.insertAdjacentElement('afterend', festiveHeadingRow);
@@ -355,10 +404,15 @@ async function inject() {
break;
case PriceRowCategory.Festive:
festiveHeadingRow.insertAdjacentElement('afterend', element.row);
festiveHeadingRow.style.display = 'revert';
break;
case PriceRowCategory.Botkiller:
botKillerHeadingRow.insertAdjacentElement('afterend', element.row);
botKillerHeadingRow.style.display = 'revert';
break;
case PriceRowCategory.KillstreakKit:
killstreakKitHeadingRow.insertAdjacentElement('afterend', element.row);
killstreakKitHeadingRow.style.display = 'revert';
}
})
if(!updateTime || !(updateTime instanceof Date) || isNaN(+updateTime)) updateTime = new Date()

View File

@@ -35,4 +35,10 @@ module.exports = {
"Diamond": "Diamond",
"Silver Mk.II": "Silver Mk.II",
"Gold Mk.II": "Gold Mk.II",
// Killstreak tiers sourced from TF2 wiki
"Killstreak Kit": "Killstreak Kit",
"kt-1": "Standard",
"kt-2": "Specialized",
"kt-3": "Professional",
}

View File

@@ -35,4 +35,10 @@ module.exports = {
"Diamond": "Diamante",
"Silver Mk.II": "Plata Mk.II",
"Gold Mk.II": "Oro Mk.II",
// Killstreak tiers sourced from TF2 wiki
"Killstreak Kit": "Kit Cuentarrachas",
"kt-1": "Standard",
"kt-2": "Especializado",
"kt-3": "Profesional",
}