Skip to content

Instantly share code, notes, and snippets.

@nikicat
Last active July 14, 2024 13:48
Show Gist options
  • Save nikicat/c85d3d7873852a56de1a0db7ac3e454d to your computer and use it in GitHub Desktop.
Save nikicat/c85d3d7873852a56de1a0db7ac3e454d to your computer and use it in GitHub Desktop.
Any-to-USD converter Userscript
// ==UserScript==
// @name Any to USD currency converter
// @namespace http://tampermonkey.net/
// @version 2024-07-13
// @description converts any cryptocurrency to USD
// @author Zxczxc
// @match *://*/*
// @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgAAAAIACAIAAAB7GkOtAAAurElEQVR42uzVQQ0AIAzAwKnDHyqxgY0lveQE9Nc59wEQNDuzADAAAAwAAAMAwAAAMAAADAAAAwDAAAAwAIA4AwCIMgCAKAMAiDIAgCgDAIgyAIAoAwCIMgCAKAMAiDIAgCgDAIgyAIAoAwCIMgCAKAMAiDIAgCgDAIgyAIAoAwCIMgCAKAMAiDIAgCgDAIgyAIAoAwCIMgCAKAMAiDIAgCgDAIgyAIAoAwCIMgCAKAMAiDIAgCgDAIgyAIAoAwCIMgCAKAMAiDIAgCgDAIgyAIAoAwCIMgCAKAMAiDIAgCgDAIgyAIAoAwCIMgCAKAMAiDIAgCgDAIgyAIAoAwCIMgCAKAMAiDIAgCgDAIgyAIAoAwCIMgCAKAMAiDIAgCgDAIgyAIAoAwCIMgCAKAMAiDIAgCgDAIgyAIAoAwCIMgCAKAMAiDIAgCgDAIgyAIAoAwCIMgCAKAMAiDIAgCgDAIgyAIAoAwCIMgCAKAMAiDIAgCgDAIgyAIAoAwCIMgCAKAMAiDIAgCgDAIgyAIAoAwCIMgCAKAMAiDIAgCgDAIgyAIAoAwCIMgCAKAMAiDIAgCgDAIgyAIAoAwCIMgCAKAMAiDIAgCgDAIgyAIAoAwCIMgCAKAMAiDIAgCgDAIgyAIAoAwCIMgCAKAMAiDIAgCgDAIgyAIAoAwCIMgCAKAMAiDIAgCgDAIgyAIAoAwCIMgCAKAMAiDIAgCgDAIgyA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XKiIqEM9tLRgQR3Vwo2tRtAZkYBmUKUGobjlJih7S+++KK1cjNGnLSTY3rg1VdfLe6DM97atWu/8847jM/UebcdNoBM4qsMP6FdqjgIip8fe+wxSh903lujMV3kgLRnz55lypQRB3HJJZcMHDiQkLXOexsqA8gkZRRdu3alkFrUo2jRoux2J0+ebI0cjMbcSaPDli1bEkUR9aAtI5nrixYt0nknQ24AmeQBsCcghUbVOQH1LxT7UQhDTif973TeOqNRJw8ePDht2rSnnnrqxhtvVJUNiDNRo8N6f8GCBeFYzzlvAJnkeTCBko5pderUYdEtKQeHupUrV+7Ro8ekSZOsgtdoDOr8j90zAaIqVaqk5dCYRESC+/369Zs9e/Zvv/2m8y6ZAfyJPCee1vDhw7t169awYcPy5cuTkBt4+mbp0qWp26JkgYMsRJ/2djrvhtEYDu7duxczYCr9Qw89xEQ8zgwCTyfFY8qVK0dEgQjzG2+8Qe0C2xGdd8MMIH+WsHLlynHjxrFFoNiY/pr01if9oEKFCuh48eLFCdpkWc4TUypVqtQFF1xA0k61atV4J+655x7685CPRC6zW2f9RmMoyf6AIPCoUaOIFzVr1qxBgwZ8qnywfLbMqOET5kPOUpnFAOezzjqLD5/hVHSibNSoUYsWLVjgM7KQ5NRwy310DcBn5JG8NBKNLIBjNIaGfM6kXPNp22mcGYDRaDQazQCMRqMx2jQDMBqNxojSDMBoNBojSjMAo9FojCj/r706IAEAAAAQ9P91QxL8oAAApgQAMCUAgCkBAEwJAGBKAABTAgCYEgDAlAAApgQAMCUAgCkBAEwJAGBKAABTAgCYEgDAlAAApgQAMCUAgCkBAEwJAGBKAABTAgCYEgDAlAAApgQAMCUAgCkBAEwJAGBKAABTAgCYEgDAlAAApgQAMCUAgCkBAEwFJ+xcwZIua2IAAAAASUVORK5CYII=
// @downloadURL https://gist.githubusercontent.com/nikicat/c85d3d7873852a56de1a0db7ac3e454d/raw/any-to-usd.userscript.js
// @updateURL https://gist.githubusercontent.com/nikicat/c85d3d7873852a56de1a0db7ac3e454d/raw/any-to-usd.userscript.js
// @grant GM.xmlHttpRequest
// @run-at document-start
// @connect api.coinbase.com
// @sandbox DOM
// ==/UserScript==
const regex = /(?<value>[\d\.\s]+)\s?(?<currency>[a-z\.-]{3,})/i;
const log = console.log;
const fetch = window.GM ? window.GM.xmlHttpRequest : window.fetch;
function debug(...args) {
if (true) {
log.call(args);
}
}
function prettyNumber(num) {
let numString = num.toString()
for (let thPos = 3; thPos < numString.length; thPos += 4) {// thin space U+2009
numString = numString.slice(0, numString.length - thPos) + ' ' + numString.slice(-thPos)
}
return numString
}
(function() {
'use strict';
log("Any to USD currency converter initialized");
document.addEventListener("selectionchange", async (event) => {
const selection = window.document.getSelection();
const str = selection.toString()
//log("selection", str, selection);
const match = str.match(regex);
if (!match) {
return
}
const node = selection.anchorNode;
const elem = node.setAttribute ? node : node.parentElement;
const g = match.groups
log("match", g, node);
const url = "https://api.coinbase.com/v2/exchange-rates?currency=USD";
try {
const r = await fetch({ url: url, responseType: "json" });
const rates = r.response.data.rates;
log("resp", rates);
let currency = g.currency.toUpperCase();
let value = g.value.replaceAll(/\s/g, '');
if (currency === 'SAT' || currency === 'SATS') {
currency = 'BTC';
value /= 100_000_000;
}
const rate = rates[currency];
if (!rate) {
log("currency not found", currency, rates);
return
}
const usd = value / rate;
log("amount USD:", usd);
elem.setAttribute("title", `$ ${prettyNumber(usd.toFixed(2))}`);
} catch (exc) {
log("error", exc);
return
}
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment