aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/kotlin')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/injectors/JsInjector.kt13
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt21
2 files changed, 24 insertions, 10 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/injectors/JsInjector.kt b/app/src/main/kotlin/com/pitchedapps/frost/injectors/JsInjector.kt
index 00c7bcfc..13032479 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/injectors/JsInjector.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/injectors/JsInjector.kt
@@ -52,14 +52,19 @@ class JsBuilder {
val cssMin = css.replace(Regex("\\s*\n\\s*"), "")
append("var a=document.createElement('style');")
append("a.innerHTML='$cssMin';")
- if (tag != null) append("a.id='$tag';")
+ if (tag != null) {
+ append("a.id='$tag';")
+ }
append("document.head.appendChild(a);")
}
- if (js.isNotBlank())
+ if (js.isNotBlank()) {
append(js)
+ }
}
var content = builder.append("}()").toString()
- if (tag != null) content = singleInjector(tag, content)
+ if (tag != null) {
+ content = singleInjector(tag, content)
+ }
return content
}
@@ -101,4 +106,4 @@ fun FrostWebViewClient.jsInject(vararg injectors: InjectorContract) = web.jsInje
class JsInjector(val function: String) : InjectorContract {
override fun inject(webView: WebView) =
webView.evaluateJavascript(function, null)
-}
+} \ No newline at end of file
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 ecedc997..025119aa 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt
@@ -91,7 +91,7 @@ open class FrostWebViewClient(val web: FrostWebView) : BaseWebViewClient() {
override fun onPageCommitVisible(view: WebView, url: String?) {
super.onPageCommitVisible(view, url)
injectBackgroundColor()
- if (url.isFacebookUrl)
+ if (url.isFacebookUrl) {
view.jsInject(
// CssHider.CORE,
CssHider.HEADER,
@@ -111,8 +111,9 @@ open class FrostWebViewClient(val web: FrostWebView) : BaseWebViewClient() {
JsAssets.CONTEXT_A,
JsAssets.MEDIA
)
- else
+ } else {
refresh.offer(false)
+ }
}
override fun onPageFinished(view: WebView, url: String?) {
@@ -212,19 +213,27 @@ class FrostWebViewClientMenu(web: FrostWebView) : FrostWebViewClient(web) {
override fun onPageFinished(view: WebView, url: String?) {
super.onPageFinished(view, url)
- if (url == null) return
- if (url.shouldInjectMenu) jsInject(JsAssets.MENU)
+ if (url == null) {
+ return
+ }
+ if (url.shouldInjectMenu) {
+ jsInject(JsAssets.MENU)
+ }
}
override fun emit(flag: Int) {
super.emit(flag)
when (flag) {
- EMIT_FINISH -> super.injectAndFinish()
+ EMIT_FINISH -> {
+ super.injectAndFinish()
+ }
}
}
override fun onPageFinishedActions(url: String) {
v { "Should inject ${url.shouldInjectMenu}" }
- if (!url.shouldInjectMenu) injectAndFinish()
+ if (!url.shouldInjectMenu) {
+ injectAndFinish()
+ }
}
}