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