// ==UserScript== // @name Mandarake JPY to EUR // @namespace http://order.mandarake.co.jp/ // @version 0.4 // @description Converts Mandarake pricing to EUR // @author EIREXE // @match https://order.mandarake.co.jp/* // @grant none // @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js // @downloadURL none // ==/UserScript== // Stackoverflow format unicorn String.prototype.formatUnicorn = String.prototype.formatUnicorn || function () { "use strict"; var str = this.toString(); if (arguments.length) { var t = typeof arguments[0]; var key; var args = ("string" === t || "number" === t) ? Array.prototype.slice.call(arguments) : arguments[0]; for (key in args) { str = str.replace(new RegExp("\\{" + key + "\\}", "gi"), args[key]); } } return str; }; (function() { 'use strict'; var JPY_data = "https://free.currencyconverterapi.com/api/v5/convert?callback=?"; $.getJSON(JPY_data, { q: "JPY_EUR", compact: "y" }).done(function(data){ console.log(data); var exchange_rate = data.JPY_EUR.val; $('p:contains(" yen")').filter(function() { var price_jpy_str = $(this).text().split(" ")[0]; var price_jpy = parseFloat(price_jpy_str.replace(/,/g, "")); var price_converted = (price_jpy*exchange_rate); var price_converted_format = price_converted.toLocaleString(undefined, {maximumFractionDigits: 2}); $(this).text(""); $(this).append("{price} €".formatUnicorn({"price": price_converted_format})); $(this).append(" ({price_jpy} ¥)".formatUnicorn({"price_jpy": price_jpy.toLocaleString()})); return; }); }); })();