Skip to content

Commit

Permalink
Bug fix, commenting format changes, additional comments, API document…
Browse files Browse the repository at this point in the history
…ation, and icons added

* Bug fixed: When the extension button is clicked multiple time values are continuously added instead of refreshed
  • Loading branch information
xangelix committed Dec 23, 2017
1 parent 75818c6 commit 2d690b0
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 15 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Happy forking!
## Built With

* [JavaScript](https://www.javascript.com/) - The web framework used
* [CryptoCompare API](https://www.cryptocompare.com/api/) - The API for getting accurate prices

## Contributing

Expand Down
2 changes: 1 addition & 1 deletion background.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//Tells chrome to execute content.js when the extension button is pressed
// Tells chrome to execute content.js when the extension button is pressed

chrome.browserAction.onClicked.addListener(function(tab) {
chrome.tabs.executeScript(null, {file: "content.js"});
Expand Down
31 changes: 20 additions & 11 deletions content.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//Asynchronous HTTP Requestor
// Asynchronous HTTP Requestor
var HttpClient = function() {
this.get = function(aUrl, aCallback) {
var anHttpRequest = new XMLHttpRequest();
Expand All @@ -12,30 +12,39 @@ var HttpClient = function() {
};
};

//Collection of Website Information by Class
// Collection of Website Information by Class
var names = document.getElementsByClassName('coin ng-binding');
var amounts = document.getElementsByClassName('total f-right ng-binding');
var btcs = document.getElementsByClassName('equalValue f-right ng-binding ng-scope');
var temp = [];
var namesIndex = [];

//Synchronous spawner of asynchronous requests based off found wallets
//To-do: Only request values above 0
// Test if prices have already been added
if (amounts[1].innerHTML.includes("$")) {
for (var i = 1; i < amounts.length; i++) {
// Removal of previous prices
amounts[i].innerHTML = amounts[i].innerHTML.substring(0, amounts[i].innerHTML.indexOf('$')).slice(0, -4);
}
}

// Synchronous spawner of asynchronous requests based off found wallets
// To-do: Only request values above 0
for (var i = 1, l = amounts.length; i < l; i++) {
var coinValue = "";
temp.push(names[i].innerHTML);
namesIndex.push(names[i].innerHTML);
// To-do: Add more currencies to convert to than USD
var request = 'https://min-api.cryptocompare.com/data/price?fsym=BTC&tsyms=USD';
requestion(request, names[i].innerHTML);
}

//Asynchronous calling
// Asynchronous calling
function requestion(request, name) {
var client = new HttpClient();
client.get(request, function(response) {
parseP(name, response);
});
}

//Parsing of HTTP request
// Parsing of HTTP request
function parseP(coinName, coinValue) {
coinValue = coinValue.substr(7);
coinValue = coinValue.substr(0, coinValue.length - 1);
Expand All @@ -46,8 +55,8 @@ function parseP(coinName, coinValue) {
var output = parseFloat(coinValue) * parseFloat(btcs[index].innerHTML);
output = " - $" + output.toFixed(2);
//console.log('TOTAL: ' + output);
//To-Do: Add tradingview graphs to changed elements
//Final posting of data
// To-do: Add tradingview graphs to changed elements
// Final posting of data
amounts[index + 1].innerHTML += output;
}

Expand All @@ -56,5 +65,5 @@ function indexFinder(coinName) {
function finding(element) {
return element === coinName;
}
return temp.findIndex(finding);
return namesIndex.findIndex(finding);
}
File renamed without changes
Binary file added icon128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icon16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icon48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 6 additions & 3 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@
"manifest_version": 2,

"name": "Binance Valuations",
"version": "0.1.3",
"version": "0.1.4",
"description": "Finds values of individual wallets inside binance!",

"browser_action": { "default_icon": "logo.png" },
"browser_action": { "default_icon": "icon.png" },

"background" : {
"scripts" : ["background.js"]
},

"permissions": ["activeTab"]
"permissions": ["activeTab"],

"icons": { "16": "icon16.png",
"48": "icon48.png",
"128": "icon128.png" }
}

0 comments on commit 2d690b0

Please sign in to comment.