Greasy Fork镜像 还支持 简体中文。

Fintual Goal Variation

Easily display profit/loss on the profitability chart.

目前為 2023-07-10 提交的版本,檢視 最新版本

// ==UserScript==
// @name           Fintual Goal Variation
// @name:es        Fintual variación de objetivos
// @namespace      http://tampermonkey.net/
// @version        0.1
// @description    Easily display profit/loss on the profitability chart.
// @description:es Muestra fácilmente la ganancia/pérdida en el gráfico de rentabilidad.
// @author         IgnaV
// @match          https://fintual.cl/app/goals/*
// @icon           http://fintual.cl/favicon.ico
// @grant          GM_addStyle
// ==/UserScript==

(function() {
    'use strict';

    GM_addStyle('div.nvtooltip.performance-tooltip { top: -30px !important }');

    const observeTableChanges = (targetElement) => {
        const tableObserver = new MutationObserver((mutationsList) => {
            for (const mutation of mutationsList) {
                if (mutation.type === 'childList' && mutation.addedNodes.length > 0) {
                    for (const node of mutation.addedNodes) {
                        if (node.tagName === 'TABLE') {
                            const table = node;
                            const tbody = table.querySelector('tbody');
                            const existingRows = tbody.querySelectorAll('tr');
                            const depositAmount = parseFloat(existingRows[0].querySelectorAll('td')[2].textContent.replace(/[^0-9-]+/g, ''));
                            const fintualBalance = parseFloat(existingRows[1].querySelectorAll('td')[2].textContent.replace(/[^0-9-]+/g, ''));
                            const diff = fintualBalance - depositAmount;
                            const diffPercentage = (diff / depositAmount * 100).toFixed(1);
                            const legendBgColor = diff >= 0 ? 'rgb(43, 214, 0)' : 'rgb(214, 0, 0)';
                            const formattedDiff = diff.toLocaleString('es-CL', { useGrouping: true });
                            const diffRow = document.createElement('tr');
                            diffRow.innerHTML = `<td class="legend-color-guide"><div style="background-color: ${legendBgColor};"></div></td>` +
                                                `<td class="key">Balance</td>` +
                                                `<td class="value">(${diffPercentage}%) $ ${formattedDiff}</td>`;
                            tbody.appendChild(diffRow);
                        }
                    }
                }
            }
        });
        const tableObserverOptions = {
            childList: true,
            subtree: true
        };
        tableObserver.observe(targetElement, tableObserverOptions);
        return tableObserver;
    };

    const rootObserver = new MutationObserver((mutationsList) => {
        for (const mutation of mutationsList) {
            if (mutation.type === 'childList' && mutation.addedNodes.length > 0) {
                const targetElement = document.querySelector('div.nvtooltip.performance-tooltip');
                if (targetElement) {
                    const tableObserver = observeTableChanges(targetElement);
                    rootObserver.disconnect();
                    break;
                }
            }
        }
    });
    const rootObserverOptions = {
        childList: true,
        subtree: true
    };
    rootObserver.observe(document.body, rootObserverOptions);
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址