The CoinTools Chrome Extension has an important feature which is the Alt+Q query of the cryptocurrency. This feature can be easily extracted to a Chrome Bookmark Tool.
The Cryptocurrency Lookup is a lightweight Chrome Bookmark Tool that you can add to your bookmarket bar. Once launched, the tool will prompt a dialog that allows your to query the following conversion rates between cryptocurrency/fiat pairs.
Repository: https://github.com/DoctorLai/ChromeBookMark_CryptocurrencyLookup
Cryptocurrency Query Syntax
- BTC SBD – to get the exchange rate between BTC and SBD
- 2 BTC LTC – to see how many LTC can we get out of 2 BTC
- LTC 6 BTC – to see how many LTC are equal to 6 BTC
- the above pairs can also be fiats e.g. USD EUR
How to Install the ChromeBookmark Cryptocurrency Lookup Tool?
Create a Bookmark and paste the source in the URL:
Then, when you click the bookmark, you can issue the query commands:
Javascript Source Code of Cryptocurrency Bookmark
Full source code at github.
Copy to the URL part of the bookmark editor. Avoid using // comments which will break (new lines will be removed). The last query is saved in the local storage of the Chrome browser (current active sessions).
javascript:
(function() {
/* read as text */
function __readResponseAsText(response) {
return response.text();
}
/* read as json */
function __readResponseAsJSON(response) {
return response.json();
}
/* check if valid response */
function __validateResponse(response) {
if (!response.ok) {
throw Error(response.statusText);
}
return response;
}
function __isNumeric(n) {
return !isNaN(parseFloat(n)) && isFinite(n);
}
/* getting conversion from cryptocompare */
function CoinToools_GetPriceCC(a, b) {
a = a.toUpperCase();
if (a == 'SBD') {
a = 'SBD*';
}
b = b.toUpperCase();
if (b == 'SBD') {
b = 'SBD*';
}
if (a == 'SP') {
a = 'STEEM';
}
if (b == 'SP') {
b = 'STEEM';
}
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("Error: " + a + ", " + b);
}
}).catch(function(error) {
reject(error);
});
});
}
let query = localStorage.getItem("CryptocurrencyLookupQuery");
if (!query) {
query = "";
}
let s = prompt("(Cryptocompare) e.g. BTC STEEM, 10 BTC SBD, BTC 10 SBD", query);
if (s != null) {
s = s.trim();
localStorage.setItem("CryptocurrencyLookupQuery", s);
let arr = s.split(' ');
if (arr.length == 2) { /* BTC SBD */
CoinToools_GetPriceCC(arr[0], arr[1]).then((x) => {
alert("1 " + arr[0].toUpperCase() + " = " + x + " " + arr[1].toUpperCase());
}).catch((error) => {
alert(error);
});
} else if (arr.length == 3) { /* 2 BTC STEEM */
if (__isNumeric(arr[0])) {
CoinToools_GetPriceCC(arr[1], arr[2]).then((x) => {
alert(arr[0] + " " + arr[1].toUpperCase() + " = " + (x * arr[0]) + " " + arr[2].toUpperCase());
}).catch((error) => {
alert(error);
});
} else if (__isNumeric(arr[1])) { /* SBD 3 STEEM */
CoinToools_GetPriceCC(arr[2], arr[0]).then((x) => {
alert((arr[1] * x) + " " + arr[0].toUpperCase() + " = " + arr[1] + " " + arr[2].toUpperCase());
}).catch((error) => {
alert(error);
});
}
}
}
})();
–EOF (The Ultimate Computing & Technology Blog) —
606 wordsLast Post: How to Determine the Version of Microsoft Word using VBScript/JScript?
Next Post: Steem Witness Replay Time Takes Longer and Longer

