CoinTools Update: Adding Cryptocompare Source + Context Shortcut
utopian-io·@justyy·
0.000 HBDCoinTools Update: Adding Cryptocompare Source + Context Shortcut
## Introduction to CoinTools [CoinTools](https://helloacm.com/cointools-update-enhanced-ux-with-cryptocurrency-search-and-showing-changes/) is a powerful, lightweight Chrome Extension for [Cryptocurrency](https://helloacm.com/cointools-update-adding-cryptocompare-source-context-shortcut/) fans! It can be installed via Chrome Webstore: https://chrome.google.com/webstore/detail/coin-tools/fmglcggbdcbkpkfapngjobfeakehpcgj For Opera browsers, the workaround is to first install [Chrome Extension Gadget](https://addons.opera.com/en/extensions/details/download-chrome-extension-9/). And similarly for Firefox, you can install [Chrome Store Foxified](https://addons.mozilla.org/en-US/firefox/addon/chrome-store-foxified/) before you install CoinTools . ## New Features of CoinTools v0.0.15.1 [This commit](https://github.com/DoctorLai/CoinTools/commit/b67ef5b67bb4b8c2a541e02d1ddc34fef92a1438) adds the following features: 1. Adding Cryptocompare API as a backup source so that it is more robust and supports less popular fiats such as [NGN](https://helloacm.com/cryptocurrency-bots-update-adding-ngn-single-fiat-command/). 2. Add Context Shortcuts for a few useful Cryptocurrency websites. ## Screenshots of CoinTools v0.0.15.1 Single Fiat Command to Local Currency  History Graph from Cryptocompare  Context Shortcuts  ## Robust Cryptocompare In this version, we have added the cryptocompare source, which is returned as a Javascript Promise. ``` // getting conversion from cryptocompare const getPriceCC = (a, b) => { a = a.toUpperCase(); b = b.toUpperCase(); let api = "https://min-api.cryptocompare.com/data/price?fsym=" + a + "&tsyms=" + b; return new Promise((resolve, reject) => { fetch(api, {mode: 'cors'}) .then(validateResponse) .then(readResponseAsJSON) .then(function(result) { if (result[b]) { resolve(result[b]); } else { reject("invalid pairs: " + a + ", " + b); } }).catch(function(error) { logit(get_text("request_failed", "Request failed") + ': ' + api + ": " + error); reject(error); }); }); } ``` For example, when coinmarketcap fails, the tool will go to cryptocompare: ``` // ajax calling API to return the price of USD for coin const getPriceOfUSD = (coin) => { return new Promise((resolve, reject) => { let api = "https://api.coinmarketcap.com/v1/ticker/" + coin + '/'; fetch(api, {mode: 'cors'}) .then(validateResponse) .then(readResponseAsJSON) .then(function(result) { if (result[0].price_usd) { resolve(result[0].price_usd); } else { getPriceCC(coin, 'USD').then((res) => { resolve(res); }).catch(function(error) { reject(error); }); } }).catch(function(error) { getPriceCC(coin, 'USD').then((res) => { resolve(res); }).catch(function(error) { logit(get_text("request_failed", "Request failed") + ': ' + api + ": " + error); reject(error); }); }); }); } ``` ## Technology Javascript that runs in the Chrome Browser (ES6) ## Contribution Fully Opensource: https://github.com/DoctorLai/CoinTools Submit a PR or a issue if you found a bug. --------------------------------------------------- Support me and my work as a [witness](https://steemit.com/witness-category/@justyy/justyy-just-another-witness) by 1. voting me [here, or](https://steemconnect.com/sign/account_witness_vote?approve=1&witness=justyy) 2. voting me as a [proxy](https://v2.steemconnect.com/sign/account-witness-proxy?proxy=justyy&approve=1) Some of my contributions: **[SteemIt Tools, Bots, APIs and Tutorial](https://helloacm.com/tools/steemit/)** <br /><hr/><em>Posted on <a href="https://utopian.io/utopian-io/@justyy/cointools-update-adding-cryptocompare-source-context-shortcut">Utopian.io - Rewarding Open Source Contributors</a></em><hr/>
👍 liangfengyouren, laijihua, bambugrove, novelafans, hungryhustle, steemline, victorialuxx, andrianna, mycat, abss, comingback, lebin, cryptonewsly, helo, nichoros, davidke20, elizacheng, nada101, ayman101, halleyleow, winniex, nileelily, chann, coindzs, awiwea1974, kamel101, jiangchen, talesfrmthecrypt, yasu24, aafeng, rosatravels, luneknight, moonvoid, boontjie, irenett, maiyude, rsmartt777, fishbb, catwomanteresa, frankintaiwan, xuran, historylover, shenchensucc, vandadream, gutzygwin, foodielifestyle, woolfe19861008, anxin, twinsnicole, moobear, nean, sweet-jenny8, ethanlee, rainyapril, serenazz, al2ping, zasilla, ayanamoon, aaronstar, kangnajiang, nokeh, regals, geass, shengjian, daxiang, fanso, lilypang22, deepthinking, vincenthan, ashi0, robinlee, dongfengman, zens, yuxuan, shentrading, yedda, joelone, jianan, steemitvip, dailychina, dailystats, dailyfortune, justyy, superbing, happyukgo, piotr-galas, enforcer48, sandan, honoru, kimxinfo, jinluan, liuzg, cqf, susanli3769, davidmendel, sanka2808, gallkinigo, shyshov, jjay, tdre, meixia, teamsteem, heyitskolin, jinzo, agoha, magicmonk, touhidalam69, grzesiekb, thinkingmind, utopian-io, xiaoshancun, syarkawi, pope1995, ace108,