diff --git a/README.md b/README.md index 56b6bb5..fd5fc76 100644 --- a/README.md +++ b/README.md @@ -3,10 +3,18 @@ An xposed module for deleting Bilibili's video pop-ups for vote(投票) 、atten Test video link https://www.bilibili.com/video/BV1Wy4y1m7Xu +log: + +```json +{"vote":[{"time":"07:42 ~ 07:49","question":"谁来背这个锅?","option1":"使用AI的人","option2":"开发AI的人"}],"attention":{"time":"00:34 ~ 00:39"},"up":[{"content":"危","time":"00:53"},{"content":"嗨呀,去年做好的视频啦,没想到,已经411年了","time":"05:16"}]} ``` -attention:00:34 ~ 00:39 -up:00:53、05:16 -vote:07:42 ~ 07:49 + +Test video link https://www.bilibili.com/video/BV1N5411Q7UU + +log: + +```json +{"operation_card_new":[{"time":"15 ~ 30","title":"凡人修仙传"}]} ``` If you think this app is very helpful to you, please give me a free start, thanks diff --git a/app/src/main/java/github/zerorooot/fuckbilibilivote/CommandDmsUtil.kt b/app/src/main/java/github/zerorooot/fuckbilibilivote/CommandDmsUtil.kt index dffa0f9..8163c3b 100644 --- a/app/src/main/java/github/zerorooot/fuckbilibilivote/CommandDmsUtil.kt +++ b/app/src/main/java/github/zerorooot/fuckbilibilivote/CommandDmsUtil.kt @@ -7,7 +7,7 @@ class CommandDmsUtil(private val s: Any) { fun getCommand(): String { return try { - template("getCommand").replace("#", "") + template("getCommand").toString().replace("#", "") } catch (e: Exception) { "" } @@ -15,7 +15,7 @@ class CommandDmsUtil(private val s: Any) { fun getContent(): String { return try { - template("getContent") + template("getContent").toString() } catch (e: Exception) { "" } @@ -23,7 +23,7 @@ class CommandDmsUtil(private val s: Any) { fun getExtra(): JSONObject { return try { - JSONObject(template("getExtra")) + JSONObject(template("getExtra").toString()) } catch (e: Exception) { JSONObject() } @@ -31,13 +31,14 @@ class CommandDmsUtil(private val s: Any) { fun getProgress(): Int { return try { - template("getProgress").toInt() + template("getProgress").toString().toInt() } catch (e: Exception) { 0 } } - private fun template(name: String): String { - return XposedHelpers.callMethod(s, name) as String + + private fun template(name: String): Any { + return XposedHelpers.callMethod(s, name) } } \ No newline at end of file diff --git a/app/src/main/java/github/zerorooot/fuckbilibilivote/MyLog.kt b/app/src/main/java/github/zerorooot/fuckbilibilivote/MyLog.kt index 37dc58b..bb12f11 100644 --- a/app/src/main/java/github/zerorooot/fuckbilibilivote/MyLog.kt +++ b/app/src/main/java/github/zerorooot/fuckbilibilivote/MyLog.kt @@ -5,8 +5,24 @@ import org.json.JSONArray import org.json.JSONObject class MyLog() { + fun getOptionCardLog(obj: Any): JSONArray { + val operationCardList = XposedHelpers.callMethod(obj, "getOperationCardNewList") as List<*> + val print = JSONArray() + operationCardList.forEach { + val standardJson = JSONObject() + val title = + XposedHelpers.callMethod(XposedHelpers.callMethod(it, "getStandard"), "getTitle") + val from = XposedHelpers.callMethod(it, "getFrom") + val to = XposedHelpers.callMethod(it, "getTo") + standardJson.put("title", title) + standardJson.put("time", "$from ~ $to") + print.put(standardJson) + } + + return print + } - fun getLog(obj:Any): String { + fun getDmsLog(obj: Any): JSONObject { val commandDmsList = XposedHelpers.callMethod(obj, "getCommandDmsList") as List<*> @@ -46,7 +62,7 @@ class MyLog() { } - return print.toString() + return print } private fun getUpJsonArray(print: JSONObject, content: String, progress: Int): JSONArray { diff --git a/app/src/main/java/github/zerorooot/fuckbilibilivote/Xposed.kt b/app/src/main/java/github/zerorooot/fuckbilibilivote/Xposed.kt index 0c3b9b8..eea4430 100644 --- a/app/src/main/java/github/zerorooot/fuckbilibilivote/Xposed.kt +++ b/app/src/main/java/github/zerorooot/fuckbilibilivote/Xposed.kt @@ -5,6 +5,8 @@ import de.robv.android.xposed.XC_MethodHook import de.robv.android.xposed.XposedBridge import de.robv.android.xposed.XposedHelpers import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam +import org.json.JSONArray +import org.json.JSONObject class Xposed : IXposedHookLoadPackage { @@ -17,31 +19,33 @@ class Xposed : IXposedHookLoadPackage { return } - val viewProgressReplyClass = XposedHelpers.findClass( - "com.bapis.bilibili.app.view.v1.ViewProgressReply", - lpparam.classLoader - ) - val method = viewProgressReplyClass.getDeclaredMethod("getVideoGuide") - method.isAccessible = true - XposedBridge.hookMethod(method, object : XC_MethodHook() { - override fun afterHookedMethod(param: MethodHookParam) { - val result = param.result - if (result.toString().contains("command_dms")) { - param.result = null - try { - val log = myLog.getLog(result) - if (printInfo != log) { - XposedBridge.log(log) - printInfo = log - } - } catch (e: Exception) { - XposedBridge.log(e) + + XposedHelpers.findAndHookMethod("com.bapis.bilibili.app.view.v1.ViewProgressReply", + lpparam.classLoader, "getVideoGuide", object : XC_MethodHook() { + override fun afterHookedMethod(param: MethodHookParam) { + val result = param.result + + val print = JSONObject() + + if (result.toString().contains("operation_card_new")) { + print.put("operation_card_new", myLog.getOptionCardLog(result)) + + XposedHelpers.callMethod(result, "clearOperationCard") + XposedHelpers.callMethod(result, "clearOperationCardNew") } - } - } - }) + if (result.toString().contains("command_dms")) { + param.result = null + print.put("command_dms", myLog.getDmsLog(result)) + } + + if (printInfo != print.toString()) { + XposedBridge.log(print.toString()) + printInfo = print.toString() + } + } + }) } } diff --git a/app/src/test/java/github/zerorooot/fuckbilibilivote/ExampleUnitTest.kt b/app/src/test/java/github/zerorooot/fuckbilibilivote/ExampleUnitTest.kt index 1cbea60..1437331 100644 --- a/app/src/test/java/github/zerorooot/fuckbilibilivote/ExampleUnitTest.kt +++ b/app/src/test/java/github/zerorooot/fuckbilibilivote/ExampleUnitTest.kt @@ -1,5 +1,6 @@ package github.zerorooot.fuckbilibilivote // +import org.json.JSONArray import org.json.JSONObject import org.junit.Test import java.net.URLDecoder @@ -15,11 +16,17 @@ import java.util.regex.Pattern class ExampleUnitTest { @Test fun addition_isCorrect() { - val s = - "视频更新预告" + val a = JSONObject() + a.put("title", "凡人修仙传") + a.put("time", "15 ~ 30") + val jsonArray = JSONArray() + jsonArray.put(a) + + val jsonObject = JSONObject() + jsonObject.put("operation_card_new", jsonArray) // println(MyLog().protobufToString(s)) - println(protobufToString(s)) + println(jsonObject) } @Test