aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2020-11-07 19:34:47 -0800
committerGitHub <noreply@github.com>2020-11-07 19:34:47 -0800
commit8cac4ce54358f23a30a762bbb960309914507bb8 (patch)
tree2ecd31116ac365be0f9850b362e8fb1acf1b50f5 /app/src/main
parenteefffafcf962c0126a0bb3ee5f166412c725072d (diff)
parenta4fd999b34f970b0794565bbd4c5871485b01c7f (diff)
downloadfrost-8cac4ce54358f23a30a762bbb960309914507bb8.tar.gz
frost-8cac4ce54358f23a30a762bbb960309914507bb8.tar.bz2
frost-8cac4ce54358f23a30a762bbb960309914507bb8.zip
Merge pull request #1728 from AllanWang/theme-injection-2
Fix theme injection
Diffstat (limited to 'app/src/main')
-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?) {