Skip to content

Instantly share code, notes, and snippets.

@huaigu
Last active December 21, 2023 03:11
Show Gist options
  • Save huaigu/a2d6acb7af3f9e059d1374c3b83e2857 to your computer and use it in GitHub Desktop.
Save huaigu/a2d6acb7af3f9e059d1374c3b83e2857 to your computer and use it in GitHub Desktop.
LSGS marketplace - convert amout to tick
// 获取所有匹配的元素
const priceElements = document.querySelectorAll('.marketplace_price__nBpOg');
const amountElements = document.querySelectorAll('.marketplace_inscription-name__d94dM');
const unitElements = Array.from(document.querySelectorAll('.marketplace_unit__k_PNs')).filter(element => element.innerText.includes('LSGS'));
// 检查是否存在符合条件的元素
if (unitElements.length > 0) {
// 遍历并替换价格元素
priceElements.forEach((priceElement) => {
const originalText = priceElement.innerText;
const numericValue = parseFloat(originalText);
if (!isNaN(numericValue)) {
const multipliedValue = numericValue * 2100;
priceElement.innerText = multipliedValue.toFixed(2); // 将结果设置为保留两位小数的字符串
}
});
amountElements.forEach((priceElement) => {
const originalText = priceElement.innerText;
const numericValue = parseInt(originalText.replace(/,/g, ''));
if (!isNaN(numericValue)) {
const multipliedValue = numericValue / 2100;
priceElement.innerText = multipliedValue.toFixed(0) + "张"; // 将结果设置为保留两位小数的字符串
}
});
// 遍历并替换单位元素
unitElements.forEach((unitElement) => {
unitElement.innerText = 'USDT / 张';
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment