Most of what you want exists, or at least code you can use as examples.
The Modify ePub plugin does lots of modifications to the book code. You should find examples of what you want in it.
And as you have a Kobo device, the drivers almost support what you want. You can subclass the built-in KoboTouch driver and add the function you need. This already has a method to make some changes to the CSS. But, the KoboTouchExtended driver is probably more what you want. It does the sort of thing you want. It modifies the book code as the book is sent to the device.
|