If you’re into Hearthstone, you probably see people posting decklists to Twitter, like this:

The big ugly string at the bottom is a deck code, which you can paste into the game to build a copy of the deck. There are also a lot of great tools out there to help improve your game. One of my favourites is HSReplay.net because it keeps track of your card collection via Hearthstone Deck Tracker, so it can show you how much dust1 it would cost you to build a given deck.

I’m a casual player, so this is always the first thing I check. So I wrote a python script to make it easier! You can integrate it with macOS’s Automator, or in iOS via Pythonista, potentially with the help of Workflow. It takes a block of text (of a tweet, for instance) as input, finds the first thing that it thinks looks like a deck code2, and generates an HSReplay.net URL. For instance, if run on the tweet above, it generates this link.

The script is available here.

  1. One of the game’s two currencies. You can use gold to buy packs of random cards, and you can use dust to craft specific cards. 

  2. Any part of the string that has 30 or more consecutive characters with no whitespace