Binance BTC Fixed Display

Показва фиксирано BTC количество и смята реална USD стойност

Dit script moet niet direct worden geïnstalleerd - het is een bibliotheek voor andere scripts om op te nemen met de meta-richtlijn // @require https://update.greasyfork.org/scripts/548057/1652988/Binance%20BTC%20Fixed%20Display.js

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey, Greasemonkey of Violentmonkey.

Voor het installeren van scripts heb je een extensie nodig, zoals {tampermonkey_link:Tampermonkey}.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Violentmonkey.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Userscripts.

Voor het installeren van scripts heb je een extensie nodig, zoals {tampermonkey_link:Tampermonkey}.

Voor het installeren van scripts heb je een gebruikersscriptbeheerder nodig.

(Ik heb al een user script manager, laat me het downloaden!)

Advertisement:

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

(Ik heb al een beheerder - laat me doorgaan met de installatie!)

Advertisement:

// ==UserScript==
// @name         Binance BTC Fixed Display
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  Показва фиксирано BTC количество и смята реална USD стойност
// @author       You
// @match        https://www.binance.com/en/my/wallet/account/overview
// @match        https://www.binance.com/en/my/wallet/account/main
// @grant        GM_xmlhttpRequest
// @connect      api.binance.com
// ==/UserScript==


(function() {
    'use strict';

    const FIXED_BTC = 8.97;
    const FIXED_USD = 968429.90;

    function replaceDisplay() {
        // --- BTC ---
        const btcElem = document.querySelector('.typography-Headline4');
        if (btcElem) {
            btcElem.style.color = 'transparent';
            btcElem.style.position = 'relative';
            if (!btcElem.querySelector('.fixed-btc')) {
                const fixedBTC = document.createElement('span');
                fixedBTC.className = 'fixed-btc';
                fixedBTC.style.position = 'absolute';
                fixedBTC.style.left = '0';
                fixedBTC.style.top = '0';
                fixedBTC.style.color = '#fff';
                fixedBTC.textContent = FIXED_BTC.toFixed(8);
                btcElem.appendChild(fixedBTC);
            }
        }

        // --- USD (обща сума с дневната промяна) ---
        const usdElem = document.querySelector('.body3.mt-2');
        if (usdElem) {
            usdElem.style.color = 'transparent';
            usdElem.style.position = 'relative';
            if (!usdElem.querySelector('.fixed-usd')) {
                const fixedUSD = document.createElement('span');
                fixedUSD.className = 'fixed-usd';
                fixedUSD.style.position = 'absolute';
                fixedUSD.style.left = '0';
                fixedUSD.style.top = '0';
                fixedUSD.style.color = '#fff';
                usdElem.appendChild(fixedUSD);
            }

            // Взимаме процента от SELL или BUY
            let adjustedTotal = FIXED_USD;
            let percent = null;

            const sellElem = document.querySelector('.text-t-sell');
            const buyElem = document.querySelector('.text-t-buy');

            let match = null;
            if (sellElem) {
                match = sellElem.textContent.match(/\(([-+]?[0-9]*\.?[0-9]+)%\)/);
            }
            if ((!match || !match[1]) && buyElem) {
                match = buyElem.textContent.match(/\(([-+]?[0-9]*\.?[0-9]+)%\)/);
            }

            if (match) {
                percent = parseFloat(match[1]);
                const delta = FIXED_USD * (percent / 100);
                adjustedTotal = FIXED_USD + delta;
            }

            usdElem.querySelector('.fixed-usd').textContent =
                `≈ $${adjustedTotal.toLocaleString('en-US', {
                    minimumFractionDigits: 2,
                    maximumFractionDigits: 2
                })}`;
        }

        // --- SELL / дневна промяна ---
        const sellElem = document.querySelector('.text-t-sell');
        if (sellElem) {
            const text = sellElem.textContent;
            const match = text.match(/\(([-+]?[0-9]*\.?[0-9]+)%\)/);
            if (match) {
                const percent = parseFloat(match[1]);
                const delta = FIXED_USD * (percent / 100);
                const color = percent < 0 ? 'red' : '#2ebd85';
                sellElem.innerHTML =
                    `<span style="font-size:0.85em; color:${color}">≈ $${delta.toLocaleString('en-US', {
                        minimumFractionDigits: 2,
                        maximumFractionDigits: 2
                    })} (${percent.toFixed(2)}%)</span>`;
            } else {
                sellElem.innerHTML = '-';
            }
        }

        // --- BUY / дневна промяна ---
        const buyElem = document.querySelector('.text-t-buy');
        if (buyElem) {
            const text = buyElem.textContent;
            const match = text.match(/\(([-+]?[0-9]*\.?[0-9]+)%\)/);
            if (match) {
                const percent = parseFloat(match[1]);
                const delta = FIXED_USD * (percent / 100);
                const color = percent < 0 ? 'red' : '#2ebd85';
                buyElem.innerHTML =
                    `<span style="font-size:0.85em; color:${color}">≈ $${delta.toLocaleString('en-US', {
                        minimumFractionDigits: 2,
                        maximumFractionDigits: 2
                    })} (${percent.toFixed(2)}%)</span>`;
            } else {
                buyElem.innerHTML = '-';
            }
        }
    }

    replaceDisplay();
    setInterval(replaceDisplay, 500);

})();