mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-13 05:37:40 +02:00
feat(YouTube): add Remove viewer discretion dialog
patch
This commit is contained in:
@ -0,0 +1,22 @@
|
|||||||
|
package app.revanced.patches.shared.fingerprints.dialog
|
||||||
|
|
||||||
|
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||||
|
import com.android.tools.smali.dexlib2.AccessFlags
|
||||||
|
import com.android.tools.smali.dexlib2.Opcode
|
||||||
|
|
||||||
|
internal object CreateDialogFingerprint : MethodFingerprint(
|
||||||
|
returnType = "V",
|
||||||
|
accessFlags = AccessFlags.PROTECTED.value,
|
||||||
|
parameters = listOf("L", "L", "Ljava/lang/String;"),
|
||||||
|
opcodes = listOf(
|
||||||
|
Opcode.INVOKE_VIRTUAL,
|
||||||
|
Opcode.MOVE_RESULT_OBJECT,
|
||||||
|
Opcode.INVOKE_VIRTUAL,
|
||||||
|
Opcode.MOVE_RESULT_OBJECT,
|
||||||
|
Opcode.INVOKE_VIRTUAL,
|
||||||
|
Opcode.MOVE_RESULT_OBJECT,
|
||||||
|
Opcode.IPUT_OBJECT,
|
||||||
|
Opcode.IGET_OBJECT,
|
||||||
|
Opcode.INVOKE_VIRTUAL // dialog.show()
|
||||||
|
)
|
||||||
|
)
|
@ -0,0 +1,53 @@
|
|||||||
|
package app.revanced.patches.shared.patch.dialog
|
||||||
|
|
||||||
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
|
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||||
|
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||||
|
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||||
|
import app.revanced.patcher.patch.BytecodePatch
|
||||||
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||||
|
import app.revanced.patches.shared.fingerprints.dialog.CreateDialogFingerprint
|
||||||
|
import app.revanced.util.exception
|
||||||
|
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
||||||
|
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
|
||||||
|
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
||||||
|
|
||||||
|
abstract class AbstractRemoveViewerDiscretionDialogPatch(
|
||||||
|
private val classDescriptor: String,
|
||||||
|
private val additionalFingerprints: Set<MethodFingerprint> = emptySet()
|
||||||
|
) : BytecodePatch(
|
||||||
|
buildSet {
|
||||||
|
add(CreateDialogFingerprint)
|
||||||
|
additionalFingerprints.let(::addAll)
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
private fun MutableMethod.invoke() {
|
||||||
|
val showDialogIndex = implementation!!.instructions.indexOfFirst { instruction ->
|
||||||
|
((instruction as? ReferenceInstruction)?.reference as? MethodReference)?.name == "show"
|
||||||
|
}
|
||||||
|
val dialogRegister = getInstruction<FiveRegisterInstruction>(showDialogIndex).registerC
|
||||||
|
|
||||||
|
addInstruction(
|
||||||
|
showDialogIndex + 1,
|
||||||
|
"invoke-static { v$dialogRegister }, $classDescriptor->confirmDialog(Landroid/app/AlertDialog;)V",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun execute(context: BytecodeContext) {
|
||||||
|
CreateDialogFingerprint.result?.mutableMethod?.invoke()
|
||||||
|
?: throw CreateDialogFingerprint.exception
|
||||||
|
|
||||||
|
if (additionalFingerprints.isNotEmpty()) {
|
||||||
|
additionalFingerprints.forEach { fingerprint ->
|
||||||
|
fingerprint.result?.let {
|
||||||
|
val targetMethod = context.toMethodWalker(it.method)
|
||||||
|
.nextMethod(it.scanResult.patternScanResult!!.endIndex - 1, true)
|
||||||
|
.getMethod() as MutableMethod
|
||||||
|
|
||||||
|
targetMethod.invoke()
|
||||||
|
} ?: throw fingerprint.exception
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,64 @@
|
|||||||
|
package app.revanced.patches.youtube.general.dialog
|
||||||
|
|
||||||
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
|
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
||||||
|
import app.revanced.patcher.patch.annotation.Patch
|
||||||
|
import app.revanced.patches.shared.patch.dialog.AbstractRemoveViewerDiscretionDialogPatch
|
||||||
|
import app.revanced.patches.youtube.general.dialog.fingerprints.AgeRestrictionFingerprint
|
||||||
|
import app.revanced.patches.youtube.utils.integrations.Constants.GENERAL
|
||||||
|
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||||
|
|
||||||
|
@Patch(
|
||||||
|
name = "Remove viewer discretion dialog",
|
||||||
|
description = "Removes the dialog that appears when you try to watch a video that has been age-restricted " +
|
||||||
|
"by accepting it automatically. This does not bypass the age restriction.",
|
||||||
|
dependencies = [SettingsPatch::class],
|
||||||
|
compatiblePackages = [
|
||||||
|
CompatiblePackage(
|
||||||
|
"com.google.android.youtube",
|
||||||
|
[
|
||||||
|
"18.25.40",
|
||||||
|
"18.27.36",
|
||||||
|
"18.29.38",
|
||||||
|
"18.30.37",
|
||||||
|
"18.31.40",
|
||||||
|
"18.32.39",
|
||||||
|
"18.33.40",
|
||||||
|
"18.34.38",
|
||||||
|
"18.35.36",
|
||||||
|
"18.36.39",
|
||||||
|
"18.37.36",
|
||||||
|
"18.38.44",
|
||||||
|
"18.39.41",
|
||||||
|
"18.40.34",
|
||||||
|
"18.41.39",
|
||||||
|
"18.42.41",
|
||||||
|
"18.43.45",
|
||||||
|
"18.44.41",
|
||||||
|
"18.45.43"
|
||||||
|
]
|
||||||
|
)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
@Suppress("unused")
|
||||||
|
object RemoveViewerDiscretionDialogPatch : AbstractRemoveViewerDiscretionDialogPatch(
|
||||||
|
GENERAL,
|
||||||
|
setOf(AgeRestrictionFingerprint)
|
||||||
|
) {
|
||||||
|
override fun execute(context: BytecodeContext) {
|
||||||
|
super.execute(context)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add settings
|
||||||
|
*/
|
||||||
|
SettingsPatch.addPreference(
|
||||||
|
arrayOf(
|
||||||
|
"PREFERENCE: GENERAL_SETTINGS",
|
||||||
|
"SETTINGS: REMOVE_VIEWER_DISCRETION_DIALOG"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
SettingsPatch.updatePatchStatus("Remove viewer discretion dialog")
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
package app.revanced.patches.youtube.general.dialog.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.extensions.or
|
||||||
|
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||||
|
import com.android.tools.smali.dexlib2.AccessFlags
|
||||||
|
import com.android.tools.smali.dexlib2.Opcode
|
||||||
|
|
||||||
|
object AgeRestrictionFingerprint : MethodFingerprint(
|
||||||
|
returnType = "V",
|
||||||
|
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||||
|
parameters = listOf("L", "Ljava/util/Map;"),
|
||||||
|
opcodes = listOf(
|
||||||
|
Opcode.INVOKE_VIRTUAL,
|
||||||
|
Opcode.INVOKE_VIRTUAL,
|
||||||
|
Opcode.MOVE_RESULT_OBJECT,
|
||||||
|
Opcode.INVOKE_VIRTUAL,
|
||||||
|
Opcode.INVOKE_VIRTUAL,
|
||||||
|
Opcode.RETURN_VOID
|
||||||
|
),
|
||||||
|
strings = listOf(
|
||||||
|
"com.google.android.libraries.youtube.rendering.elements.sender_view",
|
||||||
|
"com.google.android.libraries.youtube.innertube.endpoint.tag",
|
||||||
|
"com.google.android.libraries.youtube.innertube.bundle",
|
||||||
|
"com.google.android.libraries.youtube.logging.interaction_logger"
|
||||||
|
)
|
||||||
|
)
|
@ -729,6 +729,9 @@ Tap and hold to set playback speed to 1.0x."</string>
|
|||||||
<string name="revanced_quick_actions_margin_top_title">Quick actions top margin</string>
|
<string name="revanced_quick_actions_margin_top_title">Quick actions top margin</string>
|
||||||
<string name="revanced_quick_actions_margin_top_warning">Quick actions top margin must be between 0-64. Reset to default values.</string>
|
<string name="revanced_quick_actions_margin_top_warning">Quick actions top margin must be between 0-64. Reset to default values.</string>
|
||||||
<string name="revanced_quick_actions_title">Quick actions</string>
|
<string name="revanced_quick_actions_title">Quick actions</string>
|
||||||
|
<string name="revanced_remove_viewer_discretion_dialog_summary">"Remove viewer discretion dialog.
|
||||||
|
This does not bypass the age restriction, it just accepts it automatically."</string>
|
||||||
|
<string name="revanced_remove_viewer_discretion_dialog_title">Remove viewer discretion dialog</string>
|
||||||
<string name="revanced_restart_first_run">Restart to load the layout normally</string>
|
<string name="revanced_restart_first_run">Restart to load the layout normally</string>
|
||||||
<string name="revanced_restart_message">Refresh and restart</string>
|
<string name="revanced_restart_message">Refresh and restart</string>
|
||||||
<string name="revanced_ryd_about">About</string>
|
<string name="revanced_ryd_about">About</string>
|
||||||
|
@ -244,6 +244,9 @@
|
|||||||
<!-- SETTINGS: HIDE_TRENDING_SEARCHES
|
<!-- SETTINGS: HIDE_TRENDING_SEARCHES
|
||||||
<SwitchPreference android:title="@string/revanced_hide_trending_searches_title" android:key="revanced_hide_trending_searches" android:defaultValue="true" android:summaryOn="@string/revanced_hide_trending_searches_summary_on" android:summaryOff="@string/revanced_hide_trending_searches_summary_off" />SETTINGS: HIDE_TRENDING_SEARCHES -->
|
<SwitchPreference android:title="@string/revanced_hide_trending_searches_title" android:key="revanced_hide_trending_searches" android:defaultValue="true" android:summaryOn="@string/revanced_hide_trending_searches_summary_on" android:summaryOff="@string/revanced_hide_trending_searches_summary_off" />SETTINGS: HIDE_TRENDING_SEARCHES -->
|
||||||
|
|
||||||
|
<!-- SETTINGS: REMOVE_VIEWER_DISCRETION_DIALOG
|
||||||
|
<SwitchPreference android:title="@string/revanced_remove_viewer_discretion_dialog_title" android:key="revanced_remove_viewer_discretion_dialog" android:defaultValue="false" android:summary="@string/revanced_remove_viewer_discretion_dialog_summary" />SETTINGS: REMOVE_VIEWER_DISCRETION_DIALOG -->
|
||||||
|
|
||||||
<!-- SETTINGS: HIDE_LAYOUT_COMPONENTS
|
<!-- SETTINGS: HIDE_LAYOUT_COMPONENTS
|
||||||
<Preference android:title=" " android:selectable="false" android:summary="@string/revanced_layout_title" />
|
<Preference android:title=" " android:selectable="false" android:summary="@string/revanced_layout_title" />
|
||||||
<SwitchPreference android:title="@string/revanced_custom_filter_title" android:key="revanced_custom_filter" android:defaultValue="false" android:summaryOn="@string/revanced_custom_filter_summary_on" android:summaryOff="@string/revanced_custom_filter_summary_off" />
|
<SwitchPreference android:title="@string/revanced_custom_filter_title" android:key="revanced_custom_filter" android:defaultValue="false" android:summaryOn="@string/revanced_custom_filter_summary_on" android:summaryOff="@string/revanced_custom_filter_summary_off" />
|
||||||
@ -428,6 +431,7 @@
|
|||||||
<Preference android:title="Hide suggestions shelf" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
<Preference android:title="Hide suggestions shelf" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||||
<Preference android:title="Hide toolbar button" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
<Preference android:title="Hide toolbar button" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||||
<Preference android:title="Hide trending searches" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
<Preference android:title="Hide trending searches" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||||
|
<Preference android:title="Remove viewer discretion dialog" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||||
|
|
||||||
<Preference android:title=" " android:selectable="false" android:summary="@string/revanced_misc" />
|
<Preference android:title=" " android:selectable="false" android:summary="@string/revanced_misc" />
|
||||||
<Preference android:title="Ambient mode switch" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
<Preference android:title="Ambient mode switch" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||||
|
Reference in New Issue
Block a user