You've already forked tf2wikipricing
lint: var to let/const
This commit is contained in:
@@ -10,10 +10,10 @@ import { createPriceRow, createStoreButton } from './uiRenderer'
|
||||
import { findFirstElement, findFirstChildElement } from './utils/dom'
|
||||
import { extractPageTitleFromURL } from './utils/url';
|
||||
import { ExchangeRates, prepareExchangeRates } from './exchangeRateService';
|
||||
var itemSchema: ItemSchema | null;
|
||||
var exchangeRates: ExchangeRates | null;
|
||||
let itemSchema: ItemSchema | null;
|
||||
let exchangeRates: ExchangeRates | null;
|
||||
|
||||
var locale: string = 'en'
|
||||
let locale: string = 'en'
|
||||
|
||||
/** Exclude these from the pricelist. */
|
||||
const excludedQualities = new Set([
|
||||
@@ -33,8 +33,8 @@ async function inject() {
|
||||
// Not an item page
|
||||
return;
|
||||
}
|
||||
var itemIndex: number | null = null;
|
||||
var itemName: string | null = null;
|
||||
let itemIndex: number | null = null;
|
||||
let itemName: string | null = null;
|
||||
|
||||
// Find buy buttons
|
||||
const buyButton = findFirstChildElement('.btn_buynow', itemInfobox);
|
||||
@@ -94,7 +94,7 @@ async function inject() {
|
||||
return;
|
||||
}
|
||||
|
||||
var qualities: number[] = []
|
||||
const qualities: number[] = []
|
||||
|
||||
const firstQualityTag = findFirstChildElement('.quality-tag', itemInfobox);
|
||||
|
||||
@@ -122,7 +122,7 @@ async function inject() {
|
||||
// th.infobox-header (Basic Information)
|
||||
// ...
|
||||
|
||||
var storeButtons: HTMLTableRowElement[] = [];
|
||||
const storeButtons: HTMLTableRowElement[] = [];
|
||||
|
||||
// backpack.tf button
|
||||
storeButtons.push(createStoreButton("backpack.tf", new URL(`https://backpack.tf/classifieds?item=${encodeURIComponent(itemName)}`)));
|
||||
@@ -171,7 +171,7 @@ async function inject() {
|
||||
priceProgressRow.appendChild(priceProgressData);
|
||||
priceInfoboxHeadingRow.insertAdjacentElement('afterend', priceProgressRow);
|
||||
|
||||
var token: string | null;
|
||||
let token: string | null;
|
||||
|
||||
// Steam Community Market
|
||||
// TODO: Change this to lazy-load, so that it doesn't make network requests when we have cached data.
|
||||
@@ -187,7 +187,7 @@ async function inject() {
|
||||
log('Failed to get an access token for prices.tf: ' + err);
|
||||
}
|
||||
|
||||
var updateTime: Date | null = null;
|
||||
let updateTime: Date | null = null;
|
||||
|
||||
enum PriceRowCategory {
|
||||
None,
|
||||
@@ -201,19 +201,19 @@ async function inject() {
|
||||
row: HTMLTableRowElement
|
||||
category: PriceRowCategory
|
||||
}
|
||||
var priceRows: PriceRow[]= [];
|
||||
const priceRows: PriceRow[]= [];
|
||||
|
||||
// Get current key price
|
||||
const keyPrice = await fetchKeyPrice(token);
|
||||
|
||||
var currentTime = new Date()
|
||||
const currentTime = new Date()
|
||||
|
||||
const promises = qualities.filter(x => !excludedQualities.has(x)).map(async (quality) => {
|
||||
|
||||
const qualifiedName = ((quality != 6 ? itemQualities[quality as unknown as keyof typeof itemQualities].toString() : '') + ' ' + itemName).trim()
|
||||
// logDebug(`Fetching price for ${qualifiedName}`)
|
||||
|
||||
var data: ItemPriceData | null
|
||||
let data: ItemPriceData | null
|
||||
try {
|
||||
data = await fetchPrice(token, itemIndex + ";" + quality, currentTime);
|
||||
updateTime = new Date(data.update)
|
||||
@@ -231,7 +231,7 @@ async function inject() {
|
||||
if(itemSchema[itemIndex].hasAustraliumVariant) {
|
||||
promises.push(new Promise(async (resolve) => {
|
||||
logDebug(`Fetching price for Australium ${itemName}`)
|
||||
var data: ItemPriceData | null
|
||||
let data: ItemPriceData | null
|
||||
try {
|
||||
data = await fetchPrice(token, `${itemIndex};11;australium`, currentTime);
|
||||
updateTime = new Date(data.update)
|
||||
@@ -247,7 +247,7 @@ async function inject() {
|
||||
}))
|
||||
}
|
||||
|
||||
var festiveHeadingRow: HTMLTableRowElement | null
|
||||
let festiveHeadingRow: HTMLTableRowElement | null
|
||||
// Check item schema for Festive variant of current defindex
|
||||
if(itemSchema[itemIndex].festiveVariant != null) {
|
||||
/// Create subheading
|
||||
@@ -263,7 +263,7 @@ async function inject() {
|
||||
|
||||
promises.push(new Promise(async (resolve) => {
|
||||
logDebug(`Fetching price for Festive ${itemName}`)
|
||||
var data: ItemPriceData | null
|
||||
let data: ItemPriceData | null
|
||||
try {
|
||||
data = await fetchPrice(token, `${itemSchema[itemIndex].festiveVariant};6`, currentTime);
|
||||
updateTime = new Date(data.update)
|
||||
@@ -279,7 +279,7 @@ async function inject() {
|
||||
}))
|
||||
promises.push(new Promise(async (resolve) => {
|
||||
logDebug(`Fetching price for Strange Festive ${itemName}`)
|
||||
var data: ItemPriceData | null
|
||||
let data: ItemPriceData | null
|
||||
try {
|
||||
data = await fetchPrice(token, `${itemSchema[itemIndex].festiveVariant};11`, currentTime);
|
||||
updateTime = new Date(data.update)
|
||||
@@ -295,7 +295,7 @@ async function inject() {
|
||||
}))
|
||||
}
|
||||
|
||||
var killstreakKitHeadingRow: HTMLTableRowElement | null
|
||||
let killstreakKitHeadingRow: HTMLTableRowElement | null
|
||||
// Check for Killstreak Kits
|
||||
if(itemSchema[itemIndex].slot == ItemSlot.Primary ||
|
||||
itemSchema[itemIndex].slot == ItemSlot.Secondary ||
|
||||
@@ -314,9 +314,9 @@ async function inject() {
|
||||
[1,2,3].map((tier) => {
|
||||
promises.push(new Promise(async (resolve) => {
|
||||
logDebug(`Fetching price for ${itemName} Killstreak Kit Tier ${tier}`)
|
||||
var data: ItemPriceData | null
|
||||
let data: ItemPriceData | null
|
||||
try {
|
||||
var kitIndex: number
|
||||
let kitIndex: number
|
||||
switch (tier) {
|
||||
default:
|
||||
case 1: kitIndex = 6527; break;
|
||||
@@ -351,7 +351,7 @@ async function inject() {
|
||||
"Silver Mk.II",
|
||||
"Gold Mk.II",
|
||||
]
|
||||
var botKillerHeadingRow: HTMLTableRowElement | null
|
||||
let botKillerHeadingRow: HTMLTableRowElement | null
|
||||
if(itemSchema[itemIndex].botkillerVariants != null && itemSchema[itemIndex].botkillerVariants.length > 0) {
|
||||
/// Create subheading
|
||||
botKillerHeadingRow = document.createElement("tr")
|
||||
@@ -370,7 +370,7 @@ async function inject() {
|
||||
const variantName = itemName.includes('Mk.II') ? itemName.split(' ')[0] + ' Mk.II' : itemName.split(' ')[0]
|
||||
promises.push(new Promise(async (resolve) => {
|
||||
logDebug(`Fetching price for ${itemName}`)
|
||||
var data: ItemPriceData | null
|
||||
let data: ItemPriceData | null
|
||||
try {
|
||||
data = await fetchPrice(token, `${variantIndex};11`, currentTime);
|
||||
updateTime = new Date(data.update)
|
||||
|
||||
Reference in New Issue
Block a user