mirror of
https://github.com/revanced/revanced-patches.git
synced 2025-12-07 01:51:27 +01:00
feat(YouTube Music): Add Check watch history domain name resolution (#5979)
This commit is contained in:
committed by
GitHub
parent
191b9169ff
commit
8af70fe2d1
@@ -1,4 +1,4 @@
|
||||
package app.revanced.extension.youtube.patches;
|
||||
package app.revanced.extension.shared.patches;
|
||||
|
||||
import static app.revanced.extension.shared.StringRef.str;
|
||||
|
||||
@@ -13,8 +13,8 @@ import java.net.UnknownHostException;
|
||||
|
||||
import app.revanced.extension.shared.Logger;
|
||||
import app.revanced.extension.shared.Utils;
|
||||
import app.revanced.extension.shared.settings.BaseSettings;
|
||||
import app.revanced.extension.shared.ui.CustomDialog;
|
||||
import app.revanced.extension.youtube.settings.Settings;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class CheckWatchHistoryDomainNameResolutionPatch {
|
||||
@@ -49,7 +49,7 @@ public class CheckWatchHistoryDomainNameResolutionPatch {
|
||||
* Checks if s.youtube.com is blacklisted and playback history will fail to work.
|
||||
*/
|
||||
public static void checkDnsResolver(Activity context) {
|
||||
if (!Utils.isNetworkConnected() || !Settings.CHECK_WATCH_HISTORY_DOMAIN_NAME.get()) return;
|
||||
if (!Utils.isNetworkConnected() || !BaseSettings.CHECK_WATCH_HISTORY_DOMAIN_NAME.get()) return;
|
||||
|
||||
Utils.runOnBackgroundThread(() -> {
|
||||
try {
|
||||
@@ -61,8 +61,8 @@ public class CheckWatchHistoryDomainNameResolutionPatch {
|
||||
// Prevent this false positive by verify youtube.com resolves.
|
||||
// If youtube.com does not resolve, then it's not a watch history domain resolving error
|
||||
// because the entire app will not work since no domains are resolving.
|
||||
if (domainResolvesToValidIP(HISTORY_TRACKING_ENDPOINT)
|
||||
|| !domainResolvesToValidIP("youtube.com")) {
|
||||
if (!domainResolvesToValidIP("youtube.com")
|
||||
|| domainResolvesToValidIP(HISTORY_TRACKING_ENDPOINT)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ public class CheckWatchHistoryDomainNameResolutionPatch {
|
||||
() -> {}, // OK button action (just dismiss).
|
||||
() -> {}, // Cancel button action (just dismiss).
|
||||
str("revanced_check_watch_history_domain_name_dialog_ignore"), // Neutral button text.
|
||||
() -> Settings.CHECK_WATCH_HISTORY_DOMAIN_NAME.save(false), // Neutral button action (Ignore).
|
||||
() -> BaseSettings.CHECK_WATCH_HISTORY_DOMAIN_NAME.save(false), // Neutral button action (Ignore).
|
||||
true // Dismiss dialog on Neutral button click.
|
||||
);
|
||||
|
||||
@@ -28,10 +28,16 @@ public class BaseSettings {
|
||||
public static final BooleanSetting SETTINGS_SEARCH_HISTORY = new BooleanSetting("revanced_settings_search_history", TRUE, true);
|
||||
public static final StringSetting SETTINGS_SEARCH_ENTRIES = new StringSetting("revanced_settings_search_entries", "");
|
||||
|
||||
//
|
||||
// Settings shared by YouTube and YouTube Music.
|
||||
//
|
||||
|
||||
public static final BooleanSetting SPOOF_VIDEO_STREAMS = new BooleanSetting("revanced_spoof_video_streams", TRUE, true, "revanced_spoof_video_streams_user_dialog_message");
|
||||
public static final EnumSetting<AppLanguage> SPOOF_VIDEO_STREAMS_LANGUAGE = new EnumSetting<>("revanced_spoof_video_streams_language", AppLanguage.DEFAULT, new AudioStreamLanguageOverrideAvailability());
|
||||
public static final BooleanSetting SPOOF_STREAMING_DATA_STATS_FOR_NERDS = new BooleanSetting("revanced_spoof_streaming_data_stats_for_nerds", TRUE, parent(SPOOF_VIDEO_STREAMS));
|
||||
|
||||
public static final BooleanSetting SANITIZE_SHARED_LINKS = new BooleanSetting("revanced_sanitize_sharing_links", TRUE);
|
||||
public static final BooleanSetting REPLACE_MUSIC_LINKS_WITH_YOUTUBE = new BooleanSetting("revanced_replace_music_with_youtube", FALSE);
|
||||
|
||||
public static final BooleanSetting CHECK_WATCH_HISTORY_DOMAIN_NAME = new BooleanSetting("revanced_check_watch_history_domain_name", TRUE, false, false);
|
||||
}
|
||||
|
||||
@@ -344,7 +344,6 @@ public class Settings extends BaseSettings {
|
||||
public static final BooleanSetting LOOP_VIDEO = new BooleanSetting("revanced_loop_video", FALSE);
|
||||
public static final BooleanSetting LOOP_VIDEO_BUTTON = new BooleanSetting("revanced_loop_video_button", FALSE);
|
||||
public static final BooleanSetting BYPASS_URL_REDIRECTS = new BooleanSetting("revanced_bypass_url_redirects", TRUE);
|
||||
public static final BooleanSetting CHECK_WATCH_HISTORY_DOMAIN_NAME = new BooleanSetting("revanced_check_watch_history_domain_name", TRUE, false, false);
|
||||
public static final BooleanSetting DISABLE_HAPTIC_FEEDBACK_CHAPTERS = new BooleanSetting("revanced_disable_haptic_feedback_chapters", FALSE);
|
||||
public static final BooleanSetting DISABLE_HAPTIC_FEEDBACK_PRECISE_SEEKING = new BooleanSetting("revanced_disable_haptic_feedback_precise_seeking", FALSE);
|
||||
public static final BooleanSetting DISABLE_HAPTIC_FEEDBACK_SEEK_UNDO = new BooleanSetting("revanced_disable_haptic_feedback_seek_undo", FALSE);
|
||||
|
||||
@@ -405,6 +405,10 @@ public final class app/revanced/patches/music/misc/debugging/EnableDebuggingPatc
|
||||
public static final fun getEnableDebuggingPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||
}
|
||||
|
||||
public final class app/revanced/patches/music/misc/dns/CheckWatchHistoryDomainNameResolutionPatchKt {
|
||||
public static final fun getCheckWatchHistoryDomainNameResolutionPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||
}
|
||||
|
||||
public final class app/revanced/patches/music/misc/extension/SharedExtensionPatchKt {
|
||||
public static final fun getSharedExtensionPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
)
|
||||
|
||||
@@ -30,6 +30,11 @@ Second \"item\" text"</string>
|
||||
<string name="revanced_check_environment_not_near_patch_time_days">Patched %s days ago</string>
|
||||
<string name="revanced_check_environment_not_near_patch_time_invalid">APK build date is corrupted</string>
|
||||
</patch>
|
||||
<patch id="misc.dns.checkWatchHistoryDomainNameResolutionPatch">
|
||||
<string name="revanced_check_watch_history_domain_name_dialog_title">Warning</string>
|
||||
<string name="revanced_check_watch_history_domain_name_dialog_message">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.</string>
|
||||
<string name="revanced_check_watch_history_domain_name_dialog_ignore">Do not show again</string>
|
||||
</patch>
|
||||
<patch id="misc.settings.settingsResourcePatch">
|
||||
<string name="revanced_settings_submenu_title">Settings</string>
|
||||
<string name="revanced_settings_title" translatable="false">ReVanced</string>
|
||||
@@ -1522,11 +1527,6 @@ Tap here to learn more about DeArrow"</string>
|
||||
<string name="revanced_announcements_connection_failed">Failed connecting to announcements provider</string>
|
||||
<string name="revanced_announcements_dialog_dismiss">Dismiss</string>
|
||||
</patch>
|
||||
<patch id="misc.dns.checkWatchHistoryDomainNameResolutionPatch">
|
||||
<string name="revanced_check_watch_history_domain_name_dialog_title">Warning</string>
|
||||
<string name="revanced_check_watch_history_domain_name_dialog_message">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.</string>
|
||||
<string name="revanced_check_watch_history_domain_name_dialog_ignore">Do not show again</string>
|
||||
</patch>
|
||||
<patch id="misc.loopvideo.loopVideoPatch">
|
||||
<string name="revanced_loop_video_title">Enable loop video</string>
|
||||
<string name="revanced_loop_video_summary_on">Video will loop</string>
|
||||
|
||||
Reference in New Issue
Block a user