From 2af142525cda07a131335faadd4b3889979fd077 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Thu, 15 Aug 2024 12:06:19 -0400 Subject: [PATCH] feat(YouTube): Add `Check watch history domain name resolution` patch (#3537) Co-authored-by: oSumAtrIX --- .../instagram/patches/ad/HideAdsPatch.kt | 2 +- .../misc/SpoofAndroidDeviceIdPatch.kt | 2 +- .../BypassImageRegionRestrictions.kt | 2 +- ...ckWatchHistoryDomainNameResolutionPatch.kt | 37 +++++++++++++++++++ .../resources/addresources/values/strings.xml | 7 +++- 5 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 src/main/kotlin/app/revanced/patches/youtube/misc/dns/CheckWatchHistoryDomainNameResolutionPatch.kt diff --git a/src/main/kotlin/app/revanced/patches/instagram/patches/ad/HideAdsPatch.kt b/src/main/kotlin/app/revanced/patches/instagram/patches/ad/HideAdsPatch.kt index 15b0668ec..62200bd26 100644 --- a/src/main/kotlin/app/revanced/patches/instagram/patches/ad/HideAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/instagram/patches/ad/HideAdsPatch.kt @@ -10,7 +10,7 @@ import app.revanced.util.exception @Patch( name = "Hide ads", - description = "Hides ads in stories, discover, profile, etc." + + description = "Hides ads in stories, discover, profile, etc. " + "An ad can still appear once when refreshing the home feed.", compatiblePackages = [CompatiblePackage("com.instagram.android")], ) diff --git a/src/main/kotlin/app/revanced/patches/piccomafr/misc/SpoofAndroidDeviceIdPatch.kt b/src/main/kotlin/app/revanced/patches/piccomafr/misc/SpoofAndroidDeviceIdPatch.kt index a2a920526..4f2534aec 100644 --- a/src/main/kotlin/app/revanced/patches/piccomafr/misc/SpoofAndroidDeviceIdPatch.kt +++ b/src/main/kotlin/app/revanced/patches/piccomafr/misc/SpoofAndroidDeviceIdPatch.kt @@ -11,7 +11,7 @@ import app.revanced.util.exception @Patch( name = "Spoof Android device ID", - description = "Spoofs the Android device ID used by the app for account authentication." + + description = "Spoofs the Android device ID used by the app for account authentication. " + "This can be used to copy the account to another device.", compatiblePackages = [ CompatiblePackage( diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/thumbnails/BypassImageRegionRestrictions.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/thumbnails/BypassImageRegionRestrictions.kt index faf77ddab..d1d9dd39e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/thumbnails/BypassImageRegionRestrictions.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/thumbnails/BypassImageRegionRestrictions.kt @@ -12,7 +12,7 @@ import app.revanced.patches.youtube.misc.settings.SettingsPatch @Patch( name = "Bypass image region restrictions", - description = "Adds an option to use a different host for user avatar and channel images," + + description = "Adds an option to use a different host for user avatar and channel images " + "and can fix missing images that are blocked in some countries.", dependencies = [ IntegrationsPatch::class, diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/dns/CheckWatchHistoryDomainNameResolutionPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/dns/CheckWatchHistoryDomainNameResolutionPatch.kt new file mode 100644 index 000000000..0cccab86b --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/dns/CheckWatchHistoryDomainNameResolutionPatch.kt @@ -0,0 +1,37 @@ +package app.revanced.patches.youtube.misc.dns + +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.patch.BytecodePatch +import app.revanced.patcher.patch.annotation.Patch +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch +import app.revanced.patches.youtube.shared.fingerprints.MainActivityOnCreateFingerprint +import app.revanced.util.resultOrThrow + +@Patch( + name = "Check watch history domain name resolution", + description = "Checks if the device DNS server is preventing user watch history from being saved.", + dependencies = [IntegrationsPatch::class], +) +@Suppress("unused") +internal object CheckWatchHistoryDomainNameResolutionPatch : BytecodePatch( + setOf(MainActivityOnCreateFingerprint), +) { + private const val INTEGRATIONS_CLASS_DESCRIPTOR = + "Lapp/revanced/integrations/youtube/patches/CheckWatchHistoryDomainNameResolutionPatch;" + + override fun execute(context: BytecodeContext) { + AddResourcesPatch(this::class) + + MainActivityOnCreateFingerprint.resultOrThrow().mutableMethod.addInstructions( + // FIXME: Insert index must be greater than the insert index used by GmsCoreSupport, + // as both patch the same method and GmsCoreSupport check should be first, + // but the patch does not depend on GmsCoreSupport, so it should not be possible to enforce this + // unless a third patch is added that this patch and GmsCoreSupport depend on to manage + // the order of the patches. + 1, + "invoke-static/range { p0 .. p0 }, $INTEGRATIONS_CLASS_DESCRIPTOR->checkDnsResolver(Landroid/app/Activity;)V", + ) + } +} diff --git a/src/main/resources/addresources/values/strings.xml b/src/main/resources/addresources/values/strings.xml index b002d5e70..c4282babd 100644 --- a/src/main/resources/addresources/values/strings.xml +++ b/src/main/resources/addresources/values/strings.xml @@ -1045,6 +1045,11 @@ This is because Crowdin requires temporarily flattening this file and removing t Failed connecting to announcements provider Dismiss + + Warning + Your watch history is not being saved.<br><br>This most likely is caused by a DNS ad blocker or network proxy.<br><br>To fix this, whitelist <b>s.youtube.com</b> or turn off all DNS blockers and proxies. + Do not show again + Enable auto-repeat Auto-repeat is enabled @@ -1135,7 +1140,7 @@ This is because Crowdin requires temporarily flattening this file and removing t Client is not spoofed\n\nVideo playback may not work Turning off this setting may cause video playback issues. Spoof client to iOS - Client is currently spoofed to iOS\n\nSide effects include:\n• HDR video may not be available\n• Watch history may not work + Client is currently spoofed to iOS\n\nSide effects include:\n• HDR video may not be available\n• Watch history does not work with a brand account Client is currently spoofed to Android VR\n\nSide effects include:\n• No HDR video\n• Kids videos do not playback\n• Paused videos can randomly resume\n• Low quality Shorts seekbar thumbnails\n• Download action button is hidden\n• End screen cards are hidden Spoof client thumbnails not available (API timed out) Spoof client thumbnails temporarily not available: %s