Add scroll listener to CEF browser and scroll other JBCEF browser to the same percentage?

As I’ve mentioned a few times, I use Mermaid to show preview diagrams of XML-based files. Now I’ve implemented the diff.DiffTool plugin to show diagrams for these files at different versions side-by-side. I’m trying to implement scroll synchronization, but I’m not sure how to:

  1. Register a listener for scroll events in the embedded CEF browser.
  2. Assuming I’m able to do that, get the current percentage.
  3. Assuming I’m able to do that, force the other CEF browser to scroll to the same percentage (ignore smart/matched synchronization for this discussion).

Any insights on how this can be accomplished are greatly appreciated.

FYI, I was able to get this going via JavaScript integration using JBCefJSQuery and CefBrowser.executeScript(). The former is used to register a callback for an onscroll listener on the correct DOM element, and the latter is used to call scrollTo() on the corresponding element in the other CEF browser.