Skip to content

Injecting custom CSS files in each WebView #260

Answered by mickael-menu
838 asked this question in Q&A
Discussion options

You must be logged in to vote

We plan to work soonish on an Injectable API to inject custom JavaScript and CSS but there's nothing available yet.

However, you can implement a custom transformer for the HTML resources to use with the TransformingFetcher and inject the CSS yourself.

You can wrap the publication fetcher from the Streamer.open(onCreatePublication:) closure:

suspend fun injectCss(resource: Resource): Resource {
    ...
}

streamer.open(
    ...,
    onCreatePublication = {
        fetcher = TransformingFetcher(fetcher, injectCss)
    }
)

Take a look at the HtmlInjector for an example:

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@838
Comment options

Answer selected by 838
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants