mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-05 17:14:35 +02:00
feat(reddit): add open-links-externally
patch
This commit is contained in:
parent
ca3ff3d28d
commit
0306d18c43
@ -0,0 +1,20 @@
|
||||
package app.revanced.patches.reddit.misc.openlink.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
||||
object ScreenNavigatorFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = listOf("L", "L", "L", "Z"),
|
||||
opcodes = listOf(
|
||||
Opcode.CONST_STRING,
|
||||
Opcode.INVOKE_STATIC,
|
||||
Opcode.CONST_STRING,
|
||||
Opcode.INVOKE_STATIC
|
||||
),
|
||||
strings = listOf("uri", "android.intent.action.VIEW"),
|
||||
customFingerprint = { it, _ -> it.definingClass.endsWith("/RedditScreenNavigator;") }
|
||||
)
|
@ -0,0 +1,57 @@
|
||||
package app.revanced.patches.reddit.misc.openlink.patch
|
||||
|
||||
import app.revanced.extensions.toErrorResult
|
||||
import app.revanced.patcher.annotation.Description
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patcher.util.smali.ExternalLabel
|
||||
import app.revanced.patches.reddit.misc.openlink.fingerprints.ScreenNavigatorFingerprint
|
||||
import app.revanced.patches.reddit.utils.annotations.RedditCompatibility
|
||||
import app.revanced.patches.reddit.utils.settings.bytecode.patch.SettingsPatch
|
||||
import app.revanced.patches.reddit.utils.settings.bytecode.patch.SettingsPatch.Companion.updateSettingsStatus
|
||||
import app.revanced.util.bytecode.getStringIndex
|
||||
|
||||
@Patch
|
||||
@Name("open-links-externally")
|
||||
@Description("Open links outside of the app directly in your browser.")
|
||||
@DependsOn([SettingsPatch::class])
|
||||
@RedditCompatibility
|
||||
@Version("0.0.1")
|
||||
class OpenLinksExternallyPatch : BytecodePatch(
|
||||
listOf(ScreenNavigatorFingerprint)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
ScreenNavigatorFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
val insertIndex = getStringIndex("uri") + 2
|
||||
|
||||
addInstructionsWithLabels(
|
||||
insertIndex, """
|
||||
invoke-static {}, $INTEGRATIONS_METHOD_DESCRIPTOR->openLinksExternally()Z
|
||||
move-result v0
|
||||
if-eqz v0, :dismiss
|
||||
invoke-static {p1, p2}, $INTEGRATIONS_METHOD_DESCRIPTOR->openLinksExternally(Landroid/app/Activity;Landroid/net/Uri;)V
|
||||
return-void
|
||||
""", ExternalLabel("dismiss", getInstruction(insertIndex))
|
||||
)
|
||||
}
|
||||
} ?: return ScreenNavigatorFingerprint.toErrorResult()
|
||||
|
||||
updateSettingsStatus("OpenLinksExternally")
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
private companion object {
|
||||
private const val INTEGRATIONS_METHOD_DESCRIPTOR =
|
||||
"Lapp/revanced/reddit/patches/OpenLinksExternallyPatch;"
|
||||
}
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||
<resources>
|
||||
<string name="revanced_enable_open_links_externally_summary">Open links outside of the app directly in your browser</string>
|
||||
<string name="revanced_enable_open_links_externally_title">Open links externally</string>
|
||||
<string name="revanced_enable_sanitize_url_query_summary">Removes (tracking) query parameters from the URLs when sharing links</string>
|
||||
<string name="revanced_enable_sanitize_url_query_title">Sanitize sharing links</string>
|
||||
<string name="revanced_extended_settings_title">ReVanced Extended</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user