Skip to content

Instantly share code, notes, and snippets.

@daveWid
Created June 22, 2018 18:23
Show Gist options
  • Save daveWid/c7f9b6cb12a06a15f5d1ebf31bbf1e74 to your computer and use it in GitHub Desktop.
Save daveWid/c7f9b6cb12a06a15f5d1ebf31bbf1e74 to your computer and use it in GitHub Desktop.
/**
* http://gatherer.wizards.com/Pages/Search/Default.aspx?sort=cn+|rarity+&action=advanced&output=checklist&set=%20[%22Dominaria%22]&type=%20![%22Land%22]%20![%22Planeswalker%22]
*/
(function(rows){
var row, info, output = [];
var countMap = {
C: 3,
U: 2,
R: 1,
M: 1
};
function formatRow(data) {
return '| ' + data.join(' | ') + ' |';
}
output.push(formatRow(['Have', 'Need', 'Name']));
output.push(formatRow(['----', '----', '----']));
for (var i = 0, len = rows.length; i < len; i++) {
row = rows.item(i);
info = [0];
info.push(countMap[row.querySelector('.rarity').textContent]);
info.push(row.querySelector('.name').textContent);
output.push(formatRow(info));
}
console.log(output.join("\n"));
})(document.querySelector('table.checklist').querySelectorAll('tr.cardItem'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment