rss webView添加注入js

pull/2565/head
kunfei 2 years ago
parent 420e50ec87
commit 49fb1a3938
  1. 3
      app/src/main/java/io/legado/app/data/entities/RssSource.kt
  2. 1
      app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt
  3. 3
      app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditAdapter.kt
  4. 3
      app/src/main/java/io/legado/app/ui/book/source/edit/EditEntity.kt
  5. 3
      app/src/main/java/io/legado/app/ui/rss/source/edit/EditEntity.kt
  6. 3
      app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt
  7. 3
      app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditAdapter.kt
  8. 9
      app/src/main/java/io/legado/app/ui/widget/text/EditEntity.kt
  9. 1
      app/src/main/res/values-es-rES/strings.xml
  10. 1
      app/src/main/res/values-ja-rJP/strings.xml
  11. 1
      app/src/main/res/values-pt-rBR/strings.xml
  12. 1
      app/src/main/res/values-zh-rHK/strings.xml
  13. 1
      app/src/main/res/values-zh-rTW/strings.xml
  14. 1
      app/src/main/res/values-zh/strings.xml
  15. 1
      app/src/main/res/values/strings.xml

@ -111,6 +111,8 @@ data class RssSource(
&& enableJs == source.enableJs
&& loadWithBaseUrl == source.loadWithBaseUrl
&& equal(variableComment, source.variableComment)
&& equal(style, source.style)
&& equal(injectJs, source.injectJs)
}
private fun equal(a: String?, b: String?): Boolean {
@ -180,6 +182,7 @@ data class RssSource(
ruleLink = doc.readString("$.ruleLink"),
ruleContent = doc.readString("$.ruleContent"),
style = doc.readString("$.style"),
injectJs = doc.readString("$.injectJs"),
enableJs = doc.readBool("$.enableJs") ?: true,
loadWithBaseUrl = doc.readBool("$.loadWithBaseUrl") ?: true,
enabledCookieJar = doc.readBool("$.enabledCookieJar") ?: false,

@ -31,6 +31,7 @@ import io.legado.app.ui.qrcode.QrCodeResult
import io.legado.app.ui.widget.dialog.TextDialog
import io.legado.app.ui.widget.dialog.UrlOptionDialog
import io.legado.app.ui.widget.keyboard.KeyboardToolPop
import io.legado.app.ui.widget.text.EditEntity
import io.legado.app.utils.*
import io.legado.app.utils.viewbindingdelegate.viewBinding
import kotlinx.coroutines.Dispatchers.IO

@ -13,6 +13,7 @@ import io.legado.app.help.config.AppConfig
import io.legado.app.ui.widget.code.addJsPattern
import io.legado.app.ui.widget.code.addJsonPattern
import io.legado.app.ui.widget.code.addLegadoPattern
import io.legado.app.ui.widget.text.EditEntity
class BookSourceEditAdapter : RecyclerView.Adapter<BookSourceEditAdapter.MyViewHolder>() {
@ -70,7 +71,7 @@ class BookSourceEditAdapter : RecyclerView.Adapter<BookSourceEditAdapter.MyViewH
}
}
editText.setText(editEntity.value)
textInputLayout.hint = itemView.context.getString(editEntity.hint)
textInputLayout.hint = editEntity.hint
val textWatcher = object : TextWatcher {
override fun beforeTextChanged(
s: CharSequence,

@ -1,3 +0,0 @@
package io.legado.app.ui.book.source.edit
data class EditEntity(var key: String, var value: String?, var hint: Int)

@ -1,3 +0,0 @@
package io.legado.app.ui.rss.source.edit
data class EditEntity(var key: String, var value: String?, var hint: Int)

@ -22,6 +22,7 @@ import io.legado.app.ui.rss.source.debug.RssSourceDebugActivity
import io.legado.app.ui.widget.dialog.TextDialog
import io.legado.app.ui.widget.dialog.UrlOptionDialog
import io.legado.app.ui.widget.keyboard.KeyboardToolPop
import io.legado.app.ui.widget.text.EditEntity
import io.legado.app.utils.*
import io.legado.app.utils.viewbindingdelegate.viewBinding
@ -183,6 +184,7 @@ class RssSourceEditActivity :
add(EditEntity("ruleLink", source?.ruleLink, R.string.r_link))
add(EditEntity("ruleContent", source?.ruleContent, R.string.r_content))
add(EditEntity("style", source?.style, R.string.r_style))
add(EditEntity("injectJs", source?.injectJs, R.string.r_inject_js))
}
adapter.editEntities = sourceEntities
}
@ -225,6 +227,7 @@ class RssSourceEditActivity :
"ruleContent" -> source.ruleContent =
viewModel.ruleComplete(it.value, source.ruleArticles)
"style" -> source.style = it.value
"injectJs" -> source.injectJs = it.value
}
}
return source

