feat(YouTube Music): Add Check watch history domain name resolution (#5979)

This commit is contained in:
LisoUseInAIKyrios
2025-09-23 13:34:00 +04:00
committed by GitHub
parent 191b9169ff
commit 8af70fe2d1
11 changed files with 118 additions and 44 deletions
@@ -0,0 +1,22 @@
package app.revanced.patches.music.misc.dns
import app.revanced.patches.music.misc.extension.sharedExtensionPatch
import app.revanced.patches.music.shared.mainActivityOnCreateFingerprint
import app.revanced.patches.shared.misc.dns.checkWatchHistoryDomainNameResolutionPatch
val checkWatchHistoryDomainNameResolutionPatch = checkWatchHistoryDomainNameResolutionPatch(
block = {
dependsOn(
sharedExtensionPatch
)
compatibleWith(
"com.google.android.apps.youtube.music"(
"7.29.52",
"8.10.52"
)
)
},
mainActivityFingerprint = mainActivityOnCreateFingerprint
)
@@ -1,9 +1,10 @@
package app.revanced.patches.music.misc.extension
import app.revanced.patches.music.misc.extension.hooks.applicationInitHook
import app.revanced.patches.music.misc.extension.hooks.applicationInitOnCreateHook
import app.revanced.patches.shared.misc.extension.sharedExtensionPatch
val sharedExtensionPatch = sharedExtensionPatch(
"music",
applicationInitHook,
applicationInitHook, applicationInitOnCreateHook
)
@@ -1,5 +1,6 @@
package app.revanced.patches.music.misc.extension.hooks
import app.revanced.patches.music.shared.YOUTUBE_MUSIC_MAIN_ACTIVITY_CLASS_TYPE
import app.revanced.patches.shared.misc.extension.extensionHook
internal val applicationInitHook = extensionHook {
@@ -8,3 +9,11 @@ internal val applicationInitHook = extensionHook {
strings("activity")
custom { method, _ -> method.name == "onCreate" }
}
internal val applicationInitOnCreateHook = extensionHook {
returns("V")
parameters("Landroid/os/Bundle;")
custom { method, classDef ->
method.name == "onCreate" && classDef.type == YOUTUBE_MUSIC_MAIN_ACTIVITY_CLASS_TYPE
}
}
@@ -0,0 +1,13 @@
package app.revanced.patches.music.shared
import app.revanced.patcher.fingerprint
internal const val YOUTUBE_MUSIC_MAIN_ACTIVITY_CLASS_TYPE = "Lcom/google/android/apps/youtube/music/activities/MusicActivity;"
internal val mainActivityOnCreateFingerprint = fingerprint {
returns("V")
parameters("Landroid/os/Bundle;")
custom { method, classDef ->
method.name == "onCreate" && classDef.type == YOUTUBE_MUSIC_MAIN_ACTIVITY_CLASS_TYPE
}
}
@@ -0,0 +1,36 @@
package app.revanced.patches.shared.misc.dns
import app.revanced.patcher.Fingerprint
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.patch.BytecodePatchBuilder
import app.revanced.patcher.patch.BytecodePatchContext
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.all.misc.resources.addResources
private const val EXTENSION_CLASS_DESCRIPTOR =
"Lapp/revanced/extension/shared/patches/CheckWatchHistoryDomainNameResolutionPatch;"
/**
* Patch shared with YouTube and YT Music.
*/
internal fun checkWatchHistoryDomainNameResolutionPatch(
block: BytecodePatchBuilder.() -> Unit = {},
executeBlock: BytecodePatchContext.() -> Unit = {},
mainActivityFingerprint: Fingerprint
) = bytecodePatch(
name = "Check watch history domain name resolution",
description = "Checks if the device DNS server is preventing user watch history from being saved.",
) {
block()
execute {
executeBlock()
addResources("shared", "misc.dns.checkWatchHistoryDomainNameResolutionPatch")
mainActivityFingerprint.method.addInstruction(
0,
"invoke-static/range { p0 .. p0 }, $EXTENSION_CLASS_DESCRIPTOR->checkDnsResolver(Landroid/app/Activity;)V",
)
}
}
@@ -1,39 +1,23 @@
package app.revanced.patches.youtube.misc.dns
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.all.misc.resources.addResources
import app.revanced.patches.all.misc.resources.addResourcesPatch
import app.revanced.patches.shared.misc.dns.checkWatchHistoryDomainNameResolutionPatch
import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch
import app.revanced.patches.youtube.shared.mainActivityOnCreateFingerprint
private const val EXTENSION_CLASS_DESCRIPTOR =
"Lapp/revanced/extension/youtube/patches/CheckWatchHistoryDomainNameResolutionPatch;"
val checkWatchHistoryDomainNameResolutionPatch = bytecodePatch(
name = "Check watch history domain name resolution",
description = "Checks if the device DNS server is preventing user watch history from being saved.",
) {
dependsOn(
sharedExtensionPatch,
addResourcesPatch
)
compatibleWith(
"com.google.android.youtube"(
"19.34.42",
"20.07.39",
"20.13.41",
"20.14.43",
val checkWatchHistoryDomainNameResolutionPatch = checkWatchHistoryDomainNameResolutionPatch(
block = {
dependsOn(
sharedExtensionPatch
)
)
execute {
addResources("youtube", "misc.dns.checkWatchHistoryDomainNameResolutionPatch")
mainActivityOnCreateFingerprint.method.addInstruction(
0,
"invoke-static/range { p0 .. p0 }, $EXTENSION_CLASS_DESCRIPTOR->checkDnsResolver(Landroid/app/Activity;)V",
compatibleWith(
"com.google.android.youtube"(
"19.34.42",
"20.07.39",
"20.13.41",
"20.14.43",
)
)
}
}
},
mainActivityFingerprint = mainActivityOnCreateFingerprint
)