Get interaction from webpage

One approach is to do that sort of thing in/via Scriptable, assuming you construct the page as you can set and evaluate content.

The editor here returns a whole chunk of edited content for example, but the principle is the same.