+1

Modify epubreader css

Glancelot 2 months ago updated by jamedeus 2 weeks ago 1

Hi,

Is there a way to edit the epubreader css ? I would like to change the default white color to something else.

Default is too bright and night mode is too black ^^

I try creating my own theme but can't find which css to edit.

I'm trying to do something similar. It seems like themes only apply to the library view and not the reader itself. The css for the reader is embedded in the Ubooquity.jar file, but it's split over several files and I can't seem to find one for text color.

If you just want to change the reader's background color you can do it fairly easily, but you'll have to extract the jar and re-jar it.

Here are instructions for linux (anything between `` is a command you can copy-paste):

- Make a backup of your Ubooquity.jar (just in case something goes wrong)

- Make an empty folder called temp and move your Ubooquity.jar to it

- Open terminal and cd into temp

- Run `unzip Ubooquity.jar` to extract it

- Delete Ubooquity.jar with `rm Ubooquity.jar`

This will create a bunch of files and folders - go to the "epubreader" folder and open "epubreader.css" in any text editor. All you need to do is add "background-color: <new-color>;" under "body {".

Now to re-jar go back to terminal:

- Make sure you're in temp, not temp/epubreader or any other subdirectory

- Run `jar cmvf META-INF/MANIFEST.MF Ubooquity.jar *`

- Make executable: `chmod 755 Ubooquity.jar`

Then move the new Ubooquity.jar to wherever you got it from and run it like normal.

Note that if you change the background to black (like I'm trying to do) this will make the page unreadable, since the text is black. I can't seem to find a css file that sets text color globally.

I was able to change most of the text to white by adding this to epubreader.css (global override, use at own risk!):

* {
color: white !important;
}

But some things are still black and have to be manually overridden.

When I inspect text in the epubreader using developer tools (Shift+F5 to open, Ctrl+Shift+C to select element) I see that different books are pulling from different stylesheets with generic-sounding names (template.css, stylesheet.css). I can't find these in Ubooquity's files and after some googling I suspect they may be embedded in the *.epub files themselves. This makes it difficult to override globally since they seem to use different classes. May do more research on that tomorrow.