Trying to write a tool, unsure if sync-friendly save is possible

A long time ago someone wrote an “English to fictional language” translator webpage. I rewrote the page code nearly from scratch to allow me to tweak the alphabet transpositions as well as the plaintext, but also to remember changes to the alphabet table and sample text (using document.localStorage).
The good news is, it works when dropped into my Research folder and used within Scrivener. The bad news is, because it saves those changes to document.localStorage (i.e. the platform’s cache outside Scrivener), the storage changes don’t sync between the desktop and iPad versions. The worse news is that iOS doesn’t guarantee localStorage persistence so this isn’t a stable solution longterm.
If I were attempting to code a (crossplat) tool able to save its own data in a form Scrivener is aware of and will sync between devices, what Scrivener APIs or solutions should I be looking at? I can probably create a button that copies the table and the text to a JSON array but have no clue whether there’s macro functionality in Scrivener that would write it to a document or not (and backwards).
Thanks in advance.

I’d look at Scrivener’s Sync with External Folder functionality. Scrivener saves a designated list of files out to an external location, you manipulate them as needed, and Scrivener incorporates them back into the project. The external folder can be in a “cloud” location, and neither you nor the cloud need to mess with the internal structure of the project.

Katherine

I kind of get what you’re suggesting here, but I’m trying to create a tool that works inside Scrivener and saves its contents inside the project. The upside of using HTML/JS is it’s easy to code and supported by the built-in WebKit renderer; the downside is that by design client-side JS has no API for creating/manipulating the local filesystem.

Scrivener has not published an API.

The user’s content is written to RTF and plain text (synopsis items) files. The indexes used to build the Binder and perform other functions are XML. We have published a detailed format specification: send an email to our technical support address to request it.

If you’re not able to manipulate the file system, you’re going to have a rough time because Scrivener is very much a file-based application.

Katherine