Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×

Access to Campaign through DOM and JS

1660248253

Edited 1660248342
Hi everyone! I hope I'm posting in the right forum I have a small project and, to sumarize the idea, I want to create Character Sheets from a third party BackEnd to a Roll20 Campaign. I looked up on the Internet and found out that the best and easiest way to do it is through an browser extension written in JS calling functions in the site. I'm not a JS guy, I'm more from the backend side of things, but I found that if I inspect some Campaign in browser and type "window.Campaign.characters.create({name: "Some Name Here"})" in the console, the game actually creates a Blank Sheet with that Name. So my question is: how to write this in a JS file so I can, for example, import a Sheet from a site that supports this extension? Thanks in advance
1660252357

Edited 1660253117
As you have a pro subscription consider writing a mod script. These are also written in javascript.
Martijn S. said: As you have a pro subscription consider writing a mod script. These are also written in javascript. My idea is that anybody could use this feature, not just who pays for the Pro. I could write a Mod, as I did to test somethings, but I want anyone else to use this
1660253612
The Aaron
Roll20 Production Team
API Scripter
That's definitely outside the scope of what we can help with here.  I'd look for some tutorials on writing browser extensions elsewhere, there are plenty of them, and once you get a feel for them, start digging into whatever interfaces you have access to in the browser. Traditionally, we write Mod Scripts that take in some structured data (like JSON) and parse it to create structures in Roll20.  The down\side is, that's fairly manual for the migration of the data from off site.  However, you could write a blend of the two approaches and end up with a pretty compelling system. Good luck!  Definitely reach out for help on the Mod Scripts side of all that.
1660282263

Edited 1660282527
Oosh
Sheet Author
API Scripter
That's a pretty significant task. You'll need to be fairly confident on a few fronts:     - Firebase realtime database - you'll be interacting with this via the DOM if you're not using Roll20's API methods     - Async JS - you'll need to control the order of operations when writing to Firebase     - Fetch API or similar for grabbing data. Axios is an excellent Promise-based library for HTTP methods     - Roll20 character sheet funcionality, specifically repeating sections. You'll also need to figure out how to fire sheetworkers for calculated fields - this won't happen automatically since you're sidestepping R20's methods.     - Browser extensions and the various contexts available to them. They live in an odd combiniation of worlds You'll also need to hand-roll transforms for every sheet you want to support, unless this backend is specifically tooled on Roll20's character sheet implementation. Sounds fun! I'd also be a little wary of setting some bounds on your project - recreating any Pro-level functionality for free will displease the overlords.
1660285430
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Another thing to consider, is that this approach also leaves you vulnerable to changes in the Roll20 code. Creators of extensions like VTTES often have to deal with their project suddenly "breaking" due to factors outside of their control. Be prepared to never really be finished with the task.