Compare commits

...

4 Commits

Author SHA1 Message Date
semantic-release-bot
c7383bdf67 chore(release): 2.191.0-dev.19 [skip ci]
# [2.191.0-dev.19](https://github.com/ReVanced/revanced-patches/compare/v2.191.0-dev.18...v2.191.0-dev.19) (2023-09-28)

### Features

* **YouTube:** Add `Bypass URL redirects` patch ([01e3642](01e36428a0))
2023-09-28 02:51:14 +00:00
oSumAtrIX
01e36428a0 feat(YouTube): Add Bypass URL redirects patch 2023-09-28 04:47:41 +02:00
semantic-release-bot
187c1eb14a chore(release): 2.191.0-dev.18 [skip ci]
# [2.191.0-dev.18](https://github.com/ReVanced/revanced-patches/compare/v2.191.0-dev.17...v2.191.0-dev.18) (2023-09-28)

### Features

* **YouTube - Premium heading:** Allow using default heading ([#3029](https://github.com/ReVanced/revanced-patches/issues/3029)) ([acadac3](acadac3049))
2023-09-28 01:06:04 +00:00
aliernfrog
acadac3049 feat(YouTube - Premium heading): Allow using default heading (#3029)
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
2023-09-28 03:03:07 +02:00
7 changed files with 160 additions and 21 deletions

View File

@@ -1,3 +1,17 @@
# [2.191.0-dev.19](https://github.com/ReVanced/revanced-patches/compare/v2.191.0-dev.18...v2.191.0-dev.19) (2023-09-28)
### Features
* **YouTube:** Add `Bypass URL redirects` patch ([125cac5](https://github.com/ReVanced/revanced-patches/commit/125cac5928c9b71d35253f1fd7651f4a30e15529))
# [2.191.0-dev.18](https://github.com/ReVanced/revanced-patches/compare/v2.191.0-dev.17...v2.191.0-dev.18) (2023-09-28)
### Features
* **YouTube - Premium heading:** Allow using default heading ([#3029](https://github.com/ReVanced/revanced-patches/issues/3029)) ([d5ab35a](https://github.com/ReVanced/revanced-patches/commit/d5ab35a444523baa0586fcb9513d6ae4f2518946))
# [2.191.0-dev.17](https://github.com/ReVanced/revanced-patches/compare/v2.191.0-dev.16...v2.191.0-dev.17) (2023-09-27)

View File

@@ -1,4 +1,4 @@
org.gradle.parallel = true
org.gradle.caching = true
kotlin.code.style = official
version = 2.191.0-dev.17
version = 2.191.0-dev.19

File diff suppressed because one or more lines are too long

View File

@@ -5,39 +5,57 @@ import app.revanced.patcher.patch.PatchException
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotation.CompatiblePackage
import app.revanced.patcher.patch.annotation.Patch
import java.nio.file.Files
import java.nio.file.StandardCopyOption
import kotlin.io.path.exists
import app.revanced.patcher.patch.options.types.BooleanPatchOption.Companion.booleanPatchOption
import kotlin.io.path.copyTo
@Patch(
name = "Premium heading",
description = "Shows premium branding on the home screen.",
description = "Show or hide the premium heading.",
compatiblePackages = [
CompatiblePackage("com.google.android.youtube")
]
)
@Suppress("unused")
object PremiumHeadingPatch : ResourcePatch() {
private const val DEFAULT_HEADING_RES = "yt_wordmark_header"
private const val PREMIUM_HEADING_RES = "yt_premium_wordmark_header"
private val usePremiumHeading by booleanPatchOption(
key = "usePremiumHeading",
default = true,
title = "Use premium heading",
description = "Whether to use the premium heading.",
required = true,
)
override fun execute(context: ResourceContext) {
val resDirectory = context["res"]
if (!resDirectory.isDirectory) throw PatchException("The res folder can not be found.")
val (original, replacement) = "yt_premium_wordmark_header" to "yt_wordmark_header"
val modes = arrayOf("light", "dark")
val (original, replacement) = if (usePremiumHeading!!)
DEFAULT_HEADING_RES to PREMIUM_HEADING_RES
else
PREMIUM_HEADING_RES to DEFAULT_HEADING_RES
arrayOf("xxxhdpi", "xxhdpi", "xhdpi", "hdpi", "mdpi").forEach { size ->
val headingDirectory = resDirectory.resolve("drawable-$size")
modes.forEach { mode ->
val fromPath = headingDirectory.resolve("${original}_$mode.png").toPath()
val toPath = headingDirectory.resolve("${replacement}_$mode.png").toPath()
val variants = arrayOf("light", "dark")
if (!fromPath.exists())
throw PatchException("The file $fromPath does not exist in the resources. Therefore, this patch can not succeed.")
Files.copy(
fromPath,
toPath,
StandardCopyOption.REPLACE_EXISTING
)
arrayOf(
"xxxhdpi",
"xxhdpi",
"xhdpi",
"hdpi",
"mdpi"
).mapNotNull { dpi ->
resDirectory.resolve("drawable-$dpi").takeIf { it.exists() }?.toPath()
}.also {
if (it.isEmpty())
throw PatchException("The drawable folder can not be found. Therefore, the patch can not be applied.")
}.forEach { path ->
variants.forEach { mode ->
val fromPath = path.resolve("${original}_$mode.png")
val toPath = path.resolve("${replacement}_$mode.png")
fromPath.copyTo(toPath, true)
}
}
}

View File

@@ -0,0 +1,70 @@
package app.revanced.patches.youtube.misc.links
import app.revanced.extensions.exception
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.annotation.CompatiblePackage
import app.revanced.patcher.patch.annotation.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.integrations.IntegrationsPatch
import app.revanced.patches.youtube.misc.links.fingerprints.OpenLinksDirectlyPrimaryFingerprint
import app.revanced.patches.youtube.misc.links.fingerprints.OpenLinksDirectlySecondaryFingerprint
import app.revanced.patches.youtube.misc.settings.SettingsPatch
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
@Patch(
name = "Bypass URL redirects",
description = "Bypass URL redirects and open the original URL directly.",
dependencies = [IntegrationsPatch::class, SettingsPatch::class],
compatiblePackages = [
CompatiblePackage(
"com.google.android.youtube",
[
"18.16.37",
"18.19.35",
"18.20.39",
"18.23.35",
"18.29.38",
"18.32.39",
"18.37.36"
]
)
]
)
object BypassURLRedirectsPatch : BytecodePatch(
setOf(OpenLinksDirectlyPrimaryFingerprint, OpenLinksDirectlySecondaryFingerprint)
) {
override fun execute(context: BytecodeContext) {
SettingsPatch.PreferenceScreen.MISC.addPreferences(
SwitchPreference(
"revanced_bypass_url_redirects",
StringResource("revanced_bypass_url_redirects_title", "Bypass URL redirects"),
StringResource("revanced_bypass_url_redirects_summary_on", "URL redirects are bypassed"),
StringResource("revanced_bypass_url_redirects_summary_off", "URL redirects are not bypassed"),
)
)
arrayOf(
OpenLinksDirectlyPrimaryFingerprint,
OpenLinksDirectlySecondaryFingerprint
).map {
it.result ?: throw it.exception
}.forEach { result ->
result.mutableMethod.apply {
val insertIndex = result.scanResult.patternScanResult!!.startIndex
val uriStringRegister = getInstruction<FiveRegisterInstruction>(insertIndex).registerC
replaceInstruction(
insertIndex,
"invoke-static {v$uriStringRegister}," +
"Lapp/revanced/integrations/patches/BypassURLRedirectsPatch;" +
"->" +
"parseRedirectUri(Ljava/lang/String;)Landroid/net/Uri;"
)
}
}
}
}

View File

@@ -0,0 +1,20 @@
package app.revanced.patches.youtube.misc.links.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 OpenLinksDirectlyPrimaryFingerprint : MethodFingerprint(
returnType = "Ljava/lang/Object",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf("Ljava/lang/Object"),
opcodes = listOf(
Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT_OBJECT,
Opcode.RETURN_OBJECT,
Opcode.CHECK_CAST,
Opcode.SGET,
Opcode.SGET_OBJECT
)
)

View File

@@ -0,0 +1,17 @@
package app.revanced.patches.youtube.misc.links.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 OpenLinksDirectlySecondaryFingerprint : MethodFingerprint(
returnType = "Landroid/net/Uri",
accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC,
parameters = listOf("Ljava/lang/String"),
opcodes = listOf(
Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT_OBJECT
),
strings = listOf("://")
)