@@ -4,14 +4,17 @@ import app.revanced.patcher.data.BytecodeContext
4
4
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
5
5
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
6
6
import app.revanced.patcher.patch.BytecodePatch
7
+ import app.revanced.patcher.patch.PatchException
7
8
import app.revanced.patcher.patch.annotation.CompatiblePackage
8
9
import app.revanced.patcher.patch.annotation.Patch
9
10
import app.revanced.patches.youtube.player.speedoverlay.fingerprints.RestoreSlideToSeekBehaviorFingerprint
10
11
import app.revanced.patches.youtube.player.speedoverlay.fingerprints.SpeedOverlayFingerprint
11
12
import app.revanced.patches.youtube.utils.integrations.Constants.PLAYER
12
13
import app.revanced.patches.youtube.utils.settings.SettingsPatch
14
+ import app.revanced.util.doRecursively
13
15
import app.revanced.util.exception
14
16
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
17
+ import org.w3c.dom.Element
15
18
16
19
@Patch(
17
20
name = " Disable speed overlay" ,
@@ -65,24 +68,43 @@ object SpeedOverlayPatch : BytecodePatch(
65
68
) {
66
69
override fun execute (context : BytecodeContext ) {
67
70
68
- arrayOf(
69
- RestoreSlideToSeekBehaviorFingerprint ,
70
- SpeedOverlayFingerprint
71
- ).forEach { fingerprint ->
72
- fingerprint.result?.let {
73
- it.mutableMethod.apply {
74
- val insertIndex = it.scanResult.patternScanResult!! .endIndex + 1
75
- val insertRegister =
76
- getInstruction<OneRegisterInstruction >(insertIndex).registerA
71
+ if (SettingsPatch .upward1836) {
72
+ arrayOf(
73
+ RestoreSlideToSeekBehaviorFingerprint ,
74
+ SpeedOverlayFingerprint
75
+ ).forEach { fingerprint ->
76
+ fingerprint.result?.let {
77
+ it.mutableMethod.apply {
78
+ val insertIndex = it.scanResult.patternScanResult!! .endIndex + 1
79
+ val insertRegister =
80
+ getInstruction<OneRegisterInstruction >(insertIndex).registerA
81
+
82
+ addInstructions(
83
+ insertIndex, """
84
+ invoke-static {v$insertRegister }, $PLAYER ->disableSpeedOverlay(Z)Z
85
+ move-result v$insertRegister
86
+ """
87
+ )
88
+ }
89
+ } ? : throw fingerprint.exception
90
+ }
91
+ } else {
92
+ throw PatchException (" This version is not supported. Please use YouTube 18.36.39 or later." )
93
+ }
94
+
95
+ if (SettingsPatch .upward1839) {
96
+ SettingsPatch .contexts.xmlEditor[" res/layout/speedmaster_icon_edu_overlay.xml" ].use { editor ->
97
+ editor.file.doRecursively {
98
+ arrayOf(" height" , " width" ).forEach replacement@{ replacement ->
99
+ if (it !is Element ) return @replacement
77
100
78
- addInstructions(
79
- insertIndex, """
80
- invoke-static {v$insertRegister }, $PLAYER ->disableSpeedOverlay(Z)Z
81
- move-result v$insertRegister
82
- """
83
- )
101
+ if (it.attributes.getNamedItem(" android:src" )?.nodeValue?.endsWith(" _24" ) == true ) {
102
+ it.getAttributeNode(" android:layout_$replacement " )
103
+ ?.let { attribute -> attribute.textContent = " 12.0dip" }
104
+ }
105
+ }
84
106
}
85
- } ? : throw fingerprint.exception
107
+ }
86
108
}
87
109
88
110
/* *
0 commit comments