Last active
February 23, 2024 20:00
-
-
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.
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
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 |
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
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
HOW CAN I USE THIS SCRIPT?
Go to any STANDARD deck list on Decklog (for example: https://decklog-en.bushiroad.com/view/AVH6)
![image](https://user-images.githubusercontent.com/15229355/219965496-1e31fe19-8b8a-42cc-bd7a-4907ca564c41.png)
Run the script either via a Bookmarklet or via the console and copy your newly generated deck list !
![image](https://user-images.githubusercontent.com/15229355/219965525-8c2af988-2ff5-4df5-b7ba-7ed61cba9ad1.png)
You can now import it using Cardmarket's "Wants" feature:
![image](https://user-images.githubusercontent.com/15229355/219966727-3f8d130c-790a-41f9-8c7e-90184884c13b.png)
HOW DO I ADD A BOOKMARKLET?
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 !)