0
0
mirror of https://github.com/Maks1mS/userscripts.git synced 2024-12-24 00:33:03 +03:00

[SteamPriceConverter] update to 0.2

fix some bugs
This commit is contained in:
Maxim Slipenko 2024-05-28 13:33:22 +03:00
parent 5326567242
commit 1e5f939be0

View File

@ -1,7 +1,7 @@
// ==UserScript== // ==UserScript==
// @name Steam Price Converter // @name Steam Price Converter
// @namespace https://github.com/Maks1mS/userscripts // @namespace https://github.com/Maks1mS/userscripts
// @version 0.1 // @version 0.2
// @description Converts prices to rubles // @description Converts prices to rubles
// @author Maxim Slipenko // @author Maxim Slipenko
// @match https://store.steampowered.com/* // @match https://store.steampowered.com/*
@ -50,8 +50,8 @@
function getCurrentValute() { function getCurrentValute() {
const walletText = document.getElementById('header_wallet_balance').innerText; const walletText = document.getElementById('header_wallet_balance').innerText;
const symbol = Object.keys(SYMBOL_TO_CODE_MAPPING).find(symbol => walletText.includes(symbol)) state.source_symbol = Object.keys(SYMBOL_TO_CODE_MAPPING).find(symbol => walletText.includes(symbol))
return SYMBOL_TO_CODE_MAPPING[symbol]; return SYMBOL_TO_CODE_MAPPING[state.source_symbol];
} }
async function main() { async function main() {
@ -69,7 +69,7 @@
} }
function replace(convert) { function replace(convert) {
let r = document.evaluate('//text()[contains(., \"₸\")]',document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); let r = document.evaluate(`//text()[contains(., \"${state.source_symbol}\")]`,document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
for (let i = 0; i < r.snapshotLength; i++) { for (let i = 0; i < r.snapshotLength; i++) {
let n = r.snapshotItem(i); let n = r.snapshotItem(i);