Here's an introduction I made on how to program from/to WebInterface in Reaper.
It is an enhanced version of Reaper's own docs hidden in a js-file.
As you already wrote, write a script, that sets these values to an extstate, which can be retrieved.
You can run this script, by retrieving it's commandid and using the command-id and run it.
Just follow the examples, to get an understanding on how to do it, as the examples show you, how to get/set the extstates you wrote.
https://mespotin.uber.space/Ultrasch...mentation.html
If you're already familiar with that, read the following parts for:
ProjectExtStates:
https://mespotin.uber.space/Ultrasch...TE/section/key
or normal ExtStates:
https://mespotin.uber.space/Ultrasch...TE/section/key
and the one for getting the right command-id for your script:
https://mespotin.uber.space/Ultrasch...GET/command_id
and use them accordingly.