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 { findFirstElement, findFirstChildElement } from './utils/dom'
|
||||||
import { extractPageTitleFromURL } from './utils/url';
|
import { extractPageTitleFromURL } from './utils/url';
|
||||||
import { ExchangeRates, prepareExchangeRates } from './exchangeRateService';
|
import { ExchangeRates, prepareExchangeRates } from './exchangeRateService';
|
||||||
var itemSchema: ItemSchema | null;
|
let itemSchema: ItemSchema | null;
|
||||||
var exchangeRates: ExchangeRates | null;
|
let exchangeRates: ExchangeRates | null;
|
||||||
|
|
||||||
var locale: string = 'en'
|
let locale: string = 'en'
|
||||||
|
|
||||||
/** Exclude these from the pricelist. */
|
/** Exclude these from the pricelist. */
|
||||||
const excludedQualities = new Set([
|
const excludedQualities = new Set([
|
||||||
@@ -33,8 +33,8 @@ async function inject() {
|
|||||||
// Not an item page
|
// Not an item page
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var itemIndex: number | null = null;
|
let itemIndex: number | null = null;
|
||||||
var itemName: string | null = null;
|
let itemName: string | null = null;
|
||||||
|
|
||||||
// Find buy buttons
|
// Find buy buttons
|
||||||
const buyButton = findFirstChildElement('.btn_buynow', itemInfobox);
|
const buyButton = findFirstChildElement('.btn_buynow', itemInfobox);
|
||||||
@@ -94,7 +94,7 @@ async function inject() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var qualities: number[] = []
|
const qualities: number[] = []
|
||||||
|
|
||||||
const firstQualityTag = findFirstChildElement('.quality-tag', itemInfobox);
|
const firstQualityTag = findFirstChildElement('.quality-tag', itemInfobox);
|
||||||
|
|
||||||
@@ -122,7 +122,7 @@ async function inject() {
|
|||||||
// th.infobox-header (Basic Information)
|
// th.infobox-header (Basic Information)
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
var storeButtons: HTMLTableRowElement[] = [];
|
const storeButtons: HTMLTableRowElement[] = [];
|
||||||
|
|
||||||
// backpack.tf button
|
// backpack.tf button
|
||||||
storeButtons.push(createStoreButton("backpack.tf", new URL(`https://backpack.tf/classifieds?item=${encodeURIComponent(itemName)}`)));
|
storeButtons.push(createStoreButton("backpack.tf", new URL(`https://backpack.tf/classifieds?item=${encodeURIComponent(itemName)}`)));
|
||||||
@@ -171,7 +171,7 @@ async function inject() {
|
|||||||
priceProgressRow.appendChild(priceProgressData);
|
priceProgressRow.appendChild(priceProgressData);
|
||||||
priceInfoboxHeadingRow.insertAdjacentElement('afterend', priceProgressRow);
|
priceInfoboxHeadingRow.insertAdjacentElement('afterend', priceProgressRow);
|
||||||
|
|
||||||
var token: string | null;
|
let token: string | null;
|
||||||
|
|
||||||
// Steam Community Market
|
// Steam Community Market
|
||||||
// TODO: Change this to lazy-load, so that it doesn't make network requests when we have cached data.
|
// 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);
|
log('Failed to get an access token for prices.tf: ' + err);
|
||||||
}
|
}
|
||||||
|
|
||||||
var updateTime: Date | null = null;
|
let updateTime: Date | null = null;
|
||||||
|
|
||||||
enum PriceRowCategory {
|
enum PriceRowCategory {
|
||||||
None,
|
None,
|
||||||
@@ -201,19 +201,19 @@ async function inject() {
|
|||||||
row: HTMLTableRowElement
|
row: HTMLTableRowElement
|
||||||
category: PriceRowCategory
|
category: PriceRowCategory
|
||||||
}
|
}
|
||||||
var priceRows: PriceRow[]= [];
|
const priceRows: PriceRow[]= [];
|
||||||
|
|
||||||
// Get current key price
|
// Get current key price
|
||||||
const keyPrice = await fetchKeyPrice(token);
|
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 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()
|
const qualifiedName = ((quality != 6 ? itemQualities[quality as unknown as keyof typeof itemQualities].toString() : '') + ' ' + itemName).trim()
|
||||||
// logDebug(`Fetching price for ${qualifiedName}`)
|
// logDebug(`Fetching price for ${qualifiedName}`)
|
||||||
|
|
||||||
var data: ItemPriceData | null
|
let data: ItemPriceData | null
|
||||||
try {
|
try {
|
||||||
data = await fetchPrice(token, itemIndex + ";" + quality, currentTime);
|
data = await fetchPrice(token, itemIndex + ";" + quality, currentTime);
|
||||||
updateTime = new Date(data.update)
|
updateTime = new Date(data.update)
|
||||||
@@ -231,7 +231,7 @@ async function inject() {
|
|||||||
if(itemSchema[itemIndex].hasAustraliumVariant) {
|
if(itemSchema[itemIndex].hasAustraliumVariant) {
|
||||||
promises.push(new Promise(async (resolve) => {
|
promises.push(new Promise(async (resolve) => {
|
||||||
logDebug(`Fetching price for Australium ${itemName}`)
|
logDebug(`Fetching price for Australium ${itemName}`)
|
||||||
var data: ItemPriceData | null
|
let data: ItemPriceData | null
|
||||||
try {
|
try {
|
||||||
data = await fetchPrice(token, `${itemIndex};11;australium`, currentTime);
|
data = await fetchPrice(token, `${itemIndex};11;australium`, currentTime);
|
||||||
updateTime = new Date(data.update)
|
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
|
// Check item schema for Festive variant of current defindex
|
||||||
if(itemSchema[itemIndex].festiveVariant != null) {
|
if(itemSchema[itemIndex].festiveVariant != null) {
|
||||||
/// Create subheading
|
/// Create subheading
|
||||||
@@ -263,7 +263,7 @@ async function inject() {
|
|||||||
|
|
||||||
promises.push(new Promise(async (resolve) => {
|
promises.push(new Promise(async (resolve) => {
|
||||||
logDebug(`Fetching price for Festive ${itemName}`)
|
logDebug(`Fetching price for Festive ${itemName}`)
|
||||||
var data: ItemPriceData | null
|
let data: ItemPriceData | null
|
||||||
try {
|
try {
|
||||||
data = await fetchPrice(token, `${itemSchema[itemIndex].festiveVariant};6`, currentTime);
|
data = await fetchPrice(token, `${itemSchema[itemIndex].festiveVariant};6`, currentTime);
|
||||||
updateTime = new Date(data.update)
|
updateTime = new Date(data.update)
|
||||||
@@ -279,7 +279,7 @@ async function inject() {
|
|||||||
}))
|
}))
|
||||||
promises.push(new Promise(async (resolve) => {
|
promises.push(new Promise(async (resolve) => {
|
||||||
logDebug(`Fetching price for Strange Festive ${itemName}`)
|
logDebug(`Fetching price for Strange Festive ${itemName}`)
|
||||||
var data: ItemPriceData | null
|
let data: ItemPriceData | null
|
||||||
try {
|
try {
|
||||||
data = await fetchPrice(token, `${itemSchema[itemIndex].festiveVariant};11`, currentTime);
|
data = await fetchPrice(token, `${itemSchema[itemIndex].festiveVariant};11`, currentTime);
|
||||||
updateTime = new Date(data.update)
|
updateTime = new Date(data.update)
|
||||||
@@ -295,7 +295,7 @@ async function inject() {
|
|||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
var killstreakKitHeadingRow: HTMLTableRowElement | null
|
let killstreakKitHeadingRow: HTMLTableRowElement | null
|
||||||
// Check for Killstreak Kits
|
// Check for Killstreak Kits
|
||||||
if(itemSchema[itemIndex].slot == ItemSlot.Primary ||
|
if(itemSchema[itemIndex].slot == ItemSlot.Primary ||
|
||||||
itemSchema[itemIndex].slot == ItemSlot.Secondary ||
|
itemSchema[itemIndex].slot == ItemSlot.Secondary ||
|
||||||
@@ -314,9 +314,9 @@ async function inject() {
|
|||||||
[1,2,3].map((tier) => {
|
[1,2,3].map((tier) => {
|
||||||
promises.push(new Promise(async (resolve) => {
|
promises.push(new Promise(async (resolve) => {
|
||||||
logDebug(`Fetching price for ${itemName} Killstreak Kit Tier ${tier}`)
|
logDebug(`Fetching price for ${itemName} Killstreak Kit Tier ${tier}`)
|
||||||
var data: ItemPriceData | null
|
let data: ItemPriceData | null
|
||||||
try {
|
try {
|
||||||
var kitIndex: number
|
let kitIndex: number
|
||||||
switch (tier) {
|
switch (tier) {
|
||||||
default:
|
default:
|
||||||
case 1: kitIndex = 6527; break;
|
case 1: kitIndex = 6527; break;
|
||||||
@@ -351,7 +351,7 @@ async function inject() {
|
|||||||
"Silver Mk.II",
|
"Silver Mk.II",
|
||||||
"Gold Mk.II",
|
"Gold Mk.II",
|
||||||
]
|
]
|
||||||
var botKillerHeadingRow: HTMLTableRowElement | null
|
let botKillerHeadingRow: HTMLTableRowElement | null
|
||||||
if(itemSchema[itemIndex].botkillerVariants != null && itemSchema[itemIndex].botkillerVariants.length > 0) {
|
if(itemSchema[itemIndex].botkillerVariants != null && itemSchema[itemIndex].botkillerVariants.length > 0) {
|
||||||
/// Create subheading
|
/// Create subheading
|
||||||
botKillerHeadingRow = document.createElement("tr")
|
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]
|
const variantName = itemName.includes('Mk.II') ? itemName.split(' ')[0] + ' Mk.II' : itemName.split(' ')[0]
|
||||||
promises.push(new Promise(async (resolve) => {
|
promises.push(new Promise(async (resolve) => {
|
||||||
logDebug(`Fetching price for ${itemName}`)
|
logDebug(`Fetching price for ${itemName}`)
|
||||||
var data: ItemPriceData | null
|
let data: ItemPriceData | null
|
||||||
try {
|
try {
|
||||||
data = await fetchPrice(token, `${variantIndex};11`, currentTime);
|
data = await fetchPrice(token, `${variantIndex};11`, currentTime);
|
||||||
updateTime = new Date(data.update)
|
updateTime = new Date(data.update)
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ export async function wipeExchangeRates(): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function prepareExchangeRates(): Promise<ExchangeRates> {
|
export async function prepareExchangeRates(): Promise<ExchangeRates> {
|
||||||
var needsUpdate: Boolean = false
|
let needsUpdate: boolean = false
|
||||||
var rates: ExchangeRates | null = null
|
let rates: ExchangeRates | null = null
|
||||||
|
|
||||||
rates = await getStorageValue(storage_exchangerates, null);
|
rates = await getStorageValue(storage_exchangerates, null);
|
||||||
const update = await getStorageValue(storage_exchangerates_update, null)
|
const update = await getStorageValue(storage_exchangerates_update, null)
|
||||||
@@ -39,7 +39,7 @@ export async function prepareExchangeRates(): Promise<ExchangeRates> {
|
|||||||
const response = await GM_fetch(url);
|
const response = await GM_fetch(url);
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
await setStorageValue(storage_exchangerates_update, new Date().toISOString())
|
await setStorageValue(storage_exchangerates_update, new Date().toISOString())
|
||||||
var json = await response.json()
|
const json = await response.json()
|
||||||
if(json != null){
|
if(json != null){
|
||||||
rates = json['rates']
|
rates = json['rates']
|
||||||
await setStorageValue(storage_exchangerates, rates)
|
await setStorageValue(storage_exchangerates, rates)
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ export async function fetchKeyPrice(token: string) {
|
|||||||
*/
|
*/
|
||||||
export async function fetchPrice(token: string, sku: string, update: Date = new Date(), ttl: number = 30 * 60 * 1000): Promise<ItemPriceData> {
|
export async function fetchPrice(token: string, sku: string, update: Date = new Date(), ttl: number = 30 * 60 * 1000): Promise<ItemPriceData> {
|
||||||
return new Promise(async (resolve, reject) => {
|
return new Promise(async (resolve, reject) => {
|
||||||
var data: ItemPriceData | null
|
let data: ItemPriceData | null
|
||||||
|
|
||||||
const cached: ItemPriceData = await getStorageValue(storage_priceprefix + sku, null)
|
const cached: ItemPriceData = await getStorageValue(storage_priceprefix + sku, null)
|
||||||
if (cached != null && 'keys' in cached && 'metal' in cached && !isNaN(cached.update)) {
|
if (cached != null && 'keys' in cached && 'metal' in cached && !isNaN(cached.update)) {
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ async function priceUsingPricesTF(token: string, sku: string, retries: number =
|
|||||||
if (!token) {
|
if (!token) {
|
||||||
reject(401)
|
reject(401)
|
||||||
}
|
}
|
||||||
var response = await GM_fetch(`https://api2.prices.tf/prices/${encodeURIComponent(sku)}`, {
|
let response = await GM_fetch(`https://api2.prices.tf/prices/${encodeURIComponent(sku)}`, {
|
||||||
method: 'get',
|
method: 'get',
|
||||||
headers: new Headers({
|
headers: new Headers({
|
||||||
'Accept': 'application/json',
|
'Accept': 'application/json',
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ export function checkAustraliumVariant(defindex: number): boolean {
|
|||||||
export declare const __VERSION__: string;
|
export declare const __VERSION__: string;
|
||||||
|
|
||||||
function isDateAfterOneDay(date1: Date, date2: Date): boolean {
|
function isDateAfterOneDay(date1: Date, date2: Date): boolean {
|
||||||
var diff = date2.getTime() - date1.getTime();
|
const diff = date2.getTime() - date1.getTime();
|
||||||
var diffDays = Math.round(diff / (1000 * 3600 * 24));
|
const diffDays = Math.round(diff / (1000 * 3600 * 24));
|
||||||
return diffDays > 1;
|
return diffDays > 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,8 +119,8 @@ export async function wipeSchema(): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function prepareSchema(): Promise<ItemSchema> {
|
export async function prepareSchema(): Promise<ItemSchema> {
|
||||||
var needsUpdate: Boolean = false
|
let needsUpdate: boolean = false
|
||||||
var itemSchema: ItemSchema | null = null
|
let itemSchema: ItemSchema | null = null
|
||||||
|
|
||||||
const storedVersion: string | null = await getStorageValue(storage_version, null)
|
const storedVersion: string | null = await getStorageValue(storage_version, null)
|
||||||
if(!storedVersion || !semver.valid(storedVersion)) {
|
if(!storedVersion || !semver.valid(storedVersion)) {
|
||||||
@@ -150,14 +150,14 @@ export async function prepareSchema(): Promise<ItemSchema> {
|
|||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
await setStorageValue(storage_lastUpdateTime, new Date().getTime());
|
await setStorageValue(storage_lastUpdateTime, new Date().getTime());
|
||||||
|
|
||||||
var cacheItems = {}
|
const cacheItems = {}
|
||||||
|
|
||||||
var responseItems: any[] = await response.json()
|
const responseItems: any[] = await response.json()
|
||||||
// We want to keep the keys `defindex`, `item_name`, and `attributes`
|
// We want to keep the keys `defindex`, `item_name`, and `attributes`
|
||||||
responseItems.forEach((item: any) => {
|
responseItems.forEach((item: any) => {
|
||||||
const defindex: number = item['defindex']
|
const defindex: number = item['defindex']
|
||||||
|
|
||||||
var tradable: Boolean = true
|
let tradable: boolean = true
|
||||||
try {
|
try {
|
||||||
if(item['attributes'] != null) {
|
if(item['attributes'] != null) {
|
||||||
if(item['attributes'].find((attribute: {}) => (attribute as any)['class'] == "cannot_trade")) {
|
if(item['attributes'].find((attribute: {}) => (attribute as any)['class'] == "cannot_trade")) {
|
||||||
@@ -169,7 +169,7 @@ export async function prepareSchema(): Promise<ItemSchema> {
|
|||||||
log(item)
|
log(item)
|
||||||
}
|
}
|
||||||
|
|
||||||
var canKillstreakify: Boolean = false
|
let canKillstreakify: boolean = false
|
||||||
try {
|
try {
|
||||||
if(item['capabilities'] != null) {
|
if(item['capabilities'] != null) {
|
||||||
if(item['capabilities']['can_killstreakify'] != null && item['capabilities']['can_killstreakify'] == true) {
|
if(item['capabilities']['can_killstreakify'] != null && item['capabilities']['can_killstreakify'] == true) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
declare var __ENV_USERSCRIPT: boolean;
|
declare let __ENV_USERSCRIPT: boolean;
|
||||||
declare var __ENV_WEBEXTENSION: boolean;
|
declare let __ENV_WEBEXTENSION: boolean;
|
||||||
|
|
||||||
function getStorageValue(name: string, defaultValue: string): Promise<any> {
|
function getStorageValue(name: string, defaultValue: string): Promise<any> {
|
||||||
if(__ENV_USERSCRIPT) {
|
if(__ENV_USERSCRIPT) {
|
||||||
|
|||||||
@@ -22,14 +22,14 @@ export function createPriceRow(qualityName: string, data: ItemPriceData, keyPric
|
|||||||
|
|
||||||
const priceData = document.createElement("td");
|
const priceData = document.createElement("td");
|
||||||
const priceLink = document.createElement("span");
|
const priceLink = document.createElement("span");
|
||||||
var priceString: string = ''
|
let priceString: string = ''
|
||||||
|
|
||||||
if(data) {
|
if(data) {
|
||||||
const gamePrice = formatPrice(data.keys, data.metal, keyPrice.metal, locale).trim()
|
const gamePrice = formatPrice(data.keys, data.metal, keyPrice.metal, locale).trim()
|
||||||
const realPriceUSD = convertTF2PriceToUSD(data.keys, data.metal, keyPrice.metal)
|
const realPriceUSD = convertTF2PriceToUSD(data.keys, data.metal, keyPrice.metal)
|
||||||
|
|
||||||
const USDFormatter = new Intl.NumberFormat(locale, { style: "currency", currency: 'USD' })
|
const USDFormatter = new Intl.NumberFormat(locale, { style: "currency", currency: 'USD' })
|
||||||
var realPriceString = USDFormatter.format(realPriceUSD)
|
let realPriceString = USDFormatter.format(realPriceUSD)
|
||||||
const currency = defaultCurrencyForPageLocale(locale) ?? 'USD'
|
const currency = defaultCurrencyForPageLocale(locale) ?? 'USD'
|
||||||
if(currency !== 'USD') {
|
if(currency !== 'USD') {
|
||||||
try {
|
try {
|
||||||
@@ -56,7 +56,7 @@ export function createPriceRow(qualityName: string, data: ItemPriceData, keyPric
|
|||||||
|
|
||||||
export function createStoreButton(storeName: string, url: URL) {
|
export function createStoreButton(storeName: string, url: URL) {
|
||||||
const button = document.createElement("tr")
|
const button = document.createElement("tr")
|
||||||
var source = `<td colspan="2" class="infobox-data" style="text-align:center"><div class="plainlinks btn_wrapper" style="width:100%"><a rel="nofollow" class="external text" href="{link}" target="_blank"><span class="btn_buynow_addon_${storeName.replaceAll('.', '')}">{title}<span></span></span></a></div></td>`
|
let source = `<td colspan="2" class="infobox-data" style="text-align:center"><div class="plainlinks btn_wrapper" style="width:100%"><a rel="nofollow" class="external text" href="{link}" target="_blank"><span class="btn_buynow_addon_${storeName.replaceAll('.', '')}">{title}<span></span></span></a></div></td>`
|
||||||
source = source.replace("{link}", url.toString())
|
source = source.replace("{link}", url.toString())
|
||||||
source = source.replace("{title}", $T("View listings on %@").replace('%@', storeName))
|
source = source.replace("{title}", $T("View listings on %@").replace('%@', storeName))
|
||||||
button.innerHTML = source
|
button.innerHTML = source
|
||||||
|
|||||||
@@ -2,14 +2,14 @@ import { conversion_ref_usd } from '../config';
|
|||||||
import { $T } from './localization'
|
import { $T } from './localization'
|
||||||
|
|
||||||
function toFixed(num: number, fixed: number) {
|
function toFixed(num: number, fixed: number) {
|
||||||
var re = new RegExp('^-?\\d+(?:\.\\d{0,' + (fixed || -1) + '})?');
|
const re = new RegExp('^-?\\d+(?:\.\\d{0,' + (fixed || -1) + '})?');
|
||||||
return num.toString().match(re)[0];
|
return num.toString().match(re)[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function formatPrice(keys: number, metal: number, keyPrice: number, locale: string = 'en') {
|
export function formatPrice(keys: number, metal: number, keyPrice: number, locale: string = 'en') {
|
||||||
const formattedKeys = +(keys + (metal / keyPrice)).toFixed(2)
|
const formattedKeys = +(keys + (metal / keyPrice)).toFixed(2)
|
||||||
|
|
||||||
var output: string = ''
|
let output: string = ''
|
||||||
if(keys > 0) {
|
if(keys > 0) {
|
||||||
output += (formattedKeys == 1.0 ? $T("%@ key") : $T("%@ keys")).replace('%@', formattedKeys.toLocaleString(locale))
|
output += (formattedKeys == 1.0 ? $T("%@ key") : $T("%@ keys")).replace('%@', formattedKeys.toLocaleString(locale))
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ export function $T(s: string, locale?: Intl.LocalesArgument): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function extractLocaleFromURL(url: string): string {
|
export function extractLocaleFromURL(url: string): string {
|
||||||
var split = url.substring(url.indexOf("/wiki/") + "/wiki/".length);
|
const split = url.substring(url.indexOf("/wiki/") + "/wiki/".length);
|
||||||
if (split.indexOf('/') != -1) {
|
if (split.indexOf('/') != -1) {
|
||||||
// Remove language suffix e.g. `/es`
|
// Remove language suffix e.g. `/es`
|
||||||
return split.substring(split.indexOf('/') + 1);
|
return split.substring(split.indexOf('/') + 1);
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
declare var __PRODUCTION: boolean;
|
declare let __EXTENSION_NAME: string;
|
||||||
declare var __EXTENSION_NAME: string;
|
|
||||||
const logHeader = `[${__EXTENSION_NAME}] `;
|
const logHeader = `[${__EXTENSION_NAME}] `;
|
||||||
|
|
||||||
/** `console.debug` with header; automatically NO-OP on production build */
|
/** `console.debug` with header; automatically NO-OP on production build */
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
export function extractPageTitleFromURL(url: string): string {
|
export function extractPageTitleFromURL(url: string): string {
|
||||||
var split = url.substring(url.indexOf("/wiki/") + "/wiki/".length);
|
let split = url.substring(url.indexOf("/wiki/") + "/wiki/".length);
|
||||||
if (split.indexOf('/') != -1) {
|
if (split.indexOf('/') != -1) {
|
||||||
// Remove language suffix (/es)
|
// Remove language suffix (/es)
|
||||||
split = split.substring(0, split.indexOf('/'));
|
split = split.substring(0, split.indexOf('/'));
|
||||||
|
|||||||
Reference in New Issue
Block a user