Add support for Crypto.org blockchain

They’ve recently officially launched the crypto.org blockchain on the 25th of March, so I thought it’d be nice if you guys could add this feature.

While we wait for this to be implemented, you can try this JS using the web console in your browser when you are on the explorer page. It just reads from the table and makes a CSV. I had wanted to read form the API that fills the table, but I didn’t have time to figure it out.

var table = document.getElementsByClassName("ant-table-tbody")[0];
var t = "\"Koinly Date\",\"Amount\",\"Currency\",\"Fee Amount\",\"Fee Currency\",\"Label\",\"Description\",\"TxHash\"";
for (var i = 0, row; row = table.rows[i]; i++) {
	if (row.cells.length == 1) continue;
	if (row.cells[2].children[0].ariaLabel == "check-circle") {
		if (row.cells[5].textContent == "IN") {
			t+="\n"+[row.cells[3].children[1].textContent.replace(",", ""),
			 row.cells[7].textContent.replace("CRO", "").replace(",", "").trim(),
			 "CRO",
			 "",
			 "",
			 "",
			 row.cells[4].textContent + " to " + row.cells[6].textContent,
			 row.cells[1].children[0].textContent].join(",");
		} else {
			if (row.cells[1].children[1].textContent == "Delegate" | row.cells[1].children[1].textContent == "Redelegate") {
				t+="\n"+[row.cells[3].children[1].textContent.replace(",", ""),
				 "-" + row.cells[8].textContent.replace("CRO", "").trim(),
				 "CRO",
				 "",
				 "",
				 "cost",
				 "\"" + row.cells[1].children[1].textContent + " " + row.cells[7].textContent + "\"",
				 row.cells[1].children[0].textContent].join(",");
			} else if (row.cells[1].children[1].textContent == "Withdraw Reward") {
				t+="\n"+[row.cells[3].children[1].textContent.replace(",", ""),
				 row.cells[7].textContent.replace("CRO", "").trim(),
				 "CRO",
				 "",
				 "",
				 "staking",
				 "\"" + row.cells[1].children[1].textContent + " " + row.cells[7].textContent + "\"",
				 row.cells[1].children[0].textContent].join(",");
			} else {
				t+="\n"+[row.cells[3].children[1].textContent.replace(",", ""),
				 "-" + row.cells[7].textContent.replace("CRO", "").replace(",", "").trim(),
				 "CRO",
				 row.cells[8].textContent.replace("CRO", "").trim(),
				 "CRO",
				 "",
				 row.cells[4].textContent + " to " + row.cells[6].textContent,
				 row.cells[1].children[0].textContent].join(",");
			}
		}
	} else {
		t+="\n"+[row.cells[3].children[1].textContent.replace(",", ""),
		 "-" + row.cells[8].textContent.replace("CRO", "").trim(),
		 "CRO",
		 "",
		 "",
		 "cost",
		 "Transaction failed / fee only",
		 row.cells[1].children[0].textContent].join(",");
	}
}
var csv_file = document.getElementsByClassName("account___TB_Tx")[0].textContent + ' Koinly.csv';
var universalBOM = "\uFEFF";
var a = window.document.createElement('a');
a.setAttribute('href', 'data:text/csv; charset=utf-8,' + encodeURIComponent(universalBOM + t));
a.setAttribute('download', csv_file);
window.document.body.appendChild(a);
a.click();

EDIT: Here is a bookmarklet of the above, which is more convenient.

