Last active
June 10, 2016 14:09
-
-
Save phts/70edee69d0445f4d71ff to your computer and use it in GitHub Desktop.
Bookmarklet to add USD prices to an item page on catalog.onliner.by
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function(){ | |
"use strict"; | |
var $a = $(".b-offers-desc__info-sub > a.b-offers-desc__info-price-value_secondary"); | |
var byrPricesText = $a.text(); | |
var byrPrices = byrPricesText.replace(/[^0-9–]/g, "").split("–"); | |
var currencyText = $("#currency-informer > a > span").text().replace(/[^0-9]/g, ""); | |
var currency = parseInt(currencyText); | |
var usdPrices = []; | |
for (var byrPrice of byrPrices) { | |
usdPrices.push(Math.round(parseInt(byrPrice) / currency)); | |
} | |
$a.append(" ( $" + usdPrices.join(" – $") + " )"); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment