Banggood.com currency changer

Change currency from USD showed to another currency that does not supported in Banggood.com website

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Banggood.com currency changer
// @description  Change currency from USD showed to another currency that does not supported in Banggood.com website
// @namespace    https://github.com/NabiKAZ/banggood-currency
// @version      0.2
// @license      GPL-3.0+; http://www.gnu.org/licenses/gpl-3.0.txt
// @date         2017-02-20
// @update       2018
// @author       Nabi KaramAlizadeh <[email protected]>
// @homepage     http://www.nabi.ir/
// @match        *://www.banggood.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    var unit = 4600; //THIS IS THE CURRENT PRICE OF THE DOLLAR IN TODAY. REPLACE WITH ARBITRARY VALUE.
    var currency = 'تومان'; //THIS IS THE CURRENCY NAME. REPLACE WITH ARBITRARY VALUE.

    var selectors = 'div>.now, li>.price, .selected_total>strong';

    $('body').on('DOMSubtreeModified', selectors, function(){
        var price = $(this).text();
        price = price.replace('US$', '');
        price = price * unit;
        price = Math.round(price);
        price = isNaN(price)?'':price.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
        var priceUnit = price + ' ' + currency;
        var priceTomanEl = $(this).parent().find('.priceToman').first();
        if (priceTomanEl.length === 0) {
            priceTomanEl = $('<div/>');
            priceTomanEl.addClass('priceToman');
            priceTomanEl.css({
                'color': '#f60', 'font-size': '33px', 'font-weight': 'bold', 'direction': 'rtl',
                'text-align': 'left', 'font-family': 'nazanin, bnazanin, "b nazanin"', 'display': 'inline-block',
            });
            priceTomanEl.text(priceUnit);
            $(this).after(priceTomanEl);
            $(this).css({'color': '#c7c7c7', 'font-size': '16px'});
        } else {
            priceTomanEl.text(priceUnit);
        }

    });

    var tId = setInterval(function() {
        if (document.readyState == 'complete') onComplete();
    }, 11);
    function onComplete(){
        clearInterval(tId);
        $(selectors).trigger('DOMSubtreeModified');
        $('.goods_together_all .scroll_box').css('height', '285px');
    }

})();