Skip to content
This repository has been archived by the owner on Oct 28, 2023. It is now read-only.

Commit

Permalink
支持屏蔽‘追番’
Browse files Browse the repository at this point in the history
  • Loading branch information
zerorooot committed Jul 22, 2022
1 parent ef8214e commit 410b3d7
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 36 deletions.
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,38 @@ class CommandDmsUtil(private val s: Any) {

fun getCommand(): String {
return try {
template("getCommand").replace("#", "")
template("getCommand").toString().replace("#", "")
} catch (e: Exception) {
""
}
}

fun getContent(): String {
return try {
template("getContent")
template("getContent").toString()
} catch (e: Exception) {
""
}
}

fun getExtra(): JSONObject {
return try {
JSONObject(template("getExtra"))
JSONObject(template("getExtra").toString())
} catch (e: Exception) {
JSONObject()
}
}

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)
}
}
20 changes: 18 additions & 2 deletions app/src/main/java/github/zerorooot/fuckbilibilivote/MyLog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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<*>

Expand Down Expand Up @@ -46,7 +62,7 @@ class MyLog() {
}


return print.toString()
return print
}

private fun getUpJsonArray(print: JSONObject, content: String, progress: Int): JSONArray {
Expand Down
48 changes: 26 additions & 22 deletions app/src/main/java/github/zerorooot/fuckbilibilivote/Xposed.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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()
}

}
})
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package github.zerorooot.fuckbilibilivote
//
import org.json.JSONArray
import org.json.JSONObject
import org.junit.Test
import java.net.URLDecoder
Expand All @@ -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
Expand Down

0 comments on commit 410b3d7

Please sign in to comment.