Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions app/src/main/java/me/iacn/biliroaming/BiliBiliPackage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ class BiliBiliPackage constructor(private val mClassLoader: ClassLoader, mContex
val videoDownloadEntryClass by Weak { "com.bilibili.videodownloader.model.VideoDownloadEntry" from mClassLoader }
val rewardAdClass by Weak { mHookInfo.rewardAd.class_ from mClassLoader }
val tripleSpeedServiceClass by Weak { "com.bilibili.ship.theseus.united.player.TripleSpeedService\$runOldTripleSpeed\$1\$listener\$1\$onLongPress\$1" from mClassLoader }
val storyPagerPlayerClass by Weak { mHookInfo.storyPagerPlayer.class_ from mClassLoader }

// for v8.17.0+
val useNewMossFunc = instance.viewMossClass?.declaredMethods?.any {
Expand Down Expand Up @@ -370,6 +371,8 @@ class BiliBiliPackage constructor(private val mClassLoader: ClassLoader, mContex

fun rewardFlag() = mHookInfo.rewardAd.rewardFlag.orNull

fun addVideo() = mHookInfo.storyPagerPlayer.addVideo.orNull

private fun readHookInfo(context: Context): Configs.HookInfo {
try {
val hookInfoFile = File(context.cacheDir, Constant.HOOK_INFO_FILE_NAME)
Expand Down Expand Up @@ -2398,6 +2401,29 @@ class BiliBiliPackage constructor(private val mClassLoader: ClassLoader, mContex
rewardFlag = field { name = rewardFlagField.name }

}
storyPagerPlayer = storyPagerPlayer {
val storyPagerPlayerClass =
"com.bilibili.video.story.player.StoryPagerPlayer".from(classloader) ?: return@storyPagerPlayer

class_ = class_ { name = storyPagerPlayerClass.name }

val addVideoMethod = dexHelper.findMethodUsingString(
" add ",
false,
-1,
-1,
null,
dexHelper.encodeClassIndex(storyPagerPlayerClass),
null,
longArrayOf(dexHelper.encodeClassIndex(List::class.java)),
null,
true
).asSequence().mapNotNull {
dexHelper.decodeMethodIndex(it)
}.firstOrNull() ?: return@storyPagerPlayer

addVideo = method { name = addVideoMethod.name }
}

dexHelper.close()
}
Expand Down
11 changes: 2 additions & 9 deletions app/src/main/java/me/iacn/biliroaming/SettingDialog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ class SettingDialog(context: Context) : AlertDialog.Builder(context) {
packageName + "_preferences",
Context.MODE_MULTI_PROCESS
)
updatePurifyStoryVideoAdBlockedCount()
if (!prefs.getBoolean("hidden", false)) {
val hiddenGroup = findPreference("hidden_group") as PreferenceCategory
preferenceScreen.removePreference(hiddenGroup)
Expand Down Expand Up @@ -886,16 +885,16 @@ class SettingDialog(context: Context) : AlertDialog.Builder(context) {
val prefKey = "purify_story_video_ad_tags"
val oldPurifyAdTags = sPrefs.getStringSet(prefKey, emptySet()) ?: emptySet()


val keys = tagMap.keys.toList()
val values = tagMap.values.toTypedArray()

val checkedTags = BooleanArray(keys.size) { index ->
keys[index] in oldPurifyAdTags
}

val blockedCount = sPrefs.getInt("purify_story_video_ad_blocked_count", 0)

setTitle(context.getString(R.string.purify_story_video_ad_title))
setTitle(context.getString(R.string.purify_story_video_ad_title) + "(累计拦截 $blockedCount 条)")
setPositiveButton(context.getString(android.R.string.ok)) { _, _ ->
val selected = mutableSetOf<String>()
for (i in keys.indices) {
Expand All @@ -918,12 +917,6 @@ class SettingDialog(context: Context) : AlertDialog.Builder(context) {
return true
}

private fun updatePurifyStoryVideoAdBlockedCount() {
val blockedCount = sPrefs.getInt("purify_story_video_ad_blocked_count", 0)
findPreference("purify_story_video_ad")?.summary = getString(R.string.purify_story_video_ad_summary) +
"(累计拦截 $blockedCount 条)"
}

private fun onLongPressSpeedClick(): Boolean {
AlertDialog.Builder(activity).run {
val view = context.inflateLayout(R.layout.seekbar_dialog)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package me.iacn.biliroaming.hook

import me.iacn.biliroaming.BiliBiliPackage.Companion.instance
import me.iacn.biliroaming.utils.Log
import me.iacn.biliroaming.utils.from
import me.iacn.biliroaming.utils.hookBeforeMethod
Expand All @@ -12,10 +13,10 @@ class StoryPlayerAdHook(classLoader: ClassLoader) : BaseHook(classLoader) {
val purifyTags = sPrefs.getStringSet("purify_story_video_ad_tags", emptySet()) ?: emptySet()
if (purifyTags.isEmpty()) return

Log.d("startHook: StoryPlayerAd, purifyTags: ${purifyTags}")
Log.d("startHook: StoryPlayerAd, purifyTags: $purifyTags")

"com.bilibili.video.story.player.StoryPagerPlayer".from(mClassLoader)
?.hookBeforeMethod("n1", List::class.java) { params ->
instance.storyPagerPlayerClass?.hookBeforeMethod(
instance.addVideo(), List::class.java) { params ->
val storyDetailList = params.args[0] as? MutableList<*> ?: return@hookBeforeMethod
val toRemove = mutableListOf<Any>()

Expand Down
6 changes: 6 additions & 0 deletions app/src/main/proto/me/iacn/biliroaming/configs.proto
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,11 @@ message RewardAd {
optional Field rewardFlag = 2;
}

message StoryPagerPlayer {
optional Class class = 1;
optional Method addVideo = 2;
}

message HookInfo {
int64 last_update_time = 1;
optional MapIds map_ids = 2;
Expand Down Expand Up @@ -407,4 +412,5 @@ message HookInfo {
optional ResolveClientCompanion resolveClientCompanion = 102;
optional GCommonResolverParams gCommonResolverParams = 103;
optional RewardAd rewardAd = 104;
optional StoryPagerPlayer storyPagerPlayer = 105;
}