diff --git a/patches/api/patches.api b/patches/api/patches.api index 7ea364a9a..b53b2c301 100644 --- a/patches/api/patches.api +++ b/patches/api/patches.api @@ -400,6 +400,10 @@ public final class app/revanced/patches/pixiv/ads/HideAdsPatchKt { public static final fun getHideAdsPatch ()Lapp/revanced/patcher/patch/BytecodePatch; } +public final class app/revanced/patches/protonmail/signature/RemoveSentFromSignaturePatchKt { + public static final fun getRemoveSentFromSignaturePatch ()Lapp/revanced/patcher/patch/ResourcePatch; +} + public final class app/revanced/patches/rar/misc/annoyances/purchasereminder/HidePurchaseReminderPatchKt { public static final fun getHidePurchaseReminderPatch ()Lapp/revanced/patcher/patch/BytecodePatch; } diff --git a/patches/src/main/kotlin/app/revanced/patches/protonmail/signature/RemoveSentFromSignaturePatch.kt b/patches/src/main/kotlin/app/revanced/patches/protonmail/signature/RemoveSentFromSignaturePatch.kt new file mode 100644 index 000000000..f3d2b2dd2 --- /dev/null +++ b/patches/src/main/kotlin/app/revanced/patches/protonmail/signature/RemoveSentFromSignaturePatch.kt @@ -0,0 +1,42 @@ +package app.revanced.patches.protonmail.signature + +import app.revanced.patcher.patch.PatchException +import app.revanced.patcher.patch.resourcePatch +import app.revanced.util.findElementByAttributeValue +import java.io.File + +@Suppress("unused") +val removeSentFromSignaturePatch = resourcePatch( + name = "Remove 'Sent from' signature", + description = "Removes the 'Sent from Proton Mail mobile' signature from emails.", +) { + compatibleWith("ch.protonmail.android") + + execute { + val stringResourceFiles = mutableListOf() + + get("res").walk().forEach { file -> + if (file.isFile && file.name.equals("strings.xml", ignoreCase = true)) { + stringResourceFiles.add(file) + } + } + + var foundString = false + stringResourceFiles.forEach { filePath -> + document(filePath.absolutePath).use { document -> + var node = document.documentElement.childNodes.findElementByAttributeValue( + "name", + "mail_settings_identity_mobile_footer_default_free" + ) + + // String is not localized in all languages. + if (node != null) { + node.textContent = "" + foundString = true + } + } + } + + if (!foundString) throw PatchException("Could not find 'sent from' string in resources") + } +} \ No newline at end of file