Fix JsExtensions' timeFormat function

master^2
fengyuecanzhu 2 years ago
parent c805ef309c
commit 2c9a5f1bb3
No known key found for this signature in database
GPG Key ID: 04B78AD06A9D6E6C
  1. 7
      app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/JsExtensions.kt
  2. 1
      dynamic/src/main/java/xyz/fycz/dynamic/AppLoadImpl.kt
  3. 54
      dynamic/src/main/java/xyz/fycz/dynamic/fix/App250Fix.kt

@ -25,7 +25,6 @@ import androidx.annotation.Keep
import kotlinx.coroutines.Dispatchers.IO import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.async import kotlinx.coroutines.async
import kotlinx.coroutines.runBlocking import kotlinx.coroutines.runBlocking
import nl.siegmann.epublib.epub.PackageDocumentBase.dateFormat
import org.jsoup.Connection import org.jsoup.Connection
import org.jsoup.Jsoup import org.jsoup.Jsoup
import xyz.fycz.myreader.application.App import xyz.fycz.myreader.application.App
@ -141,7 +140,9 @@ interface JsExtensions {
BackstageWebView( BackstageWebView(
url = url, url = url,
html = html, html = html,
javaScript = js javaScript = js,
headerMap = getSource()?.getHeaderMap(true),
tag = getSource()?.getKey()
).getStrResponse().body ).getStrResponse().body
} }
} }
@ -264,7 +265,7 @@ interface JsExtensions {
* 时间格式化 * 时间格式化
*/ */
fun timeFormat(time: Long): String { fun timeFormat(time: Long): String {
return dateFormat.format(Date(time)) return SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()).format(Date(time))
} }
/** /**

@ -57,6 +57,7 @@ class AppLoadImpl : IAppLoader {
App246Fix3::class.java, App246Fix3::class.java,
App246Fix4::class.java, App246Fix4::class.java,
App246Fix5::class.java, App246Fix5::class.java,
App250Fix::class.java,
) )
override fun onLoad(appParam: AppParam) { override fun onLoad(appParam: AppParam) {

@ -0,0 +1,54 @@
/*
* This file is part of FYReader.
* FYReader is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* FYReader is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with FYReader. If not, see <https://www.gnu.org/licenses/>.
*
* Copyright (C) 2020 - 2022 fengyuecanzhu
*/
package xyz.fycz.dynamic.fix
import me.fycz.maple.MapleBridge
import me.fycz.maple.MapleUtils
import me.fycz.maple.MethodReplacement
import xyz.fycz.myreader.model.third3.analyzeRule.JsExtensions
import java.text.SimpleDateFormat
import java.util.*
/**
* @author fengyue
* @date 2022/8/3 12:57
*/
@AppFix([243, 244, 245, 246, 250], ["修复书源时间格式化bug"], "2022-08-03")
class App250Fix : AppFixHandle {
override fun onFix(key: String): BooleanArray {
return handleFix(
key,
"timeFormat" to { fixTimeFormat() },
)
}
fun fixTimeFormat() {
MapleUtils.findAndHookMethod(
JsExtensions::class.java,
"timeFormat",
Long::class.java,
object : MethodReplacement() {
override fun replaceHookedMethod(param: MapleBridge.MethodHookParam): Any {
val time = param.args[0] as Long
return SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()).format(Date(time))
}
}
)
}
}
Loading…
Cancel
Save