[BitoEX] exchange differences

add exchange differences in BitoEX

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==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');
})();