Skip to content

Instantly share code, notes, and snippets.

@christopherkade
Last active February 23, 2024 20:00
Show Gist options
  • Save christopherkade/0dedc95b4ef1e982b67d7c1b04e78af1 to your computer and use it in GitHub Desktop.
Save christopherkade/0dedc95b4ef1e982b67d7c1b04e78af1 to your computer and use it in GitHub Desktop.
Generates a Cardmarket "Wants" deck list based on the deck being viewed on any decklog-en.bushiroad.com/view/DECK-CODE page. Save the bookmarklet below as a bookmark or use the Javascript code directly in the console.
javascript:var%20%24jscomp%3D%24jscomp%7C%7C%7B%7D%3B%24jscomp.scope%3D%7B%7D%3B%24jscomp.createTemplateTagFirstArg%3Dfunction(a)%7Breturn%20a.raw%3Da%7D%3B%24jscomp.createTemplateTagFirstArgWithRaw%3Dfunction(a%2Cb)%7Ba.raw%3Db%3Breturn%20a%7D%3Bvar%20getDeckListFromDom%3Dfunction(a)%7Ba%3Dvoid%200%3D%3D%3Da%3F%22D%22%3Aa%3Bvar%20b%3D%22%22%3Bdocument.querySelectorAll(%22.card-controller-inner%22).forEach(function(c)%7Bvar%20d%3Dc.firstChild.title.split(%22%3A%22)%5B1%5D.trim()%3Bc%3Dc.lastChild.innerText%3Bd%3Dd.concat(%22%20%5B%22%2Ba%2B%22%20Format%5D%22)%3Bb%3Db.concat(%22%5Cn%22%2Cc%2B%22%20%22%2Bd)%7D)%3Breturn%20b%7D%2Clist%3DgetDeckListFromDom()%3Bprompt(%22Please%20copy%20your%20decklist%20and%20import%20it%20to%20Cardmarket%22%2Clist)%3Bvoid+0
const getDeckListFromDom = (format = 'D') => {
const cardData = document.querySelectorAll('.card-controller-inner');
let deckList = ''
cardData.forEach(data => {
let name = data.firstChild.title.split(':')[1].trim();
const number = data.lastChild.innerText;
name = name.concat(` [${format} Format]`)
deckList = deckList.concat('\n', `${number} ${name}`)
})
return deckList
}
const list = getDeckListFromDom();
prompt('Please copy your decklist and import it to Cardmarket', list)
@christopherkade
Copy link
Author

christopherkade commented Feb 19, 2023

HOW CAN I USE THIS SCRIPT?

  1. Go to any STANDARD deck list on Decklog (for example: https://decklog-en.bushiroad.com/view/AVH6)
    image

  2. Run the script either via a Bookmarklet or via the console and copy your newly generated deck list !
    image

  3. You can now import it using Cardmarket's "Wants" feature:
    image

HOW DO I ADD A BOOKMARKLET?

  • Simply create a new bookmark for a page and paste the bookmarklet inside the URL field
  • Add a relevant title
    image

WHY DOES IT ONLY WORK FOR STANDARD DECKS?

Because of the way Bushiroad coded their decklog pages, it's not super easy to retrieve a card's format (and I couldn't be bothered to do it just yet, but feel free to export a list and manually set each card's format !)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment