js-tampermonkey-public-scripts/Вывод в дооларах к Тенге.user.js
Unkas Amanjolov 42b29defae first commit
2024-10-07 10:25:50 +05:00

45 lines
1.7 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// ==UserScript==
// @name Вывод в дооларах к Тенге
// @namespace http://tampermonkey.net/
// @version 0.3
// @description try to take over the world!
// @author You
// @match https://aliexpress.ru/item/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=aliexpress.ru
// @downloadURL https://gitlabappserver.lkaz.ru/lukas91/js-tampermonkey-public-scripts/raw/branch/main/Withdrawal%20in%20dollars%20to%20tenge.js
// @updateURL https://gitlabappserver.lkaz.ru/lukas91/js-tampermonkey-public-scripts/raw/branch/main/Withdrawal%20in%20dollars%20to%20tenge.js
// @grant none
// ==/UserScript==
// Функция для ожидания загрузки страницы
console.log('start');
function waitForPageLoad(callback) {
if (document.readyState === "complete") {
callback();
console.log('complete');
} else {
window.addEventListener("load", callback);
console.log('load');
}
}
// Функция для выполнения вычислений и обновления страницы
function performCalculations() {
const priceElement = document.querySelector('[class^="snow-price_SnowPrice__mainS__"]');
if (priceElement) {
const priceText = priceElement.innerText;
const priceInKZT = parseFloat(priceText.replace(/\s/g, '').replace('₸', '').replace(',', '.'));
const priceInUSD = (priceInKZT / 462.105).toFixed(2);
// Обновление страницы с новыми данными
priceElement.innerHTML = `${priceText} / (${priceInUSD}$)`;
}
}
// Ожидание загрузки страницы и выполнение вычислений
waitForPageLoad(performCalculations);