aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2020-11-07 18:22:37 -0800
committerAllan Wang <me@allanwang.ca>2020-11-07 18:22:37 -0800
commita4fd999b34f970b0794565bbd4c5871485b01c7f (patch)
tree2ecd31116ac365be0f9850b362e8fb1acf1b50f5 /app
parenteefffafcf962c0126a0bb3ee5f166412c725072d (diff)
downloadfrost-a4fd999b34f970b0794565bbd4c5871485b01c7f.tar.gz
frost-a4fd999b34f970b0794565bbd4c5871485b01c7f.tar.bz2
frost-a4fd999b34f970b0794565bbd4c5871485b01c7f.zip
Fix theme injection
Diffstat (limited to 'app')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt57
1 files changed, 33 insertions, 24 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt
index dd1d45cb..62115a5a 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt
@@ -99,6 +99,36 @@ open class FrostWebViewClient(val web: FrostWebView) : BaseWebViewClient() {
protected inline fun v(crossinline message: () -> Any?) = L.v { "web client: ${message()}" }
+ /**
+ * Main injections for facebook content
+ */
+ private fun WebView.facebookJsInject() {
+ jsInject(
+// CssHider.CORE,
+ CssHider.HEADER,
+ CssHider.COMPOSER.maybe(!prefs.showComposer),
+ CssHider.STORIES.maybe(!prefs.showStories),
+ CssHider.PEOPLE_YOU_MAY_KNOW.maybe(!prefs.showSuggestedFriends),
+ CssHider.SUGGESTED_GROUPS.maybe(!prefs.showSuggestedGroups),
+ prefs.themeInjector,
+ CssHider.NON_RECENT.maybe(
+ (web.url?.contains("?sk=h_chr") ?: false) &&
+ prefs.aggressiveRecents
+ ),
+ CssHider.ADS.maybe(!prefs.showFacebookAds),
+ CssHider.POST_ACTIONS.maybe(!prefs.showPostActions),
+ CssHider.POST_REACTIONS.maybe(!prefs.showPostReactions),
+ CssSmallAssets.FullSizeImage.maybe(prefs.fullSizeImage),
+ JsAssets.DOCUMENT_WATCHER,
+ JsAssets.HORIZONTAL_SCROLLING,
+ JsAssets.AUTO_RESIZE_TEXTAREA.maybe(prefs.autoExpandTextBox),
+ JsAssets.CLICK_A,
+ JsAssets.CONTEXT_A,
+ JsAssets.MEDIA,
+ prefs = prefs
+ )
+ }
+
override fun onPageStarted(view: WebView, url: String?, favicon: Bitmap?) {
super.onPageStarted(view, url, favicon)
if (url == null) return
@@ -120,30 +150,8 @@ open class FrostWebViewClient(val web: FrostWebView) : BaseWebViewClient() {
super.onPageCommitVisible(view, url)
injectBackgroundColor()
if (url.isFacebookUrl) {
- view.jsInject(
-// CssHider.CORE,
- CssHider.HEADER,
- CssHider.COMPOSER.maybe(!prefs.showComposer),
- CssHider.STORIES.maybe(!prefs.showStories),
- CssHider.PEOPLE_YOU_MAY_KNOW.maybe(!prefs.showSuggestedFriends),
- CssHider.SUGGESTED_GROUPS.maybe(!prefs.showSuggestedGroups),
- prefs.themeInjector,
- CssHider.NON_RECENT.maybe(
- (web.url?.contains("?sk=h_chr") ?: false) &&
- prefs.aggressiveRecents
- ),
- CssHider.ADS.maybe(!prefs.showFacebookAds),
- CssHider.POST_ACTIONS.maybe(!prefs.showPostActions),
- CssHider.POST_REACTIONS.maybe(!prefs.showPostReactions),
- CssSmallAssets.FullSizeImage.maybe(prefs.fullSizeImage),
- JsAssets.DOCUMENT_WATCHER,
- JsAssets.HORIZONTAL_SCROLLING,
- JsAssets.AUTO_RESIZE_TEXTAREA,
- JsAssets.CLICK_A,
- JsAssets.CONTEXT_A,
- JsAssets.MEDIA,
- prefs = prefs
- )
+ v { "Page commit visible" }
+ view.facebookJsInject()
} else {
refresh.offer(false)
}
@@ -176,6 +184,7 @@ open class FrostWebViewClient(val web: FrostWebView) : BaseWebViewClient() {
JsAssets.HEADER_BADGES.maybe(isMain),
prefs = prefs
)
+ web.facebookJsInject()
}
open fun handleHtml(html: String?) {