[BitoEX] exchange differences

add exchange differences in BitoEX

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         [BitoEX] exchange differences
// @namespace    http://tampermonkey.net/
// @version      0.1.1
// @description  add exchange differences in BitoEX
// @author       SSARCandy
// @match        https://www.bitoex.com/charts*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    $( document ).ajaxComplete(function( event, xhr, settings ) {
        if (xhr.responseJSON.length === 4) {
            const [buy, sell] = xhr.responseJSON.slice(0, 2).map(x => Number(x.replace(/,/g, '')));

            if (!$('#buy-sell').length){
                const html = `<div class="buy col-xs-12 col-md-3 col-lg-3"><h4 class="sync_rate_buy" id="buy-sell"><span>${(buy-sell).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}</span></h4><p>差價 (TWD)</p></div>`;
                $('body > div.container.content > div.rate_row.clearfix.fadeIn.animated').prepend(html);
            } else {
                $('#buy-sell')[0].innerText = (buy-sell).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
            }
        }
    });
    $('.cal').attr('style','margin-left:0 !important');
})();