diff options
author | Allan Wang <me@allanwang.ca> | 2017-05-31 17:11:46 -0700 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2017-05-31 17:11:46 -0700 |
commit | 8618670b82641d5fbaec9c333f1290bab429ce27 (patch) | |
tree | 737c9a04f108ea68547eef2db1ae6e96caa64df6 /app/src/main/kotlin/com/pitchedapps/frost/injectors | |
parent | 9a41937a33539dbfaae4d072361caaec79865c29 (diff) | |
download | frost-8618670b82641d5fbaec9c333f1290bab429ce27.tar.gz frost-8618670b82641d5fbaec9c333f1290bab429ce27.tar.bz2 frost-8618670b82641d5fbaec9c333f1290bab429ce27.zip |
add more cookie handling
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/injectors')
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/injectors/JsBuilder.kt | 36 | ||||
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/injectors/JsInjector.kt | 24 |
2 files changed, 38 insertions, 22 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/injectors/JsBuilder.kt b/app/src/main/kotlin/com/pitchedapps/frost/injectors/JsBuilder.kt new file mode 100644 index 00000000..9844e5d5 --- /dev/null +++ b/app/src/main/kotlin/com/pitchedapps/frost/injectors/JsBuilder.kt @@ -0,0 +1,36 @@ +package com.pitchedapps.frost.injectors + +import android.webkit.WebView + +/** + * Created by Allan Wang on 2017-05-31. + */ +class JsBuilder { + private val builder = StringBuilder() + + init { + builder.append("javascript:(function(){") + } + + private fun getElementById(id: String) = "document.getElementById(\"$id\")" + + private fun hideElementById(id: String) { + builder.append(getElementById(id)).append(".style.display=\"none\";") + } + + fun hideElementById(vararg ids: String) { + ids.forEach { hideElementById(it) } + } + + fun build() = builder.toString() + "})()" + + fun inject(webView: WebView) { + webView.loadUrl(build()) + } + + fun removeAllStyles() { + + } + + override fun toString() = build() +}
\ No newline at end of file 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 e7a9df5a..2d1659cc 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/injectors/JsInjector.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/injectors/JsInjector.kt @@ -5,28 +5,8 @@ import android.webkit.WebView /** * Created by Allan Wang on 2017-05-31. */ -class JsInjector { - private val builder = StringBuilder() - - init { - builder.append("javascript:(function(){") - } - - private fun getElementById(id: String) = "document.getElementById(\"$id\")" - - private fun hideElementById(id: String) { - builder.append(getElementById(id)).append(".style.display=\"none\";") - } - - fun hideElementById(vararg ids: String) { - ids.forEach { hideElementById(it) } - } - - fun build() = builder.toString() + "})()" - +object JsInjector { fun inject(webView: WebView) { - webView.loadUrl(build()) - } - override fun toString() = build() + } }
\ No newline at end of file |