feat(YouTube): Support version 18.32.39
This commit is contained in:
+1
-1
@@ -1,4 +1,4 @@
|
||||
package app.revanced.patches.youtube.misc.links.open.annotations
|
||||
package app.revanced.patches.youtube.misc.links.annotations
|
||||
|
||||
import app.revanced.patcher.annotation.Compatibility
|
||||
import app.revanced.patcher.annotation.Package
|
||||
-17
@@ -1,17 +0,0 @@
|
||||
package app.revanced.patches.youtube.misc.links.open.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
|
||||
object BindSessionServiceFingerprint : MethodFingerprint(
|
||||
returnType = "L",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
opcodes = listOf(
|
||||
Opcode.IPUT_OBJECT,
|
||||
Opcode.NEW_INSTANCE,
|
||||
Opcode.CONST_STRING
|
||||
),
|
||||
strings = listOf("android.support.customtabs.action.CustomTabsService")
|
||||
)
|
||||
-18
@@ -1,18 +0,0 @@
|
||||
package app.revanced.patches.youtube.misc.links.open.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
|
||||
object GetCustomTabPackageNameFingerprint : MethodFingerprint(
|
||||
returnType = "L",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC,
|
||||
opcodes = listOf(
|
||||
Opcode.CHECK_CAST,
|
||||
Opcode.NEW_INSTANCE,
|
||||
Opcode.INVOKE_DIRECT,
|
||||
Opcode.CONST_STRING
|
||||
),
|
||||
strings = listOf("android.support.customtabs.action.CustomTabsService")
|
||||
)
|
||||
-18
@@ -1,18 +0,0 @@
|
||||
package app.revanced.patches.youtube.misc.links.open.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
|
||||
object InitializeCustomTabSupportFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
|
||||
opcodes = listOf(
|
||||
Opcode.CHECK_CAST,
|
||||
Opcode.NEW_INSTANCE,
|
||||
Opcode.INVOKE_DIRECT,
|
||||
Opcode.CONST_STRING
|
||||
),
|
||||
strings = listOf("android.support.customtabs.action.CustomTabsService")
|
||||
)
|
||||
-59
@@ -1,59 +0,0 @@
|
||||
package app.revanced.patches.youtube.misc.links.open.patch
|
||||
|
||||
import app.revanced.extensions.exception
|
||||
import app.revanced.patcher.annotation.Description
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patches.shared.settings.preference.impl.StringResource
|
||||
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
|
||||
import app.revanced.patches.youtube.misc.links.open.annotations.OpenLinksExternallyCompatibility
|
||||
import app.revanced.patches.youtube.misc.links.open.fingerprints.BindSessionServiceFingerprint
|
||||
import app.revanced.patches.youtube.misc.links.open.fingerprints.GetCustomTabPackageNameFingerprint
|
||||
import app.revanced.patches.youtube.misc.links.open.fingerprints.InitializeCustomTabSupportFingerprint
|
||||
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction21c
|
||||
|
||||
@Patch
|
||||
@Name("Open links externally")
|
||||
@Description("Open links outside of the app directly in your browser.")
|
||||
@OpenLinksExternallyCompatibility
|
||||
class OpenLinksExternallyPatch : BytecodePatch(
|
||||
listOf(
|
||||
GetCustomTabPackageNameFingerprint,
|
||||
BindSessionServiceFingerprint,
|
||||
InitializeCustomTabSupportFingerprint
|
||||
)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
SettingsPatch.PreferenceScreen.MISC.addPreferences(
|
||||
SwitchPreference(
|
||||
"revanced_external_browser",
|
||||
StringResource("revanced_external_browser_title", "Open links in browser"),
|
||||
StringResource("revanced_external_browser_summary_on", "Opening links externally"),
|
||||
StringResource("revanced_external_browser_summary_off", "Opening links in app")
|
||||
)
|
||||
)
|
||||
|
||||
arrayOf(
|
||||
GetCustomTabPackageNameFingerprint,
|
||||
BindSessionServiceFingerprint,
|
||||
InitializeCustomTabSupportFingerprint
|
||||
).forEach {
|
||||
val result = it.result ?: throw it.exception
|
||||
val insertIndex = result.scanResult.patternScanResult!!.endIndex + 1
|
||||
with(result.mutableMethod) {
|
||||
val register = (implementation!!.instructions[insertIndex - 1] as Instruction21c).registerA
|
||||
addInstructions(
|
||||
insertIndex,
|
||||
"""
|
||||
invoke-static {v$register}, Lapp/revanced/integrations/patches/OpenLinksExternallyPatch;->enableExternalBrowser(Ljava/lang/String;)Ljava/lang/String;
|
||||
move-result-object v$register
|
||||
"""
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
package app.revanced.patches.youtube.misc.links.patch
|
||||
|
||||
import app.revanced.patcher.annotation.Description
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||
import app.revanced.patches.shared.settings.preference.impl.StringResource
|
||||
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
|
||||
import app.revanced.patches.youtube.misc.links.annotations.OpenLinksExternallyCompatibility
|
||||
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
||||
import app.revanced.util.patch.AbstractTransformInstructionsPatch
|
||||
import com.android.tools.smali.dexlib2.iface.ClassDef
|
||||
import com.android.tools.smali.dexlib2.iface.Method
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.Instruction
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.reference.StringReference
|
||||
|
||||
@Patch
|
||||
@Name("Open links externally")
|
||||
@Description("Open links outside of the app directly in your browser.")
|
||||
@OpenLinksExternallyCompatibility
|
||||
class OpenLinksExternallyPatch : AbstractTransformInstructionsPatch<Pair<Int, Int>>(
|
||||
) {
|
||||
override fun filterMap(
|
||||
classDef: ClassDef, method: Method, instruction: Instruction, instructionIndex: Int
|
||||
): Pair<Int, Int>? {
|
||||
if (instruction !is ReferenceInstruction) return null
|
||||
val reference = instruction.reference as? StringReference ?: return null
|
||||
|
||||
if (reference.string != "android.support.customtabs.action.CustomTabsService") return null
|
||||
|
||||
return instructionIndex to (instruction as OneRegisterInstruction).registerA
|
||||
}
|
||||
|
||||
override fun transform(mutableMethod: MutableMethod, entry: Pair<Int, Int>) {
|
||||
val (intentStringIndex, register) = entry
|
||||
|
||||
// Hook the intent string.
|
||||
mutableMethod.addInstructions(
|
||||
intentStringIndex + 1,
|
||||
"""
|
||||
invoke-static {v$register}, Lapp/revanced/integrations/patches/OpenLinksExternallyPatch;->getIntent(Ljava/lang/String;)Ljava/lang/String;
|
||||
move-result-object v$register
|
||||
"""
|
||||
)
|
||||
}
|
||||
|
||||
override fun execute(context: BytecodeContext) {
|
||||
SettingsPatch.PreferenceScreen.MISC.addPreferences(
|
||||
SwitchPreference(
|
||||
"revanced_external_browser",
|
||||
StringResource("revanced_external_browser_title", "Open links in browser"),
|
||||
StringResource("revanced_external_browser_summary_on", "Opening links externally"),
|
||||
StringResource("revanced_external_browser_summary_off", "Opening links in app")
|
||||
)
|
||||
)
|
||||
|
||||
super.execute(context)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user