Last active
June 20, 2020 11:23
-
-
Save multimeric/686ccf9d47caf9624d4225239c305dc4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This script prints out a TCG order as a TSV (plain text spreadsheet that can be imported into Excel) | |
// Usage instructions: | |
// 1) Log in to your account and visit https://store.tcgplayer.com/myaccount/orderhistory | |
// 2) Type in the order number that you want printed out into the search bar | |
// 3) Open the dev console using F12 | |
// 4) Click the "Console" tab in the top bar | |
// 5) Copy this entire script to your clipboard | |
// 6) Paste it into the console text box and press enter | |
// 7) A TSV (tab-separated value) table of your TCG Player order will be printed out | |
{ | |
function qs(element, query){ | |
// Finds an element by selector and returns it as an array | |
return Array.from(element.querySelectorAll(query)) | |
} | |
let csv = 'Name\tRarity\tCondition\tIndividual Price\tQuantity\n'; | |
for (let order of qs(document, '.orderWrap')){ | |
for (let tr of qs(order, '.orderTable tr')){ | |
try{ | |
let items = [ | |
qs(tr, '.nocontext')[0].innerText, | |
qs(tr, '.orderHistoryDetail')[0].childNodes[0].textContent.split(':')[1], | |
qs(tr, '.orderHistoryDetail')[0].childNodes[2].textContent.split(':')[1], | |
qs(tr, '.orderHistoryPrice')[0].innerText, | |
qs(tr, '.orderHistoryQuantity')[0].innerText | |
]; | |
csv += items.map(item => item.trim()).join('\t') + '\n'; | |
} | |
catch { | |
continue; | |
} | |
} | |
} | |
console.log(csv); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment