A prototype for a Chrome extension to allow your web app access to your D&D Beyond content.
TL;DR This is an egregious hack.
The very idea this is based upon (programmaticallyextracting data from rendered web pages) is very fragile. It's also something that most web pages don't want you to do, so you're likely to start getting captchas to prevent it:
Using this for an actual user-facing product (or anything that you need to not break) is highly discouraged. Because of this, the code's quality is admittedly not great either.
Methods in this library return Promises containing the requested data.
Example usage:
dndBeyond.searchMonsters('goblin').then(
searchResults => displaySearchResults(searchResults));
dndBeyond.getMonsterFromUrl('https://www.dndbeyond.com/monsters/goblin').then(
monsterData => displayMonster(monsterData));
-
Update
crx/manifest.json
, the manifest of the Chrome extension.Make sure you replace all instances of
YOUR_APP
,YOUR_DOMAIN
, etc. with the proper values, and also alter any title/name text you wish. -
Load the
crx
folder as an "unpacked extension" in Chrome.Make sure your take note of the extension's ID when it's been loaded. You'll need it for the next step.
-
Update
dndbeyond.js
, the proxy script you use in your web app.Put your extension's ID in the
CHROME_EXTENSION_ID
constant near the top of the file. -
Include the updated
dndbeyond.js
script in your page and start using it!