@@ -2,13 +2,20 @@ package app.revanced.patches.youtube.general.startpage
2
2
3
3
import app.revanced.patcher.data.BytecodeContext
4
4
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
5
- import app.revanced.patches.youtube.general.startpage.fingerprints.ShortcutsActivityFingerprint
6
- import app.revanced.patches.youtube.general.startpage.fingerprints.UrlActivityFingerprint
5
+ import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
6
+ import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
7
+ import app.revanced.patches.youtube.general.startpage.fingerprints.BrowseIdFingerprint
8
+ import app.revanced.patches.youtube.general.startpage.fingerprints.IntentActionFingerprint
7
9
import app.revanced.patches.youtube.utils.compatibility.Constants.COMPATIBLE_PACKAGE
8
- import app.revanced.patches.youtube.utils.integrations.Constants.GENERAL_CLASS_DESCRIPTOR
10
+ import app.revanced.patches.youtube.utils.integrations.Constants.GENERAL_PATH
9
11
import app.revanced.patches.youtube.utils.settings.SettingsPatch
12
+ import app.revanced.util.getReference
13
+ import app.revanced.util.indexOfFirstInstructionOrThrow
10
14
import app.revanced.util.patch.BaseBytecodePatch
11
15
import app.revanced.util.resultOrThrow
16
+ import com.android.tools.smali.dexlib2.Opcode
17
+ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
18
+ import com.android.tools.smali.dexlib2.iface.reference.StringReference
12
19
13
20
@Suppress(" unused" )
14
21
object ChangeStartPagePatch : BaseBytecodePatch(
@@ -17,22 +24,37 @@ object ChangeStartPagePatch : BaseBytecodePatch(
17
24
dependencies = setOf(SettingsPatch ::class),
18
25
compatiblePackages = COMPATIBLE_PACKAGE ,
19
26
fingerprints = setOf(
20
- ShortcutsActivityFingerprint ,
21
- UrlActivityFingerprint
27
+ BrowseIdFingerprint ,
28
+ IntentActionFingerprint ,
22
29
)
23
30
) {
31
+ private const val INTEGRATIONS_CLASS_DESCRIPTOR = " $GENERAL_PATH /ChangeStartPagePatch;"
32
+
24
33
override fun execute (context : BytecodeContext ) {
25
34
26
- mapOf (
27
- ShortcutsActivityFingerprint to " changeStartPageToShortcuts" ,
28
- UrlActivityFingerprint to " changeStartPageToUrl"
29
- ).forEach { (fingerprint, method) ->
30
- fingerprint.resultOrThrow().mutableMethod.addInstruction(
31
- 0 ,
32
- " invoke-static { p1 }, $GENERAL_CLASS_DESCRIPTOR ->$method (Landroid/content/Intent;)V"
35
+ // Hook broseId.
36
+ BrowseIdFingerprint .resultOrThrow().mutableMethod.apply {
37
+ val browseIdIndex = indexOfFirstInstructionOrThrow {
38
+ opcode == Opcode .CONST_STRING &&
39
+ getReference<StringReference >()?.string == " FEwhat_to_watch"
40
+ }
41
+ val browseIdRegister = getInstruction<OneRegisterInstruction >(browseIdIndex).registerA
42
+
43
+ addInstructions(
44
+ browseIdIndex + 1 , """
45
+ invoke-static { v$browseIdRegister }, $INTEGRATIONS_CLASS_DESCRIPTOR ->overrideBrowseId(Ljava/lang/String;)Ljava/lang/String;
46
+ move-result-object v$browseIdRegister
47
+ """
33
48
)
34
49
}
35
50
51
+ // There is no browserId assigned to Shorts and Search.
52
+ // Just hook the Intent action.
53
+ IntentActionFingerprint .resultOrThrow().mutableMethod.addInstruction(
54
+ 0 ,
55
+ " invoke-static { p1 }, $INTEGRATIONS_CLASS_DESCRIPTOR ->overrideIntentAction(Landroid/content/Intent;)V"
56
+ )
57
+
36
58
/* *
37
59
* Add settings
38
60
*/
0 commit comments