@ -13,6 +13,7 @@ import io.legado.app.help.config.AppConfig
import io.legado.app.ui.widget.code.addJsPattern
import io.legado.app.ui.widget.code.addJsonPattern
import io.legado.app.ui.widget.code.addLegadoPattern
import io.legado.app.ui.widget.text.EditEntity
class RssSourceEditAdapter : RecyclerView.Adapter<RssSourceEditAdapter.MyViewHolder>() {
@ -69,7 +70,7 @@ class RssSourceEditAdapter : RecyclerView.Adapter<RssSourceEditAdapter.MyViewHol
}
}
editText.setText(editEntity.value)
textInputLayout.hint = itemView.context.getString(editEntity.hint)
textInputLayout.hint = editEntity.hint
val textWatcher = object : TextWatcher {
override fun beforeTextChanged(
s: CharSequence,

@ -0,0 +1,9 @@
package io.legado.app.ui.widget.text
import splitties.init.appCtx
data class EditEntity(var key: String, var value: String?, var hint: String) {
constructor(key: String, value: String?, hint: Int) : this(key, value, appCtx.getString(hint))
}

@ -438,6 +438,7 @@
<string name="r_image">图片url规则(ruleImage)</string>
<string name="r_content">内容规则(ruleContent)</string>
<string name="r_style">样式(style)</string>
<string name="r_inject_js">注入Js(injectJs)</string>
<string name="r_link">链接规则(ruleLink)</string>
<string name="check_key_word">校验关键字(checkKeyWord)</string>
<string name="rule_actions">操作(actions)</string>

@ -442,6 +442,7 @@
<string name="r_image">图片url规则(ruleImage)</string>
<string name="r_content">内容规则(ruleContent)</string>
<string name="r_style">样式(style)</string>
<string name="r_inject_js">注入Js(injectJs)</string>
<string name="r_link">链接规则(ruleLink)</string>
<string name="check_key_word">校验关键字(checkKeyWord)</string>
<string name="rule_actions">操作(actions)</string>

@ -440,6 +440,7 @@
<string name="r_image">图片url规则(regraImagem)</string>
<string name="r_content">内容规则(regraConteúdo)</string>
<string name="r_style">样式(formato)</string>
<string name="r_inject_js">注入Js(injectJs)</string>
<string name="r_link">链接规则(regraLink)</string>
<string name="check_key_word">校验关键字(checkKeyWord)</string>
<string name="rule_actions">操作(actions)</string>

@ -434,6 +434,7 @@
<string name="r_image">圖片 url 規則 (ruleImage)</string>
<string name="r_content">內容規則 (ruleContent)</string>
<string name="r_style">樣式 (style)</string>
<string name="r_inject_js">注入Js(injectJs)</string>
<string name="r_link">鏈接規則 (ruleLink)</string>
<string name="check_key_word">校驗關鍵字(checkKeyWord)</string>
<string name="rule_actions">操作(actions)</string>

@ -441,6 +441,7 @@
<string name="r_image">圖片url規則(ruleImage)</string>
<string name="r_content">內容規則(ruleContent)</string>
<string name="r_style">樣式(style)</string>
<string name="r_inject_js">注入Js(injectJs)</string>
<string name="r_link">連結規則(ruleLink)</string>
<string name="check_key_word">校驗關鍵字(checkKeyWord)</string>
<string name="rule_actions">操作(actions)</string>

@ -441,6 +441,7 @@
<string name="r_image">图片 URL 规则(ruleImage)</string>
<string name="r_content">内容规则(ruleContent)</string>
<string name="r_style">样式(style)</string>
<string name="r_inject_js">注入Js(injectJs)</string>
<string name="r_link">链接规则(ruleLink)</string>
<string name="check_key_word">校验关键字(checkKeyWord)</string>
<string name="rule_actions">操作(actions)</string>

@ -443,6 +443,7 @@
<string name="r_content">内容规则(ruleContent)</string>
<string name="r_style">样式(style)</string>
<string name="r_link">链接规则(ruleLink)</string>
<string name="r_inject_js">注入Js(injectJs)</string>
<string name="check_key_word">校验关键字(checkKeyWord)</string>
<string name="rule_actions">操作(actions)</string>
<string name="rule_is_pay">购买标识(isPay)</string>

Loading…
Cancel
Save