mirror of
https://github.com/ReVanced/revanced-patches.git
synced 2026-01-15 15:33:13 +00:00
Compare commits
5 Commits
v2.174.0-d
...
v2.174.0-d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
48965ace7e | ||
|
|
08f1702b18 | ||
|
|
45784eceee | ||
|
|
f891aa937c | ||
|
|
aa493c4f67 |
14
CHANGELOG.md
14
CHANGELOG.md
@@ -1,3 +1,17 @@
|
||||
# [2.174.0-dev.19](https://github.com/revanced/revanced-patches/compare/v2.174.0-dev.18...v2.174.0-dev.19) (2023-05-11)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **youtube/video-speed:** change custom video speeds inside app settings ([#2114](https://github.com/revanced/revanced-patches/issues/2114)) ([d97815a](https://github.com/revanced/revanced-patches/commit/d97815af18e645fd0fa087db0174bcc2a771ec72))
|
||||
|
||||
# [2.174.0-dev.18](https://github.com/revanced/revanced-patches/compare/v2.174.0-dev.17...v2.174.0-dev.18) (2023-05-11)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **youtube/theme:** apply custom seekbar color to video thumbnails ([#2085](https://github.com/revanced/revanced-patches/issues/2085)) ([d497027](https://github.com/revanced/revanced-patches/commit/d4970273ad10f62cd9455ef9b847c686147f7dca))
|
||||
|
||||
# [2.174.0-dev.17](https://github.com/revanced/revanced-patches/compare/v2.174.0-dev.16...v2.174.0-dev.17) (2023-05-09)
|
||||
|
||||
|
||||
|
||||
53
README.md
53
README.md
@@ -15,7 +15,6 @@ The official ReVanced Patches.
|
||||
| `copy-video-url` | Adds buttons in player to copy video links. | 18.16.37 |
|
||||
| `custom-branding` | Changes the YouTube launcher icon and name to your choice (defaults to ReVanced). | all |
|
||||
| `custom-video-buffer` | Lets you change the buffers of videos. | 18.16.37 |
|
||||
| `custom-video-speed` | Adds more video speed options. | 18.16.37 |
|
||||
| `disable-auto-captions` | Disable forced captions from being automatically enabled. | 18.16.37 |
|
||||
| `disable-fullscreen-panels` | Disables video description and comments panel in fullscreen view. | 18.16.37 |
|
||||
| `disable-player-popup-panels` | Disables panels from appearing automatically when going into fullscreen (playlist or live chat). | 18.16.37 |
|
||||
@@ -49,7 +48,6 @@ The official ReVanced Patches.
|
||||
| `old-quality-layout` | Enables the original video quality flyout in the video player settings | 18.16.37 |
|
||||
| `open-links-externally` | Open links outside of the app directly in your browser. | 18.16.37 |
|
||||
| `premium-heading` | Shows premium branding on the home screen. | all |
|
||||
| `remember-playback-speed` | Adds the ability to remember the playback speed you chose in the video playback speed flyout. | 18.16.37 |
|
||||
| `remember-video-quality` | Adds the ability to remember the video quality you chose in the video quality flyout. | 18.16.37 |
|
||||
| `remove-player-button-background` | Removes the background from the video player buttons. | 18.16.37 |
|
||||
| `return-youtube-dislike` | Shows the dislike count of videos using the Return YouTube Dislike API. | 18.16.37 |
|
||||
@@ -58,7 +56,6 @@ The official ReVanced Patches.
|
||||
| `spoof-app-version` | Tricks YouTube into thinking, you are running an older version of the app. One of the side effects also includes restoring the old UI. | 18.16.37 |
|
||||
| `swipe-controls` | Adds volume and brightness swipe controls. | 18.16.37 |
|
||||
| `tablet-mini-player` | Enables the tablet mini player layout. | 18.16.37 |
|
||||
| `theme` | Applies a custom theme. | all |
|
||||
| `vanced-microg-support` | Allows YouTube ReVanced to run without root and under a different package name with Vanced MicroG. | 18.16.37 |
|
||||
| `video-ads` | Removes ads in the video player. | 18.16.37 |
|
||||
| `wide-searchbar` | Replaces the search icon with a wide search bar. This will hide the YouTube logo when active. | 18.16.37 |
|
||||
@@ -313,30 +310,6 @@ The official ReVanced Patches.
|
||||
| `unlock-prime` | Unlocks Nova Prime and all functions of the app. | all |
|
||||
</details>
|
||||
|
||||
### [📦 `co.windyapp.android`](https://play.google.com/store/apps/details?id=co.windyapp.android)
|
||||
<details>
|
||||
|
||||
| 💊 Patch | 📜 Description | 🏹 Target Version |
|
||||
|:--------:|:--------------:|:-----------------:|
|
||||
| `unlock-pro` | Unlocks all pro features. | all |
|
||||
</details>
|
||||
|
||||
### [📦 `org.totschnig.myexpenses`](https://play.google.com/store/apps/details?id=org.totschnig.myexpenses)
|
||||
<details>
|
||||
|
||||
| 💊 Patch | 📜 Description | 🏹 Target Version |
|
||||
|:--------:|:--------------:|:-----------------:|
|
||||
| `unlock-pro` | Unlocks all professional features. | 3.4.9 |
|
||||
</details>
|
||||
|
||||
### [📦 `com.zombodroid.MemeGenerator`](https://play.google.com/store/apps/details?id=com.zombodroid.MemeGenerator)
|
||||
<details>
|
||||
|
||||
| 💊 Patch | 📜 Description | 🏹 Target Version |
|
||||
|:--------:|:--------------:|:-----------------:|
|
||||
| `unlock-pro` | Unlocks pro features. | 4.6377 |
|
||||
</details>
|
||||
|
||||
### [📦 `com.ithebk.expensemanager`](https://play.google.com/store/apps/details?id=com.ithebk.expensemanager)
|
||||
<details>
|
||||
|
||||
@@ -345,6 +318,14 @@ The official ReVanced Patches.
|
||||
| `unlock-pro` | Unlocks pro features. | all |
|
||||
</details>
|
||||
|
||||
### [📦 `com.awedea.nyx`](https://play.google.com/store/apps/details?id=com.awedea.nyx)
|
||||
<details>
|
||||
|
||||
| 💊 Patch | 📜 Description | 🏹 Target Version |
|
||||
|:--------:|:--------------:|:-----------------:|
|
||||
| `unlock-pro` | Unlocks all pro features. | all |
|
||||
</details>
|
||||
|
||||
### [📦 `ginlemon.iconpackstudio`](https://play.google.com/store/apps/details?id=ginlemon.iconpackstudio)
|
||||
<details>
|
||||
|
||||
@@ -353,7 +334,7 @@ The official ReVanced Patches.
|
||||
| `unlock-pro` | Unlocks all pro features. | all |
|
||||
</details>
|
||||
|
||||
### [📦 `com.awedea.nyx`](https://play.google.com/store/apps/details?id=com.awedea.nyx)
|
||||
### [📦 `co.windyapp.android`](https://play.google.com/store/apps/details?id=co.windyapp.android)
|
||||
<details>
|
||||
|
||||
| 💊 Patch | 📜 Description | 🏹 Target Version |
|
||||
@@ -361,6 +342,22 @@ The official ReVanced Patches.
|
||||
| `unlock-pro` | Unlocks all pro features. | all |
|
||||
</details>
|
||||
|
||||
### [📦 `com.zombodroid.MemeGenerator`](https://play.google.com/store/apps/details?id=com.zombodroid.MemeGenerator)
|
||||
<details>
|
||||
|
||||
| 💊 Patch | 📜 Description | 🏹 Target Version |
|
||||
|:--------:|:--------------:|:-----------------:|
|
||||
| `unlock-pro` | Unlocks pro features. | 4.6377 |
|
||||
</details>
|
||||
|
||||
### [📦 `org.totschnig.myexpenses`](https://play.google.com/store/apps/details?id=org.totschnig.myexpenses)
|
||||
<details>
|
||||
|
||||
| 💊 Patch | 📜 Description | 🏹 Target Version |
|
||||
|:--------:|:--------------:|:-----------------:|
|
||||
| `unlock-pro` | Unlocks all professional features. | 3.4.9 |
|
||||
</details>
|
||||
|
||||
### [📦 `com.ticktick.task`](https://play.google.com/store/apps/details?id=com.ticktick.task)
|
||||
<details>
|
||||
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
kotlin.code.style = official
|
||||
version = 2.174.0-dev.17
|
||||
version = 2.174.0-dev.19
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,6 +1,8 @@
|
||||
package app.revanced.patches.shared.settings.preference.impl
|
||||
|
||||
enum class InputType(val type: String) {
|
||||
STRING("text"),
|
||||
STRING("text"), // TODO: rename to "TEXT"
|
||||
TEXT_CAP_CHARACTERS("textCapCharacters"),
|
||||
TEXT_MULTI_LINE("textMultiLine"),
|
||||
NUMBER("number"),
|
||||
}
|
||||
@@ -16,11 +16,16 @@ import app.revanced.patches.shared.fingerprints.SeekbarOnDrawFingerprint
|
||||
import app.revanced.patches.shared.settings.preference.impl.StringResource
|
||||
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
|
||||
import app.revanced.patches.youtube.layout.hide.seekbar.annotations.HideSeekbarCompatibility
|
||||
import app.revanced.patches.youtube.layout.seekbar.bytecode.patch.SeekbarColorBytecodePatch
|
||||
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
||||
|
||||
@Patch
|
||||
@DependsOn([IntegrationsPatch::class, SettingsPatch::class])
|
||||
@DependsOn([
|
||||
IntegrationsPatch::class,
|
||||
SettingsPatch::class,
|
||||
SeekbarColorBytecodePatch::class // Used to hide the seekbar in the feed and watch history
|
||||
])
|
||||
@Name("hide-seekbar")
|
||||
@Description("Hides the seekbar.")
|
||||
@HideSeekbarCompatibility
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package app.revanced.patches.youtube.layout.seekbar.annotations
|
||||
|
||||
import app.revanced.patcher.annotation.Compatibility
|
||||
import app.revanced.patcher.annotation.Package
|
||||
|
||||
@Compatibility([Package("com.google.android.youtube")])
|
||||
@Target(AnnotationTarget.CLASS)
|
||||
internal annotation class SeekbarColorCompatibility
|
||||
@@ -0,0 +1,15 @@
|
||||
package app.revanced.patches.youtube.layout.seekbar.bytecode.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import app.revanced.patches.youtube.layout.seekbar.resource.SeekbarColorResourcePatch
|
||||
import app.revanced.util.patch.indexOfFirstConstantInstruction
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
|
||||
object CreateDarkThemeSeekbarFingerprint : MethodFingerprint(
|
||||
access = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
|
||||
customFingerprint = { method ->
|
||||
method.indexOfFirstConstantInstruction(SeekbarColorResourcePatch.inlineTimeBarColorizedBarPlayedColorDarkId) != -1
|
||||
&& method.indexOfFirstConstantInstruction(SeekbarColorResourcePatch.inlineTimeBarPlayedNotHighlightedColorId) != -1
|
||||
}
|
||||
)
|
||||
@@ -1,4 +1,4 @@
|
||||
package app.revanced.patches.youtube.layout.theme.bytecode.fingerprints
|
||||
package app.revanced.patches.youtube.layout.seekbar.bytecode.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import org.jf.dexlib2.Opcode
|
||||
@@ -0,0 +1,85 @@
|
||||
package app.revanced.patches.youtube.layout.seekbar.bytecode.patch
|
||||
|
||||
import app.revanced.extensions.toErrorResult
|
||||
import app.revanced.patcher.annotation.Description
|
||||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.data.toMethodWalker
|
||||
import app.revanced.patcher.extensions.addInstructions
|
||||
import app.revanced.patcher.extensions.instruction
|
||||
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.util.proxy.mutableTypes.MutableMethod
|
||||
import app.revanced.patches.youtube.layout.seekbar.annotations.SeekbarColorCompatibility
|
||||
import app.revanced.patches.youtube.layout.seekbar.bytecode.fingerprints.CreateDarkThemeSeekbarFingerprint
|
||||
import app.revanced.patches.youtube.layout.seekbar.bytecode.fingerprints.SetSeekbarClickedColorFingerprint
|
||||
import app.revanced.patches.youtube.layout.theme.bytecode.patch.LithoColorHookPatch
|
||||
import app.revanced.patches.youtube.layout.theme.bytecode.patch.LithoColorHookPatch.Companion.lithoColorOverrideHook
|
||||
import app.revanced.patches.youtube.layout.seekbar.resource.SeekbarColorResourcePatch
|
||||
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||
import app.revanced.util.patch.indexOfFirstConstantInstruction
|
||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction
|
||||
|
||||
@Description("Hide or set a custom seekbar color")
|
||||
@DependsOn([IntegrationsPatch::class, LithoColorHookPatch::class, SeekbarColorResourcePatch::class])
|
||||
@SeekbarColorCompatibility
|
||||
@Version("0.0.1")
|
||||
class SeekbarColorBytecodePatch : BytecodePatch(
|
||||
listOf(CreateDarkThemeSeekbarFingerprint, SetSeekbarClickedColorFingerprint)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
CreateDarkThemeSeekbarFingerprint.result?.mutableMethod?.apply {
|
||||
var registerIndex = indexOfFirstConstantInstruction(SeekbarColorResourcePatch.inlineTimeBarColorizedBarPlayedColorDarkId) + 2
|
||||
var colorRegister = (instruction(registerIndex) as OneRegisterInstruction).registerA
|
||||
addInstructions(
|
||||
registerIndex + 1,
|
||||
"""
|
||||
invoke-static { v$colorRegister }, $INTEGRATIONS_CLASS_DESCRIPTOR->getSeekbarColorValue(I)I
|
||||
move-result v$colorRegister
|
||||
"""
|
||||
)
|
||||
|
||||
registerIndex = indexOfFirstConstantInstruction(SeekbarColorResourcePatch.inlineTimeBarPlayedNotHighlightedColorId) + 2
|
||||
colorRegister = (instruction(registerIndex) as OneRegisterInstruction).registerA
|
||||
addInstructions(
|
||||
registerIndex + 1,
|
||||
"""
|
||||
invoke-static { v$colorRegister }, $INTEGRATIONS_CLASS_DESCRIPTOR->getSeekbarColorValue(I)I
|
||||
move-result v$colorRegister
|
||||
"""
|
||||
)
|
||||
} ?: return CreateDarkThemeSeekbarFingerprint.toErrorResult()
|
||||
|
||||
SetSeekbarClickedColorFingerprint.result?.let { result ->
|
||||
result.mutableMethod.let {
|
||||
val setColorMethodIndex = result.scanResult.patternScanResult!!.startIndex + 1
|
||||
val method = context
|
||||
.toMethodWalker(it)
|
||||
.nextMethod(setColorMethodIndex, true)
|
||||
.getMethod() as MutableMethod
|
||||
|
||||
method.apply {
|
||||
val colorRegister = (method.instruction(0) as TwoRegisterInstruction).registerA
|
||||
addInstructions(
|
||||
0,
|
||||
"""
|
||||
invoke-static { v$colorRegister }, $INTEGRATIONS_CLASS_DESCRIPTOR->getSeekbarColorOverride(I)I
|
||||
move-result v$colorRegister
|
||||
"""
|
||||
)
|
||||
}
|
||||
}
|
||||
} ?: return SetSeekbarClickedColorFingerprint.toErrorResult()
|
||||
|
||||
lithoColorOverrideHook(INTEGRATIONS_CLASS_DESCRIPTOR, "getSeekbarColorOverride")
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
private companion object {
|
||||
private const val INTEGRATIONS_CLASS_DESCRIPTOR = "Lapp/revanced/integrations/patches/theme/SeekbarColorPatch;"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package app.revanced.patches.youtube.layout.seekbar.resource
|
||||
|
||||
import app.revanced.patcher.data.ResourceContext
|
||||
import app.revanced.patcher.patch.*
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch
|
||||
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
||||
import org.w3c.dom.Element
|
||||
|
||||
@DependsOn([SettingsPatch::class, ResourceMappingPatch::class])
|
||||
class SeekbarColorResourcePatch : ResourcePatch {
|
||||
override fun execute(context: ResourceContext): PatchResult {
|
||||
// Edit theme colors via bytecode.
|
||||
// For that the resource id is used in a bytecode patch to change the color.
|
||||
|
||||
val seekbarErrorMessage = "Could not find seekbar resource"
|
||||
inlineTimeBarColorizedBarPlayedColorDarkId = ResourceMappingPatch.resourceMappings
|
||||
.find { it.name == "inline_time_bar_colorized_bar_played_color_dark" }?.id
|
||||
?: return PatchResultError(seekbarErrorMessage)
|
||||
inlineTimeBarPlayedNotHighlightedColorId = ResourceMappingPatch.resourceMappings
|
||||
.find { it.name == "inline_time_bar_played_not_highlighted_color" }?.id
|
||||
?: return PatchResultError(seekbarErrorMessage)
|
||||
|
||||
// Edit the resume playback drawable and replace the progress bar with a custom drawable
|
||||
context.xmlEditor["res/drawable/resume_playback_progressbar_drawable.xml"].use { editor ->
|
||||
val layerList = editor.file.getElementsByTagName("layer-list").item(0) as Element
|
||||
val progressNode = layerList.getElementsByTagName("item").item(1) as Element
|
||||
if (!progressNode.getAttributeNode("android:id").value.endsWith("progress")) {
|
||||
return PatchResultError("Could not find progress bar")
|
||||
}
|
||||
val scaleNode = progressNode.getElementsByTagName("scale").item(0) as Element
|
||||
val shapeNode = scaleNode.getElementsByTagName("shape").item(0) as Element
|
||||
val replacementNode = editor.file.createElement(
|
||||
"app.revanced.integrations.patches.theme.ProgressBarDrawable")
|
||||
scaleNode.replaceChild(replacementNode, shapeNode)
|
||||
}
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
companion object {
|
||||
internal var inlineTimeBarColorizedBarPlayedColorDarkId = -1L
|
||||
internal var inlineTimeBarPlayedNotHighlightedColorId = -1L
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package app.revanced.patches.youtube.layout.theme.bytecode.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import app.revanced.patches.youtube.layout.theme.bytecode.fingerprints.CreateDarkThemeSeekbarFingerprint.indexOfInstructionWithSeekbarId
|
||||
import app.revanced.patches.youtube.layout.theme.resource.ThemeResourcePatch
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
import org.jf.dexlib2.Opcode
|
||||
import org.jf.dexlib2.iface.Method
|
||||
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
|
||||
|
||||
object CreateDarkThemeSeekbarFingerprint : MethodFingerprint(
|
||||
access = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
|
||||
customFingerprint = { method -> method.indexOfInstructionWithSeekbarId != -1 },
|
||||
) {
|
||||
/**
|
||||
* The index of the instruction that loads the resource id of the seekbar.
|
||||
*/
|
||||
internal val Method.indexOfInstructionWithSeekbarId
|
||||
get() = implementation?.let {
|
||||
it.instructions.indexOfFirst { instruction ->
|
||||
instruction.opcode == Opcode.CONST && (instruction as WideLiteralInstruction).wideLiteral == ThemeResourcePatch.inlineTimeBarColorizedBarPlayedColorDarkId
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package app.revanced.patches.youtube.layout.theme.fingerprints
|
||||
package app.revanced.patches.youtube.layout.theme.bytecode.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
@@ -0,0 +1,47 @@
|
||||
package app.revanced.patches.youtube.layout.theme.bytecode.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.addInstructions
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||
import app.revanced.patches.youtube.layout.theme.annotations.ThemeCompatibility
|
||||
import app.revanced.patches.youtube.layout.theme.bytecode.fingerprints.LithoThemeFingerprint
|
||||
|
||||
@Name("litho-color-hook")
|
||||
@Description("Adds a hook to set color of Litho components.")
|
||||
@ThemeCompatibility
|
||||
@Version("0.0.1")
|
||||
class LithoColorHookPatch : BytecodePatch(listOf(LithoThemeFingerprint)) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
LithoThemeFingerprint.result?.let {
|
||||
insertionIndex = it.scanResult.patternScanResult!!.endIndex - 1
|
||||
colorRegister = "p1"
|
||||
insertionMethod = it.mutableMethod
|
||||
} ?: return LithoThemeFingerprint.toErrorResult()
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
companion object {
|
||||
private var insertionIndex : Int = -1
|
||||
private lateinit var colorRegister : String
|
||||
private lateinit var insertionMethod : MutableMethod
|
||||
|
||||
internal fun lithoColorOverrideHook(targetMethodClass: String, targetMethodName: String) {
|
||||
insertionMethod.addInstructions(
|
||||
insertionIndex,
|
||||
"""
|
||||
invoke-static {$colorRegister}, $targetMethodClass->$targetMethodName(I)I
|
||||
move-result $colorRegister
|
||||
"""
|
||||
)
|
||||
insertionIndex += 2
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,76 +1,34 @@
|
||||
package app.revanced.patches.youtube.layout.theme.bytecode.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.data.toMethodWalker
|
||||
import app.revanced.patcher.extensions.addInstructions
|
||||
import app.revanced.patcher.extensions.instruction
|
||||
import app.revanced.patcher.patch.*
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||
import app.revanced.patches.youtube.layout.theme.annotations.ThemeCompatibility
|
||||
import app.revanced.patches.youtube.layout.theme.bytecode.fingerprints.CreateDarkThemeSeekbarFingerprint
|
||||
import app.revanced.patches.youtube.layout.theme.bytecode.fingerprints.CreateDarkThemeSeekbarFingerprint.indexOfInstructionWithSeekbarId
|
||||
import app.revanced.patches.youtube.layout.theme.bytecode.fingerprints.SetSeekbarClickedColorFingerprint
|
||||
import app.revanced.patches.youtube.layout.seekbar.bytecode.patch.SeekbarColorBytecodePatch
|
||||
import app.revanced.patches.youtube.layout.seekbar.bytecode.fingerprints.CreateDarkThemeSeekbarFingerprint
|
||||
import app.revanced.patches.youtube.layout.seekbar.bytecode.fingerprints.SetSeekbarClickedColorFingerprint
|
||||
import app.revanced.patches.youtube.layout.theme.resource.ThemeResourcePatch
|
||||
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||
import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction
|
||||
|
||||
@Patch
|
||||
@Name("theme")
|
||||
@Description("Applies a custom theme.")
|
||||
@DependsOn([ThemeLithoComponentsPatch::class, ThemeResourcePatch::class, IntegrationsPatch::class])
|
||||
@ThemeCompatibility
|
||||
@DependsOn([LithoColorHookPatch::class, SeekbarColorBytecodePatch::class, ThemeResourcePatch::class])
|
||||
@Version("0.0.1")
|
||||
class ThemeBytecodePatch : BytecodePatch(
|
||||
listOf(CreateDarkThemeSeekbarFingerprint, SetSeekbarClickedColorFingerprint)
|
||||
) {
|
||||
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
CreateDarkThemeSeekbarFingerprint.result?.let {
|
||||
val putColorValueIndex = it.method.indexOfInstructionWithSeekbarId!! + 3
|
||||
LithoColorHookPatch.lithoColorOverrideHook(INTEGRATIONS_CLASS_DESCRIPTOR, "getValue")
|
||||
|
||||
it.mutableMethod.apply {
|
||||
val overrideRegister = instruction<TwoRegisterInstruction>(putColorValueIndex).registerA
|
||||
|
||||
addInstructions(
|
||||
putColorValueIndex,
|
||||
"""
|
||||
invoke-static { }, $INTEGRATIONS_CLASS_DESCRIPTOR->getSeekbarColorValue()I
|
||||
move-result v$overrideRegister
|
||||
"""
|
||||
)
|
||||
}
|
||||
} ?: return CreateDarkThemeSeekbarFingerprint.toErrorResult()
|
||||
|
||||
SetSeekbarClickedColorFingerprint.result?.let { result ->
|
||||
result.mutableMethod.let {
|
||||
val setColorMethodIndex = result.scanResult.patternScanResult!!.startIndex + 1
|
||||
val method = context
|
||||
.toMethodWalker(it)
|
||||
.nextMethod(setColorMethodIndex, true)
|
||||
.getMethod() as MutableMethod
|
||||
|
||||
method.apply {
|
||||
val colorRegister = method.instruction<TwoRegisterInstruction>(0).registerA
|
||||
addInstructions(
|
||||
0,
|
||||
"""
|
||||
invoke-static { v$colorRegister }, $INTEGRATIONS_CLASS_DESCRIPTOR->getSeekbarClickedColorValue(I)I
|
||||
move-result v$colorRegister
|
||||
"""
|
||||
)
|
||||
}
|
||||
}
|
||||
} ?: return SetSeekbarClickedColorFingerprint.toErrorResult()
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
companion object : OptionsContainer() {
|
||||
private const val INTEGRATIONS_CLASS_DESCRIPTOR = "Lapp/revanced/integrations/patches/theme/ThemePatch;"
|
||||
private const val INTEGRATIONS_CLASS_DESCRIPTOR = "Lapp/revanced/integrations/patches/theme/ThemeLithoComponentsPatch;"
|
||||
|
||||
var darkThemeBackgroundColor: String? by option(
|
||||
PatchOption.StringOption(
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
package app.revanced.patches.youtube.layout.theme.bytecode.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.addInstructions
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patches.youtube.layout.theme.annotations.ThemeCompatibility
|
||||
import app.revanced.patches.youtube.layout.theme.fingerprints.LithoThemeFingerprint
|
||||
|
||||
@Name("theme-litho-components")
|
||||
@Description("Applies a custom theme to Litho components.")
|
||||
@ThemeCompatibility
|
||||
@Version("0.0.1")
|
||||
class ThemeLithoComponentsPatch : BytecodePatch(listOf(LithoThemeFingerprint)) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
LithoThemeFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
val patchIndex = it.scanResult.patternScanResult!!.endIndex - 1
|
||||
|
||||
addInstructions(
|
||||
patchIndex,
|
||||
"""
|
||||
invoke-static {p1}, $INTEGRATIONS_CLASS_DESCRIPTOR->getValue(I)I
|
||||
move-result p1
|
||||
"""
|
||||
)
|
||||
}
|
||||
} ?: return LithoThemeFingerprint.toErrorResult()
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
private companion object {
|
||||
private const val INTEGRATIONS_CLASS_DESCRIPTOR = "Lapp/revanced/integrations/patches/theme/ThemeLithoComponentsPatch;"
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,7 @@
|
||||
package app.revanced.patches.youtube.layout.theme.resource
|
||||
|
||||
import app.revanced.patcher.data.ResourceContext
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultError
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.ResourcePatch
|
||||
import app.revanced.patcher.patch.*
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch
|
||||
import app.revanced.patches.shared.settings.preference.impl.InputType
|
||||
@@ -28,19 +25,11 @@ class ThemeResourcePatch : ResourcePatch {
|
||||
"#FF0000",
|
||||
StringResource(
|
||||
"revanced_seekbar_color_summary",
|
||||
"The color of the seekbar for the dark theme."
|
||||
"The color of the seekbar"
|
||||
)
|
||||
),
|
||||
)
|
||||
|
||||
// Edit theme colors via bytecode.
|
||||
// For that the resource id is used in a bytecode patch to change the color.
|
||||
|
||||
inlineTimeBarColorizedBarPlayedColorDarkId = ResourceMappingPatch.resourceMappings
|
||||
.find { it.name == "inline_time_bar_colorized_bar_played_color_dark" }?.id
|
||||
?: return PatchResultError("Could not find seekbar resource")
|
||||
|
||||
|
||||
val darkThemeBackgroundColor = darkThemeBackgroundColor!!
|
||||
val lightThemeBackgroundColor = lightThemeBackgroundColor!!
|
||||
|
||||
@@ -72,7 +61,4 @@ class ThemeResourcePatch : ResourcePatch {
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
internal companion object {
|
||||
var inlineTimeBarColorizedBarPlayedColorDarkId = -1L
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ class VideoInformationPatch : BytecodePatch(
|
||||
playerInitMethod = mutableClass.methods.first { MethodUtil.isConstructor(it) }
|
||||
|
||||
// hook the player controller for use through integrations
|
||||
onCreateHook(INTEGRATIONS_CLASS_DESCRIPTOR, "playerController_onCreateHook")
|
||||
onCreateHook(INTEGRATIONS_CLASS_DESCRIPTOR, "initialize")
|
||||
|
||||
// seek method
|
||||
val seekFingerprintResultMethod = SeekFingerprint.also { it.resolve(context, classDef) }.result!!.method
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package app.revanced.patches.youtube.misc.video.speed
|
||||
|
||||
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.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.patches.youtube.misc.video.speed.custom.patch.CustomVideoSpeedPatch
|
||||
import app.revanced.patches.youtube.misc.video.speed.remember.patch.RememberPlaybackSpeedPatch
|
||||
|
||||
@Patch
|
||||
@Name("video-speed")
|
||||
@Description("Adds custom video speeds and ability to remember the playback speed you chose in the video playback speed flyout.")
|
||||
@DependsOn([CustomVideoSpeedPatch::class, RememberPlaybackSpeedPatch::class])
|
||||
@Version("0.0.1")
|
||||
class VideoSpeeds : BytecodePatch() {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
return PatchResultSuccess() // All sub patches succeeded.
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package app.revanced.patches.youtube.misc.video.speed.custom.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
||||
object VideoSpeedPatchFingerprint : MethodFingerprint(
|
||||
opcodes = listOf(Opcode.FILL_ARRAY_DATA),
|
||||
customFingerprint = { methodDef ->
|
||||
methodDef.definingClass.endsWith("CustomVideoSpeedPatch;") && methodDef.name == "<clinit>"
|
||||
}
|
||||
)
|
||||
@@ -8,37 +8,47 @@ import app.revanced.patcher.extensions.addInstructions
|
||||
import app.revanced.patcher.extensions.replaceInstruction
|
||||
import app.revanced.patcher.patch.*
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patches.shared.settings.preference.impl.InputType
|
||||
import app.revanced.patches.shared.settings.preference.impl.StringResource
|
||||
import app.revanced.patches.shared.settings.preference.impl.TextPreference
|
||||
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
||||
import app.revanced.patches.youtube.misc.video.speed.custom.annotations.CustomPlaybackSpeedCompatibility
|
||||
import app.revanced.patches.youtube.misc.video.speed.custom.fingerprints.SpeedArrayGeneratorFingerprint
|
||||
import app.revanced.patches.youtube.misc.video.speed.custom.fingerprints.SpeedLimiterFingerprint
|
||||
import app.revanced.patches.youtube.misc.video.speed.custom.fingerprints.VideoSpeedPatchFingerprint
|
||||
import org.jf.dexlib2.builder.instruction.BuilderArrayPayload
|
||||
import org.jf.dexlib2.iface.instruction.NarrowLiteralInstruction
|
||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
|
||||
import org.jf.dexlib2.iface.reference.FieldReference
|
||||
import org.jf.dexlib2.iface.reference.MethodReference
|
||||
import java.util.stream.DoubleStream
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
@Patch
|
||||
@Name("custom-video-speed")
|
||||
@Description("Adds more video speed options.")
|
||||
@Description("Adds custom video speed options.")
|
||||
@DependsOn([IntegrationsPatch::class])
|
||||
@CustomPlaybackSpeedCompatibility
|
||||
@Version("0.0.1")
|
||||
class CustomVideoSpeedPatch : BytecodePatch(
|
||||
listOf(
|
||||
SpeedArrayGeneratorFingerprint, SpeedLimiterFingerprint, VideoSpeedPatchFingerprint
|
||||
SpeedArrayGeneratorFingerprint, SpeedLimiterFingerprint
|
||||
)
|
||||
) {
|
||||
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
val speedLimitMin = minVideoSpeed!!.toFloat()
|
||||
val speedLimitMax = maxVideoSpeed!!.toFloat().coerceAtLeast(speedLimitMin)
|
||||
val speedsGranularity = videoSpeedsGranularity!!.toFloat()
|
||||
SettingsPatch.PreferenceScreen.MISC.addPreferences(
|
||||
TextPreference(
|
||||
key = "revanced_custom_video_speeds",
|
||||
title = StringResource(
|
||||
"revanced_custom_video_speeds_title",
|
||||
"Custom playback speeds"
|
||||
),
|
||||
inputType = InputType.TEXT_MULTI_LINE,
|
||||
summary = StringResource(
|
||||
"revanced_custom_video_speeds_summary",
|
||||
"Add or change the video speeds available"
|
||||
),
|
||||
default = "0.25\n0.5\n0.75\n0.9\n0.95\n1.0\n1.05\n1.1\n1.25\n1.5\n1.75\n2.0\n3.0\n4.0\n5.0"
|
||||
)
|
||||
)
|
||||
|
||||
val arrayGenMethod = SpeedArrayGeneratorFingerprint.result?.mutableMethod!!
|
||||
val arrayGenMethodImpl = arrayGenMethod.implementation!!
|
||||
@@ -61,7 +71,7 @@ class CustomVideoSpeedPatch : BytecodePatch(
|
||||
|
||||
val arrayLengthConstDestination = (arrayLengthConst as OneRegisterInstruction).registerA
|
||||
|
||||
val videoSpeedsArrayType = "Lapp/revanced/integrations/patches/playback/speed/CustomVideoSpeedPatch;->videoSpeeds:[F"
|
||||
val videoSpeedsArrayType = "Lapp/revanced/integrations/patches/playback/speed/CustomVideoSpeedPatch;->customVideoSpeeds:[F"
|
||||
|
||||
arrayGenMethod.addInstructions(
|
||||
arrayLengthConstIndex + 1,
|
||||
@@ -96,100 +106,17 @@ class CustomVideoSpeedPatch : BytecodePatch(
|
||||
val limiterMinConstDestination = (limiterMinConst as OneRegisterInstruction).registerA
|
||||
val limiterMaxConstDestination = (limiterMaxConst as OneRegisterInstruction).registerA
|
||||
|
||||
fun hexFloat(float: Float): String = "0x%08x".format(float.toRawBits())
|
||||
|
||||
// edit: alternatively this might work by overriding with fixed values such as 0.1x and 10x
|
||||
limiterMethod.replaceInstruction(
|
||||
limiterMinConstIndex,
|
||||
"const/high16 v$limiterMinConstDestination, ${hexFloat(speedLimitMin)}"
|
||||
"sget v$limiterMinConstDestination, Lapp/revanced/integrations/patches/playback/speed/CustomVideoSpeedPatch;->minVideoSpeed:F"
|
||||
)
|
||||
limiterMethod.replaceInstruction(
|
||||
limiterMaxConstIndex,
|
||||
"const/high16 v$limiterMaxConstDestination, ${hexFloat(speedLimitMax)}"
|
||||
)
|
||||
|
||||
val constructorResult = VideoSpeedPatchFingerprint.result!!
|
||||
val constructor = constructorResult.mutableMethod
|
||||
val implementation = constructor.implementation!!
|
||||
|
||||
val stepsGranularity = 8F
|
||||
val step = speedLimitMax
|
||||
.minus(speedLimitMin) // calculate the range of the speeds
|
||||
.div(speedsGranularity)
|
||||
.times(stepsGranularity)
|
||||
.roundToInt()
|
||||
.div(stepsGranularity)// round to nearest multiple of stepsGranularity
|
||||
.coerceAtLeast(1 / stepsGranularity) // ensure steps are at least 1/8th of the step granularity
|
||||
|
||||
val videoSpeedsArray = buildList<Number> {
|
||||
DoubleStream
|
||||
.iterate(speedLimitMin.toDouble()) { it + step } // create a stream of speeds
|
||||
.let { speedStream ->
|
||||
for (speed in speedStream) {
|
||||
if (speed > speedLimitMax) break
|
||||
add(speed.toFloat().toRawBits())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// adjust the new array of speeds size
|
||||
constructor.replaceInstruction(
|
||||
0,
|
||||
"const/16 v0, ${videoSpeedsArray.size}"
|
||||
)
|
||||
|
||||
// create the payload with the new speeds
|
||||
val arrayPayloadIndex = implementation.instructions.size - 1
|
||||
implementation.replaceInstruction(
|
||||
arrayPayloadIndex,
|
||||
BuilderArrayPayload(
|
||||
4,
|
||||
videoSpeedsArray
|
||||
)
|
||||
"sget v$limiterMaxConstDestination, Lapp/revanced/integrations/patches/playback/speed/CustomVideoSpeedPatch;->maxVideoSpeed:F"
|
||||
)
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
companion object : OptionsContainer() {
|
||||
private fun String?.validate(max: Int? = null) = this?.toFloatOrNull() != null &&
|
||||
toFloat().let { float ->
|
||||
float > 0 && max?.let { max -> float <= max } ?: true
|
||||
}
|
||||
|
||||
val videoSpeedsGranularity by option(
|
||||
PatchOption.StringOption(
|
||||
"granularity",
|
||||
"16",
|
||||
"Video speed granularity",
|
||||
"The granularity of the video speeds. The higher the value, the more speeds will be available.",
|
||||
true
|
||||
) {
|
||||
it.validate()
|
||||
}
|
||||
)
|
||||
|
||||
val minVideoSpeed by option(
|
||||
PatchOption.StringOption(
|
||||
"min",
|
||||
"0.25",
|
||||
"Minimum video speed",
|
||||
"The minimum video speed.",
|
||||
true
|
||||
) {
|
||||
it.validate()
|
||||
}
|
||||
)
|
||||
|
||||
val maxVideoSpeed by option(
|
||||
PatchOption.StringOption(
|
||||
"max",
|
||||
"5.0",
|
||||
"Maximum video speed",
|
||||
"The maximum video speed. Must be greater than the minimum video speed and smaller than 5.",
|
||||
true
|
||||
) {
|
||||
it.validate(5)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,13 +21,13 @@ import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
||||
import app.revanced.patches.youtube.misc.video.information.patch.VideoInformationPatch
|
||||
import app.revanced.patches.youtube.misc.video.information.patch.VideoInformationPatch.Companion.reference
|
||||
import app.revanced.patches.youtube.misc.video.speed.custom.patch.CustomVideoSpeedPatch
|
||||
import app.revanced.patches.youtube.misc.video.speed.remember.annotation.RememberPlaybackSpeedCompatibility
|
||||
import app.revanced.patches.youtube.misc.video.speed.remember.fingerprint.InitializePlaybackSpeedValuesFingerprint
|
||||
|
||||
@Patch
|
||||
@Name("remember-playback-speed")
|
||||
@Description("Adds the ability to remember the playback speed you chose in the video playback speed flyout.")
|
||||
@DependsOn([IntegrationsPatch::class, SettingsPatch::class, VideoInformationPatch::class])
|
||||
@DependsOn([IntegrationsPatch::class, SettingsPatch::class, VideoInformationPatch::class, CustomVideoSpeedPatch::class])
|
||||
@RememberPlaybackSpeedCompatibility
|
||||
@Version("0.0.1")
|
||||
class RememberPlaybackSpeedPatch : BytecodePatch(
|
||||
|
||||
16
src/main/kotlin/app/revanced/util/patch/BytecodeUtils.kt
Normal file
16
src/main/kotlin/app/revanced/util/patch/BytecodeUtils.kt
Normal file
@@ -0,0 +1,16 @@
|
||||
package app.revanced.util.patch
|
||||
|
||||
import org.jf.dexlib2.Opcode
|
||||
import org.jf.dexlib2.iface.Method
|
||||
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
|
||||
|
||||
/**
|
||||
* @return the first constant instruction with the resource id, or -1 if not found.
|
||||
*/
|
||||
fun Method.indexOfFirstConstantInstruction(constantValue: Long): Int {
|
||||
return implementation?.let {
|
||||
it.instructions.indexOfFirst { instruction ->
|
||||
instruction.opcode == Opcode.CONST && (instruction as WideLiteralInstruction).wideLiteral == constantValue
|
||||
}
|
||||
} ?: -1
|
||||
}
|
||||
Reference in New Issue
Block a user