javascript:void%20function(){for(var%20e,t=document.getElementsByClassName(%22ant-table-tbody%22)[0],n='%22Koinly%20Date%22,%22Amount%22,%22Currency%22,%22Fee%20Amount%22,%22Fee%20Currency%22,%22Label%22,%22Description%22,%22TxHash%22',l=0;e=t.rows[l];l++)1!=e.cells.length%26%26(n+=%22check-circle%22==e.cells[2].children[0].ariaLabel%3F%22IN%22==e.cells[5].textContent%3F%22\n%22+[e.cells[3].children[1].textContent.replace(%22,%22,%22%22),e.cells[7].textContent.replace(%22CRO%22,%22%22).replace(%22,%22,%22%22).trim(),%22CRO%22,%22%22,%22%22,%22%22,e.cells[4].textContent+%22%20to%20%22+e.cells[6].textContent,e.cells[1].children[0].textContent].join(%22,%22):%22Delegate%22==e.cells[1].children[1].textContent|%22Redelegate%22==e.cells[1].children[1].textContent%3F%22\n%22+[e.cells[3].children[1].textContent.replace(%22,%22,%22%22),%22-%22+e.cells[8].textContent.replace(%22CRO%22,%22%22).trim(),%22CRO%22,%22%22,%22%22,%22cost%22,'%22'+e.cells[1].children[1].textContent+%22%20%22+e.cells[7].textContent+'%22',e.cells[1].children[0].textContent].join(%22,%22):%22Withdraw%20Reward%22==e.cells[1].children[1].textContent%3F%22\n%22+[e.cells[3].children[1].textContent.replace(%22,%22,%22%22),e.cells[7].textContent.replace(%22CRO%22,%22%22).trim(),%22CRO%22,%22%22,%22%22,%22staking%22,'%22'+e.cells[1].children[1].textContent+%22%20%22+e.cells[7].textContent+'%22',e.cells[1].children[0].textContent].join(%22,%22):%22\n%22+[e.cells[3].children[1].textContent.replace(%22,%22,%22%22),%22-%22+e.cells[7].textContent.replace(%22CRO%22,%22%22).replace(%22,%22,%22%22).trim(),%22CRO%22,e.cells[8].textContent.replace(%22CRO%22,%22%22).trim(),%22CRO%22,%22%22,e.cells[4].textContent+%22%20to%20%22+e.cells[6].textContent,e.cells[1].children[0].textContent].join(%22,%22):%22\n%22+[e.cells[3].children[1].textContent.replace(%22,%22,%22%22),%22-%22+e.cells[8].textContent.replace(%22CRO%22,%22%22).trim(),%22CRO%22,%22%22,%22%22,%22cost%22,%22Transaction%20failed%20/%20fee%20only%22,e.cells[1].children[0].textContent].join(%22,%22));var%20c=document.getElementsByClassName(%22account___TB_Tx%22)[0].textContent+%22%20Koinly.csv%22,o=%22\ufeff%22,r=window.document.createElement(%22a%22);r.setAttribute(%22href%22,%22data:text/csv;%20charset=utf-8,%22+encodeURIComponent(o+n)),r.setAttribute(%22download%22,c),window.document.body.appendChild(r),r.click()}();
1 Like

wouldn’t it be better to extract the data from https://crypto.org/explorer/api/v1/accounts/ADDRESS/transactions?limit=100000&order=height.desc

Cause on normal web the amounts are heavily rounded

@g0nzi77, you are right. But I didn’t have the patience to figure the API out. The rounding on the web is a new “feature” since I first wrote the bookmarklet. Here is an updated version to account for it.

var table = document.getElementsByClassName("ant-table-tbody")[0];
var t = "\"Koinly Date\",\"Amount\",\"Currency\",\"Fee Amount\",\"Fee Currency\",\"Label\",\"Description\",\"TxHash\"";
var amount = ""
for (var i = 0, row; row = table.rows[i]; i++) {
	if (row.cells.length == 1) continue;
	row.cells[0].children[0].click()
	if (row.cells[2].children[0].ariaLabel == "check-circle") {
		amount=table.rows[i+1].cells[0].firstChild.firstChild.lastChild.lastChild.textContent.replace(" CRO", "").replace(",", "")
    	if (row.cells[5].textContent == "IN") {
    		t+="\n"+[row.cells[3].children[1].textContent.replace(",", ""),
    		 amount,
    		 "CRO",
    		 "",
    		 "",
    		 "",
    		 row.cells[4].textContent + " to " + row.cells[6].textContent,
    		 row.cells[1].children[0].textContent].join(",");
    	} else {
    		if (row.cells[1].children[1].textContent == "Delegate" | row.cells[1].children[1].textContent == "Redelegate") {
    			t+="\n"+[row.cells[3].children[1].textContent.replace(",", ""),
    			 "-" + row.cells[8].textContent.replace("CRO", "").trim(),
    			 "CRO",
    			 "",
    			 "",
    			 "cost",
    			 "\"" + row.cells[1].children[1].textContent + " " + amount + "\"",
    			 row.cells[1].children[0].textContent].join(",");
    		} else if (row.cells[1].children[1].textContent == "Withdraw Reward") {
    			t+="\n"+[row.cells[3].children[1].textContent.replace(",", ""),
    			 amount,
    			 "CRO",
    			 "",
    			 "",
    			 "staking",
    			 "\"" + row.cells[1].children[1].textContent + " " + amount + "\"",
    			 row.cells[1].children[0].textContent].join(",");
    		} else {
    			t+="\n"+[row.cells[3].children[1].textContent.replace(",", ""),
    			 "-" + amount,
    			 "CRO",
    			 row.cells[8].textContent.replace("CRO", "").trim(),
    			 "CRO",
    			 "",
	    		 row.cells[4].textContent + " to " + row.cells[6].textContent,
	    		 row.cells[1].children[0].textContent].join(",");
    		}
		}
	} else {
    	t+="\n"+[row.cells[3].children[1].textContent.replace(",", ""),
    	 "-" + row.cells[8].textContent.replace("CRO", "").trim(),
    	 "CRO",
    	 "",
		 "",
    	 "cost",
    	 "Transaction failed / fee only",
		 row.cells[1].children[0].textContent].join(",");
	}
}
var csv_file = document.getElementsByClassName("account___TB_Tx")[0].textContent + ' Koinly.csv';
var universalBOM = "\uFEFF";
var a = window.document.createElement('a');
a.setAttribute('href', 'data:text/csv; charset=utf-8,' + encodeURIComponent(universalBOM + t));
a.setAttribute('download', csv_file);
window.document.body.appendChild(a);
a.click();

