You've already forked tf2wikipricing
feat: enable webextension builds
Currently only supports Chrome due to no `chrome` -> `browser` polyfill
This commit is contained in:
@@ -2,6 +2,8 @@ import { defindex_key, storage_priceprefix } from "./config"
|
||||
import { priceUsingPricesTF } from "./pricing/pricestf"
|
||||
import { getStorageValue, setStorageValue } from "./storage"
|
||||
import { logDebug } from "./utils/log"
|
||||
declare const __ENV_WEBEXTENSION: boolean;
|
||||
declare const __ENV_USERSCRIPT: boolean;
|
||||
|
||||
/** Pricing data for a given TF2 item. */
|
||||
export class ItemPriceData {
|
||||
@@ -58,7 +60,12 @@ export async function fetchPrice(token: string, sku: string, update: Date = new
|
||||
data.ttl = ttl
|
||||
|
||||
try {
|
||||
const response = await priceUsingPricesTF(token, sku)
|
||||
let response: PricesResponse
|
||||
if(__ENV_USERSCRIPT) {
|
||||
response = await priceUsingPricesTF(token, sku)
|
||||
} else {
|
||||
response = JSON.parse(await chrome.runtime.sendMessage({contentScriptQuery: "priceSKU", service: "prices.tf", sku: sku, token: token}));
|
||||
}
|
||||
if (response) {
|
||||
data.keys = response.keys
|
||||
data.metal = response.metal
|
||||
|
||||
Reference in New Issue
Block a user