mirror of
https://github.com/ReVanced/revanced-patches.git
synced 2026-01-24 11:11:03 +00:00
Compare commits
4 Commits
v2.191.0-d
...
v2.191.0-d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c7383bdf67 | ||
|
|
01e36428a0 | ||
|
|
187c1eb14a | ||
|
|
acadac3049 |
14
CHANGELOG.md
14
CHANGELOG.md
@@ -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)
|
# [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)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
org.gradle.parallel = true
|
org.gradle.parallel = true
|
||||||
org.gradle.caching = true
|
org.gradle.caching = true
|
||||||
kotlin.code.style = official
|
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
@@ -5,39 +5,57 @@ import app.revanced.patcher.patch.PatchException
|
|||||||
import app.revanced.patcher.patch.ResourcePatch
|
import app.revanced.patcher.patch.ResourcePatch
|
||||||
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
||||||
import app.revanced.patcher.patch.annotation.Patch
|
import app.revanced.patcher.patch.annotation.Patch
|
||||||
import java.nio.file.Files
|
import app.revanced.patcher.patch.options.types.BooleanPatchOption.Companion.booleanPatchOption
|
||||||
import java.nio.file.StandardCopyOption
|
import kotlin.io.path.copyTo
|
||||||
import kotlin.io.path.exists
|
|
||||||
|
|
||||||
@Patch(
|
@Patch(
|
||||||
name = "Premium heading",
|
name = "Premium heading",
|
||||||
description = "Shows premium branding on the home screen.",
|
description = "Show or hide the premium heading.",
|
||||||
compatiblePackages = [
|
compatiblePackages = [
|
||||||
CompatiblePackage("com.google.android.youtube")
|
CompatiblePackage("com.google.android.youtube")
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
object PremiumHeadingPatch : ResourcePatch() {
|
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) {
|
override fun execute(context: ResourceContext) {
|
||||||
val resDirectory = context["res"]
|
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 (original, replacement) = if (usePremiumHeading!!)
|
||||||
val modes = arrayOf("light", "dark")
|
DEFAULT_HEADING_RES to PREMIUM_HEADING_RES
|
||||||
|
else
|
||||||
|
PREMIUM_HEADING_RES to DEFAULT_HEADING_RES
|
||||||
|
|
||||||
arrayOf("xxxhdpi", "xxhdpi", "xhdpi", "hdpi", "mdpi").forEach { size ->
|
val variants = arrayOf("light", "dark")
|
||||||
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()
|
|
||||||
|
|
||||||
if (!fromPath.exists())
|
arrayOf(
|
||||||
throw PatchException("The file $fromPath does not exist in the resources. Therefore, this patch can not succeed.")
|
"xxxhdpi",
|
||||||
Files.copy(
|
"xxhdpi",
|
||||||
fromPath,
|
"xhdpi",
|
||||||
toPath,
|
"hdpi",
|
||||||
StandardCopyOption.REPLACE_EXISTING
|
"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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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
|
||||||
|
)
|
||||||
|
)
|
||||||
@@ -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("://")
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user