And the bookmarklet:

javascript:void%20function(){for(var%20e,t=document.getElementsByClassName(%22ant-table-tbody%22)[0],l='%22Koinly%20Date%22,%22Amount%22,%22Currency%22,%22Fee%20Amount%22,%22Fee%20Currency%22,%22Label%22,%22Description%22,%22TxHash%22',n=%22%22,c=0;e=t.rows[c];c++)1!=e.cells.length%26%26(e.cells[0].children[0].click(),%22check-circle%22==e.cells[2].children[0].ariaLabel%3F(n=t.rows[c+1].cells[0].firstChild.firstChild.lastChild.lastChild.textContent.replace(%22%20CRO%22,%22%22).replace(%22,%22,%22%22),l+=%22IN%22==e.cells[5].textContent%3F%22\n%22+[e.cells[3].children[1].textContent.replace(%22,%22,%22%22),n,%22CRO%22,%22%22,%22%22,%22%22,e.cells[4].textContent+%22%20to%20%22+e.cells[6].textContent,e.cells[1].children[0].textContent].join(%22,%22):%22Delegate%22==e.cells[1].children[1].textContent|%22Redelegate%22==e.cells[1].children[1].textContent%3F%22\n%22+[e.cells[3].children[1].textContent.replace(%22,%22,%22%22),%22-%22+e.cells[8].textContent.replace(%22CRO%22,%22%22).trim(),%22CRO%22,%22%22,%22%22,%22cost%22,'%22'+e.cells[1].children[1].textContent+%22%20%22+n+'%22',e.cells[1].children[0].textContent].join(%22,%22):%22Withdraw%20Reward%22==e.cells[1].children[1].textContent%3F%22\n%22+[e.cells[3].children[1].textContent.replace(%22,%22,%22%22),n,%22CRO%22,%22%22,%22%22,%22staking%22,'%22'+e.cells[1].children[1].textContent+%22%20%22+n+'%22',e.cells[1].children[0].textContent].join(%22,%22):%22\n%22+[e.cells[3].children[1].textContent.replace(%22,%22,%22%22),%22-%22+n,%22CRO%22,e.cells[8].textContent.replace(%22CRO%22,%22%22).trim(),%22CRO%22,%22%22,e.cells[4].textContent+%22%20to%20%22+e.cells[6].textContent,e.cells[1].children[0].textContent].join(%22,%22)):l+=%22\n%22+[e.cells[3].children[1].textContent.replace(%22,%22,%22%22),%22-%22+e.cells[8].textContent.replace(%22CRO%22,%22%22).trim(),%22CRO%22,%22%22,%22%22,%22cost%22,%22Transaction%20failed%20/%20fee%20only%22,e.cells[1].children[0].textContent].join(%22,%22));var%20o=document.getElementsByClassName(%22account___TB_Tx%22)[0].textContent+%22%20Koinly.csv%22,r=%22\ufeff%22,i=window.document.createElement(%22a%22);i.setAttribute(%22href%22,%22data:text/csv;%20charset=utf-8,%22+encodeURIComponent(r+l)),i.setAttribute(%22download%22,o),window.document.body.appendChild(i),i.click()}();
1 Like