WIth the help of AI, re-wrote the plugin and it now works when opening a book. I created 2 pull requests with the changes. I hate git, but the code is there, at least.