You've already forked tf2wikipricing
Merge branch 'develop'
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "tf2wikipricing",
|
"name": "tf2wikipricing",
|
||||||
"version": "0.5.0",
|
"version": "0.6.0",
|
||||||
"description": "Adds item pricing to the Team Fortress 2 wiki",
|
"description": "Adds item pricing to the Team Fortress 2 wiki",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@happy-dom/global-registrator": "^17.4.4",
|
"@happy-dom/global-registrator": "^17.4.4",
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import styleCss from './style.css'
|
|||||||
import { logDebug, log, logError } from './utils/log'
|
import { logDebug, log, logError } from './utils/log'
|
||||||
import { getPricesToken, priceUsingPricesTF } from './pricing/pricestf'
|
import { getPricesToken, priceUsingPricesTF } from './pricing/pricestf'
|
||||||
import itemQualities from 'tf2-static-schema/static/qualities.json';
|
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 { $T, extractLocaleFromURL } from './utils/localization'
|
||||||
import { fetchPrice, fetchKeyPrice, ItemPriceData } from './priceService'
|
import { fetchPrice, fetchKeyPrice, ItemPriceData } from './priceService'
|
||||||
import { createPriceRow, createStoreButton } from './uiRenderer'
|
import { createPriceRow, createStoreButton } from './uiRenderer'
|
||||||
@@ -190,7 +190,8 @@ async function inject() {
|
|||||||
enum PriceRowCategory {
|
enum PriceRowCategory {
|
||||||
None,
|
None,
|
||||||
Festive,
|
Festive,
|
||||||
Botkiller
|
Botkiller,
|
||||||
|
KillstreakKit
|
||||||
}
|
}
|
||||||
|
|
||||||
interface PriceRow {
|
interface PriceRow {
|
||||||
@@ -255,6 +256,7 @@ async function inject() {
|
|||||||
festiveHeading.innerText = $T("Festive")
|
festiveHeading.innerText = $T("Festive")
|
||||||
festiveHeading.style.fontSize = '1em';
|
festiveHeading.style.fontSize = '1em';
|
||||||
festiveHeading.style.backgroundColor = '#F5C087';
|
festiveHeading.style.backgroundColor = '#F5C087';
|
||||||
|
festiveHeadingRow.style.display = 'none';
|
||||||
festiveHeadingRow.appendChild(festiveHeading);
|
festiveHeadingRow.appendChild(festiveHeading);
|
||||||
|
|
||||||
promises.push(new Promise(async (resolve) => {
|
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
|
// Silver Mk.I, Gold Mk.II, Rust, Blood, Carbonado, Diamond, Silver Mk.II, Gold Mk.II
|
||||||
const botkillerOrder = [
|
const botkillerOrder = [
|
||||||
"Silver",
|
"Silver",
|
||||||
@@ -312,6 +359,7 @@ async function inject() {
|
|||||||
festiveHeading.innerText = $T("Botkiller")
|
festiveHeading.innerText = $T("Botkiller")
|
||||||
festiveHeading.style.fontSize = '1em';
|
festiveHeading.style.fontSize = '1em';
|
||||||
festiveHeading.style.backgroundColor = '#F5C087';
|
festiveHeading.style.backgroundColor = '#F5C087';
|
||||||
|
botKillerHeadingRow.style.display = 'none';
|
||||||
botKillerHeadingRow.appendChild(festiveHeading);
|
botKillerHeadingRow.appendChild(festiveHeading);
|
||||||
|
|
||||||
itemSchema[itemIndex].botkillerVariants.map((variantIndex) => {
|
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(botKillerHeadingRow) priceInfoboxHeadingRow.insertAdjacentElement('afterend', botKillerHeadingRow);
|
||||||
if(festiveHeadingRow) priceInfoboxHeadingRow.insertAdjacentElement('afterend', festiveHeadingRow);
|
if(festiveHeadingRow) priceInfoboxHeadingRow.insertAdjacentElement('afterend', festiveHeadingRow);
|
||||||
|
|
||||||
@@ -355,10 +404,15 @@ async function inject() {
|
|||||||
break;
|
break;
|
||||||
case PriceRowCategory.Festive:
|
case PriceRowCategory.Festive:
|
||||||
festiveHeadingRow.insertAdjacentElement('afterend', element.row);
|
festiveHeadingRow.insertAdjacentElement('afterend', element.row);
|
||||||
|
festiveHeadingRow.style.display = 'revert';
|
||||||
break;
|
break;
|
||||||
case PriceRowCategory.Botkiller:
|
case PriceRowCategory.Botkiller:
|
||||||
botKillerHeadingRow.insertAdjacentElement('afterend', element.row);
|
botKillerHeadingRow.insertAdjacentElement('afterend', element.row);
|
||||||
|
botKillerHeadingRow.style.display = 'revert';
|
||||||
break;
|
break;
|
||||||
|
case PriceRowCategory.KillstreakKit:
|
||||||
|
killstreakKitHeadingRow.insertAdjacentElement('afterend', element.row);
|
||||||
|
killstreakKitHeadingRow.style.display = 'revert';
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
if(!updateTime || !(updateTime instanceof Date) || isNaN(+updateTime)) updateTime = new Date()
|
if(!updateTime || !(updateTime instanceof Date) || isNaN(+updateTime)) updateTime = new Date()
|
||||||
|
|||||||
@@ -35,4 +35,10 @@ module.exports = {
|
|||||||
"Diamond": "Diamond",
|
"Diamond": "Diamond",
|
||||||
"Silver Mk.II": "Silver Mk.II",
|
"Silver Mk.II": "Silver Mk.II",
|
||||||
"Gold Mk.II": "Gold 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",
|
||||||
}
|
}
|
||||||
@@ -35,4 +35,10 @@ module.exports = {
|
|||||||
"Diamond": "Diamante",
|
"Diamond": "Diamante",
|
||||||
"Silver Mk.II": "Plata Mk.II",
|
"Silver Mk.II": "Plata Mk.II",
|
||||||
"Gold Mk.II": "Oro 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",
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user