diff options
author | Allan Wang <me@allanwang.ca> | 2021-11-21 23:21:14 -0800 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2021-11-21 23:21:14 -0800 |
commit | c28973319df956c6ce75998b4d213c2da31bf91b (patch) | |
tree | 61ace21dbed8d5d3d91a319b3fbf918b93379c0f /app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt | |
parent | dd37321626e6e5d604f12d7ffb00eeb789df0d5f (diff) | |
download | frost-c28973319df956c6ce75998b4d213c2da31bf91b.tar.gz frost-c28973319df956c6ce75998b4d213c2da31bf91b.tar.bz2 frost-c28973319df956c6ce75998b4d213c2da31bf91b.zip |
Simplify menu tab loading process
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt')
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt | 59 |
1 files changed, 34 insertions, 25 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 a6603f01..3e906a23 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt @@ -37,6 +37,7 @@ import com.pitchedapps.frost.facebook.WWW_FACEBOOK_COM import com.pitchedapps.frost.facebook.formattedFbUrl import com.pitchedapps.frost.injectors.CssAsset import com.pitchedapps.frost.injectors.CssHider +import com.pitchedapps.frost.injectors.InjectorContract import com.pitchedapps.frost.injectors.JsActions import com.pitchedapps.frost.injectors.JsAssets import com.pitchedapps.frost.injectors.ThemeProvider @@ -115,32 +116,33 @@ open class FrostWebViewClient(val web: FrostWebView) : BaseWebViewClient() { /** * Main injections for facebook content */ + protected open val facebookJsInjectors: List<InjectorContract> = listOf( + // 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), + themeProvider.injector(ThemeCategory.FACEBOOK), + 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), + CssAsset.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, + JsAssets.SCROLL_STOP, + ) + 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), - themeProvider.injector(ThemeCategory.FACEBOOK), - 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), - CssAsset.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, - JsAssets.SCROLL_STOP, - prefs = prefs - ) + jsInject(*facebookJsInjectors.toTypedArray(), prefs = prefs) } private fun WebView.messengerJsInject() { @@ -295,6 +297,13 @@ class FrostWebViewClientMenu(web: FrostWebView) : FrostWebViewClient(web) { jsInject(JsAssets.MENU, prefs = prefs) } + /* + * We do not inject headers as they include the menu flyout. + * Instead, we remove the flyout margins within the js script so that it covers the header. + */ + override val facebookJsInjectors: List<InjectorContract> = + super.facebookJsInjectors - CssHider.HEADER + override fun emit(flag: Int) { super.emit(flag) when (flag) { |