As threatened, I’ve cleaned up the code (removed all my FIXME, HACK, etc tags, and pp debugging output,) thrown together a quick README, and put it up on Gitlab.
The code is ugly, hacky, and worked for me. I make no claims that it will work for anyone else. You have been warned.