mirror of
https://github.com/revanced/revanced-patches.git
synced 2025-12-25 10:24:08 +01:00
Compare commits
6 Commits
v2.173.0-d
...
v2.173.0-d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b680a4d1d3 | ||
|
|
3130c6ac72 | ||
|
|
f0c91102e1 | ||
|
|
eb93f149df | ||
|
|
24d2f11659 | ||
|
|
dc9575e52d |
21
CHANGELOG.md
21
CHANGELOG.md
@@ -1,3 +1,24 @@
|
||||
# [2.173.0-dev.5](https://github.com/revanced/revanced-patches/compare/v2.173.0-dev.4...v2.173.0-dev.5) (2023-05-02)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **youtube:** `navigation-buttons` patch ([4bece31](https://github.com/revanced/revanced-patches/commit/4bece31f56eb340933ad26da3d1bfc902ea8569f))
|
||||
|
||||
# [2.173.0-dev.4](https://github.com/revanced/revanced-patches/compare/v2.173.0-dev.3...v2.173.0-dev.4) (2023-05-02)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **youtube/create-button:** switch create with notifications button ([385ceda](https://github.com/revanced/revanced-patches/commit/385ceda61f586f24b11a284688f55758ef5b4e74))
|
||||
|
||||
# [2.173.0-dev.3](https://github.com/revanced/revanced-patches/compare/v2.173.0-dev.2...v2.173.0-dev.3) (2023-05-02)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **youtube/theme:** theme seekbar when clicked ([691a231](https://github.com/revanced/revanced-patches/commit/691a231d99b3b2fbe446fc7edb7a88c7a3127037))
|
||||
|
||||
# [2.173.0-dev.2](https://github.com/revanced/revanced-patches/compare/v2.173.0-dev.1...v2.173.0-dev.2) (2023-05-02)
|
||||
|
||||
|
||||
|
||||
@@ -31,7 +31,6 @@ The official Patch bundle provided by ReVanced and the community.
|
||||
| `hide-breaking-news-shelf` | Hides the breaking news shelf on the homepage tab. | 18.16.37 |
|
||||
| `hide-captions-button` | Hides the captions button on video player. | 18.16.37 |
|
||||
| `hide-cast-button` | Hides the cast button in the video player. | all |
|
||||
| `hide-create-button` | Hides the create button in the navigation bar. | 18.16.37 |
|
||||
| `hide-crowdfunding-box` | Hides the crowdfunding box between the player and video description. | 18.16.37 |
|
||||
| `hide-email-address` | Hides the email address in the account switcher. | 18.16.37 |
|
||||
| `hide-endscreen-cards` | Hides the suggested video cards at the end of a video in fullscreen. | 18.16.37 |
|
||||
@@ -41,12 +40,12 @@ The official Patch bundle provided by ReVanced and the community.
|
||||
| `hide-player-buttons` | Adds the option to hide video player previous and next buttons. | all |
|
||||
| `hide-player-overlay` | Hides the dark player overlay when player controls are visible. | all |
|
||||
| `hide-seekbar` | Hides the seekbar. | 18.16.37 |
|
||||
| `hide-shorts-button` | Hides the shorts button on the navigation bar. | 18.16.37 |
|
||||
| `hide-timestamp` | Hides timestamp in video player. | 18.16.37 |
|
||||
| `hide-video-action-buttons` | Adds the options to hide action buttons under a video. | 18.16.37 |
|
||||
| `hide-watch-in-vr` | Hides the option to watch in VR from the player settings flyout panel. | 18.16.37 |
|
||||
| `hide-watermark` | Hides creator's watermarks on videos. | 18.16.37 |
|
||||
| `minimized-playback` | Enables minimized and background playback. | 18.16.37 |
|
||||
| `navigation-buttons` | Adds options to hide or change navigation buttons. | 18.16.37 |
|
||||
| `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 |
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
kotlin.code.style = official
|
||||
version = 2.173.0-dev.2
|
||||
version = 2.173.0-dev.5
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,4 +1,4 @@
|
||||
package app.revanced.patches.youtube.layout.buttons.pivotbar.shared.annotations
|
||||
package app.revanced.patches.youtube.layout.buttons.navigation.annotations
|
||||
|
||||
import app.revanced.patcher.annotation.Compatibility
|
||||
import app.revanced.patcher.annotation.Package
|
||||
@@ -21,4 +21,4 @@ import app.revanced.patcher.annotation.Package
|
||||
)]
|
||||
)
|
||||
@Target(AnnotationTarget.CLASS)
|
||||
internal annotation class PivotBarCompatibility
|
||||
internal annotation class NavigationButtonsCompatibility
|
||||
@@ -0,0 +1,12 @@
|
||||
package app.revanced.patches.youtube.layout.buttons.navigation.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
|
||||
internal const val ANDROID_AUTOMOTIVE_STRING = "Android Automotive"
|
||||
|
||||
object AddCreateButtonViewFingerprint : MethodFingerprint(
|
||||
strings = listOf(
|
||||
"Android Wear",
|
||||
ANDROID_AUTOMOTIVE_STRING,
|
||||
)
|
||||
)
|
||||
@@ -1,7 +1,7 @@
|
||||
package app.revanced.patches.youtube.layout.buttons.pivotbar.shared.fingerprints
|
||||
package app.revanced.patches.youtube.layout.buttons.navigation.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import app.revanced.patches.youtube.layout.buttons.pivotbar.shared.patch.ResolvePivotBarFingerprintsPatch
|
||||
import app.revanced.patches.youtube.layout.buttons.navigation.patch.ResolvePivotBarFingerprintsPatch
|
||||
import org.jf.dexlib2.Opcode
|
||||
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package app.revanced.patches.youtube.layout.buttons.pivotbar.shorts.fingerprints
|
||||
package app.revanced.patches.youtube.layout.buttons.navigation.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
||||
object PivotBarShortsButtonViewFingerprint : MethodFingerprint(
|
||||
object PivotBarButtonsViewFingerprint : MethodFingerprint(
|
||||
opcodes = listOf(
|
||||
Opcode.INVOKE_VIRTUAL_RANGE,
|
||||
Opcode.MOVE_RESULT_OBJECT, // target reference
|
||||
@@ -1,4 +1,4 @@
|
||||
package app.revanced.patches.youtube.layout.buttons.pivotbar.shared.fingerprints
|
||||
package app.revanced.patches.youtube.layout.buttons.navigation.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
@@ -1,4 +1,4 @@
|
||||
package app.revanced.patches.youtube.layout.buttons.pivotbar.create.fingerprints
|
||||
package app.revanced.patches.youtube.layout.buttons.navigation.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import org.jf.dexlib2.Opcode
|
||||
@@ -1,4 +1,4 @@
|
||||
package app.revanced.patches.youtube.layout.buttons.pivotbar.shorts.fingerprints
|
||||
package app.revanced.patches.youtube.layout.buttons.navigation.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import org.jf.dexlib2.Opcode
|
||||
@@ -0,0 +1,196 @@
|
||||
package app.revanced.patches.youtube.layout.buttons.navigation.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.extensions.instruction
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
|
||||
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.shared.settings.preference.impl.PreferenceScreen
|
||||
import app.revanced.patches.shared.settings.preference.impl.StringResource
|
||||
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
|
||||
import app.revanced.patches.youtube.layout.buttons.navigation.annotations.NavigationButtonsCompatibility
|
||||
import app.revanced.patches.youtube.layout.buttons.navigation.fingerprints.*
|
||||
import app.revanced.patches.youtube.layout.buttons.navigation.utils.InjectionUtils.REGISTER_TEMPLATE_REPLACEMENT
|
||||
import app.revanced.patches.youtube.layout.buttons.navigation.utils.InjectionUtils.injectHook
|
||||
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
||||
import org.jf.dexlib2.Opcode
|
||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
|
||||
@Patch
|
||||
@DependsOn(
|
||||
[
|
||||
IntegrationsPatch::class,
|
||||
SettingsPatch::class,
|
||||
ResolvePivotBarFingerprintsPatch::class,
|
||||
]
|
||||
)
|
||||
@Name("navigation-buttons")
|
||||
@Description("Adds options to hide or change navigation buttons.")
|
||||
@NavigationButtonsCompatibility
|
||||
@Version("0.0.1")
|
||||
class NavigationButtonsPatch : BytecodePatch(listOf(AddCreateButtonViewFingerprint)) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
|
||||
PreferenceScreen(
|
||||
"revanced_navigation_buttons",
|
||||
StringResource("revanced_navigation_buttons", "Navigation button settings"),
|
||||
listOf(
|
||||
SwitchPreference(
|
||||
"revanced_hide_home_button",
|
||||
StringResource("revanced_hide_home_button_title", "Hide home button"),
|
||||
false,
|
||||
StringResource("revanced_hide_home_button_summary_on", "Home button is hidden"),
|
||||
StringResource("revanced_hide_home_button_summary_off", "Home button is shown")
|
||||
),
|
||||
SwitchPreference(
|
||||
"revanced_hide_shorts_button",
|
||||
StringResource("revanced_hide_shorts_button_title", "Hide shorts button"),
|
||||
true,
|
||||
StringResource("revanced_hide_shorts_button_summary_on", "Shorts button is hidden"),
|
||||
StringResource("revanced_hide_shorts_button_summary_off", "Shorts button is shown")
|
||||
),
|
||||
SwitchPreference(
|
||||
"revanced_hide_subscriptions_button",
|
||||
StringResource("revanced_hide_subscriptions_button_title", "Hide subscriptions button"),
|
||||
false,
|
||||
StringResource(
|
||||
"revanced_hide_subscriptions_button_summary_on",
|
||||
"Home subscriptions is hidden"
|
||||
),
|
||||
StringResource("revanced_hide_subscriptions_button_summary_off", "Home subscriptions is shown")
|
||||
),
|
||||
SwitchPreference(
|
||||
"revanced_hide_create_button",
|
||||
StringResource("revanced_hide_create_button_title", "Hide create button"),
|
||||
true,
|
||||
StringResource("revanced_hide_create_button_summary_on", "Create button is hidden"),
|
||||
StringResource("revanced_hide_create_button_summary_off", "Create button is shown")
|
||||
),
|
||||
SwitchPreference(
|
||||
"revanced_switch_create_with_notifications_button",
|
||||
StringResource(
|
||||
"revanced_switch_create_with_notifications_button_title",
|
||||
"Switch create with notifications button"
|
||||
),
|
||||
true,
|
||||
StringResource(
|
||||
"revanced_switch_create_with_notifications_button_summary_on",
|
||||
"Create button is switched with notifications"
|
||||
),
|
||||
StringResource(
|
||||
"revanced_switch_create_with_notifications_button_summary_off",
|
||||
"Create button is not switched with notifications"
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
/*
|
||||
* Resolve fingerprints
|
||||
*/
|
||||
|
||||
val initializeButtonsResult = InitializeButtonsFingerprint.result!!
|
||||
|
||||
val fingerprintResults =
|
||||
arrayOf(PivotBarEnumFingerprint, PivotBarButtonsViewFingerprint)
|
||||
.onEach {
|
||||
if (!it.resolve(
|
||||
context,
|
||||
initializeButtonsResult.mutableMethod,
|
||||
initializeButtonsResult.mutableClass
|
||||
)
|
||||
)
|
||||
return it.toErrorResult()
|
||||
}
|
||||
.map { it.result!!.scanResult.patternScanResult!! }
|
||||
|
||||
|
||||
val enumScanResult = fingerprintResults[0]
|
||||
val buttonViewResult = fingerprintResults[1]
|
||||
|
||||
val enumHookInsertIndex = enumScanResult.startIndex + 2
|
||||
val buttonHookInsertIndex = buttonViewResult.endIndex
|
||||
|
||||
/*
|
||||
* Inject hooks
|
||||
*/
|
||||
|
||||
val enumHook = "sput-object v$REGISTER_TEMPLATE_REPLACEMENT, " +
|
||||
"$INTEGRATIONS_CLASS_DESCRIPTOR->lastNavigationButton:Ljava/lang/Enum;"
|
||||
val buttonHook = "invoke-static { v$REGISTER_TEMPLATE_REPLACEMENT }, " +
|
||||
"$INTEGRATIONS_CLASS_DESCRIPTOR->hideButton(Landroid/view/View;)V"
|
||||
|
||||
// Inject bottom to top to not mess up the indices
|
||||
mapOf(
|
||||
buttonHook to buttonHookInsertIndex,
|
||||
enumHook to enumHookInsertIndex
|
||||
).forEach { (hook, insertIndex) ->
|
||||
initializeButtonsResult.mutableMethod.injectHook(hook, insertIndex)
|
||||
}
|
||||
|
||||
/*
|
||||
* Hide create or switch it with notifications buttons.
|
||||
*/
|
||||
|
||||
AddCreateButtonViewFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
val stringIndex = it.scanResult.stringsScanResult!!.matches.find {
|
||||
match -> match.string == ANDROID_AUTOMOTIVE_STRING
|
||||
}!!.index
|
||||
|
||||
val conditionalCheckIndex = stringIndex - 1
|
||||
val conditionRegister = (instruction(conditionalCheckIndex) as OneRegisterInstruction).registerA
|
||||
|
||||
addInstructions(
|
||||
conditionalCheckIndex,
|
||||
"""
|
||||
invoke-static { }, $INTEGRATIONS_CLASS_DESCRIPTOR->switchCreateWithNotificationButton()Z
|
||||
move-result v$conditionRegister
|
||||
"""
|
||||
)
|
||||
}
|
||||
} ?: return AddCreateButtonViewFingerprint.toErrorResult()
|
||||
|
||||
/*
|
||||
* Resolve fingerprints
|
||||
*/
|
||||
|
||||
InitializeButtonsFingerprint.result!!.let {
|
||||
if (!PivotBarCreateButtonViewFingerprint.resolve(context, it.mutableMethod, it.mutableClass))
|
||||
return PivotBarCreateButtonViewFingerprint.toErrorResult()
|
||||
}
|
||||
|
||||
PivotBarCreateButtonViewFingerprint.result!!.apply {
|
||||
val insertIndex = mutableMethod.implementation!!.instructions.let {
|
||||
val scanStart = scanResult.patternScanResult!!.endIndex
|
||||
|
||||
scanStart + it.subList(scanStart, it.size - 1).indexOfFirst { instruction ->
|
||||
instruction.opcode == Opcode.INVOKE_STATIC
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Inject hooks
|
||||
*/
|
||||
val hook = "invoke-static { v$REGISTER_TEMPLATE_REPLACEMENT }, " +
|
||||
"$INTEGRATIONS_CLASS_DESCRIPTOR->hideCreateButton(Landroid/view/View;)V"
|
||||
|
||||
mutableMethod.injectHook(hook, insertIndex)
|
||||
}
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
private companion object {
|
||||
const val INTEGRATIONS_CLASS_DESCRIPTOR = "Lapp/revanced/integrations/patches/NavigationButtonsPatch;"
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package app.revanced.patches.youtube.layout.buttons.pivotbar.shared.patch
|
||||
package app.revanced.patches.youtube.layout.buttons.navigation.patch
|
||||
|
||||
import app.revanced.extensions.toErrorResult
|
||||
import app.revanced.patcher.annotation.Description
|
||||
@@ -11,21 +11,15 @@ import app.revanced.patcher.patch.PatchResultError
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch
|
||||
import app.revanced.patches.youtube.layout.buttons.pivotbar.shared.annotations.PivotBarCompatibility
|
||||
import app.revanced.patches.youtube.layout.buttons.pivotbar.shared.fingerprints.InitializeButtonsFingerprint
|
||||
import app.revanced.patches.youtube.layout.buttons.pivotbar.shared.fingerprints.PivotBarConstructorFingerprint
|
||||
import app.revanced.patches.youtube.layout.buttons.navigation.fingerprints.InitializeButtonsFingerprint
|
||||
import app.revanced.patches.youtube.layout.buttons.navigation.fingerprints.PivotBarConstructorFingerprint
|
||||
|
||||
@DependsOn([ResourceMappingPatch::class])
|
||||
@PivotBarCompatibility
|
||||
@Description("Resolves necessary fingerprints.")
|
||||
@Version("0.0.1")
|
||||
class ResolvePivotBarFingerprintsPatch : BytecodePatch(
|
||||
listOf(PivotBarConstructorFingerprint)
|
||||
) {
|
||||
internal companion object {
|
||||
var imageOnlyTabResourceId: Long = -1
|
||||
}
|
||||
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
// imageOnlyTabResourceId is used in InitializeButtonsFingerprint fingerprint
|
||||
ResourceMappingPatch.resourceMappings.find { it.type == "layout" && it.name == "image_only_tab" }
|
||||
@@ -42,4 +36,8 @@ class ResolvePivotBarFingerprintsPatch : BytecodePatch(
|
||||
} ?: return PivotBarConstructorFingerprint.toErrorResult()
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
internal companion object {
|
||||
var imageOnlyTabResourceId: Long = -1
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package app.revanced.patches.youtube.layout.buttons.pivotbar.utils
|
||||
package app.revanced.patches.youtube.layout.buttons.navigation.utils
|
||||
|
||||
import app.revanced.patcher.extensions.addInstruction
|
||||
import app.revanced.patcher.extensions.instruction
|
||||
@@ -1,79 +0,0 @@
|
||||
package app.revanced.patches.youtube.layout.buttons.pivotbar.create.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.fingerprint.method.impl.MethodFingerprint.Companion.resolve
|
||||
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.shared.mapping.misc.patch.ResourceMappingPatch
|
||||
import app.revanced.patches.shared.settings.preference.impl.StringResource
|
||||
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
|
||||
import app.revanced.patches.youtube.layout.buttons.pivotbar.create.fingerprints.PivotBarCreateButtonViewFingerprint
|
||||
import app.revanced.patches.youtube.layout.buttons.pivotbar.shared.annotations.PivotBarCompatibility
|
||||
import app.revanced.patches.youtube.layout.buttons.pivotbar.shared.fingerprints.InitializeButtonsFingerprint
|
||||
import app.revanced.patches.youtube.layout.buttons.pivotbar.shared.patch.ResolvePivotBarFingerprintsPatch
|
||||
import app.revanced.patches.youtube.layout.buttons.pivotbar.utils.InjectionUtils.REGISTER_TEMPLATE_REPLACEMENT
|
||||
import app.revanced.patches.youtube.layout.buttons.pivotbar.utils.InjectionUtils.injectHook
|
||||
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
||||
@Patch
|
||||
@DependsOn([IntegrationsPatch::class, ResourceMappingPatch::class, SettingsPatch::class, ResolvePivotBarFingerprintsPatch::class])
|
||||
@Name("hide-create-button")
|
||||
@Description("Hides the create button in the navigation bar.")
|
||||
@PivotBarCompatibility
|
||||
@Version("0.0.1")
|
||||
class CreateButtonRemoverPatch : BytecodePatch() {
|
||||
private companion object {
|
||||
const val INTEGRATIONS_CLASS_DESCRIPTOR = "Lapp/revanced/integrations/patches/HideCreateButtonPatch;"
|
||||
}
|
||||
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
|
||||
SwitchPreference(
|
||||
"revanced_hide_create_button",
|
||||
StringResource("revanced_hide_create_button_title", "Hide create button"),
|
||||
true,
|
||||
StringResource("revanced_hide_create_button_summary_on", "Create button is hidden"),
|
||||
StringResource("revanced_hide_create_button_summary_off", "Create button is shown")
|
||||
)
|
||||
)
|
||||
|
||||
/*
|
||||
* Resolve fingerprints
|
||||
*/
|
||||
|
||||
InitializeButtonsFingerprint.result!!.let {
|
||||
if (!PivotBarCreateButtonViewFingerprint.resolve(context, it.mutableMethod, it.mutableClass))
|
||||
return PivotBarCreateButtonViewFingerprint.toErrorResult()
|
||||
}
|
||||
|
||||
PivotBarCreateButtonViewFingerprint.result!!.apply {
|
||||
val insertIndex = mutableMethod.implementation!!.instructions.let {
|
||||
val scanStart = scanResult.patternScanResult!!.endIndex
|
||||
|
||||
scanStart + it.subList(scanStart, it.size - 1).indexOfFirst { instruction ->
|
||||
instruction.opcode == Opcode.INVOKE_STATIC
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Inject hooks
|
||||
*/
|
||||
val hook = "invoke-static { v$REGISTER_TEMPLATE_REPLACEMENT }, " +
|
||||
"$INTEGRATIONS_CLASS_DESCRIPTOR->hideCreateButton(Landroid/view/View;)V"
|
||||
|
||||
mutableMethod.injectHook(hook, insertIndex)
|
||||
}
|
||||
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
package app.revanced.patches.youtube.layout.buttons.pivotbar.shorts.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.fingerprint.method.impl.MethodFingerprint.Companion.resolve
|
||||
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.shared.settings.preference.impl.StringResource
|
||||
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
|
||||
import app.revanced.patches.youtube.layout.buttons.pivotbar.shared.annotations.PivotBarCompatibility
|
||||
import app.revanced.patches.youtube.layout.buttons.pivotbar.shared.fingerprints.InitializeButtonsFingerprint
|
||||
import app.revanced.patches.youtube.layout.buttons.pivotbar.shared.patch.ResolvePivotBarFingerprintsPatch
|
||||
import app.revanced.patches.youtube.layout.buttons.pivotbar.shorts.fingerprints.PivotBarEnumFingerprint
|
||||
import app.revanced.patches.youtube.layout.buttons.pivotbar.shorts.fingerprints.PivotBarShortsButtonViewFingerprint
|
||||
import app.revanced.patches.youtube.layout.buttons.pivotbar.utils.InjectionUtils.REGISTER_TEMPLATE_REPLACEMENT
|
||||
import app.revanced.patches.youtube.layout.buttons.pivotbar.utils.InjectionUtils.injectHook
|
||||
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, ResolvePivotBarFingerprintsPatch::class])
|
||||
@Name("hide-shorts-button")
|
||||
@Description("Hides the shorts button on the navigation bar.")
|
||||
@PivotBarCompatibility
|
||||
@Version("0.0.1")
|
||||
class ShortsButtonRemoverPatch : BytecodePatch() {
|
||||
private companion object {
|
||||
const val INTEGRATIONS_CLASS_DESCRIPTOR = "Lapp/revanced/integrations/patches/HideShortsButtonPatch;"
|
||||
}
|
||||
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
|
||||
SwitchPreference(
|
||||
"revanced_hide_shorts_button",
|
||||
StringResource("revanced_hide_shorts_button_title", "Hide shorts button"),
|
||||
true,
|
||||
StringResource("revanced_hide_shorts_button_summary_on", "Shorts button is hidden"),
|
||||
StringResource("revanced_hide_shorts_button_summary_off", "Shorts button is shown")
|
||||
)
|
||||
)
|
||||
|
||||
/*
|
||||
* Resolve fingerprints
|
||||
*/
|
||||
|
||||
val initializeButtonsResult = InitializeButtonsFingerprint.result!!
|
||||
|
||||
val fingerprintResults =
|
||||
arrayOf(PivotBarEnumFingerprint, PivotBarShortsButtonViewFingerprint)
|
||||
.onEach {
|
||||
if (!it.resolve(
|
||||
context,
|
||||
initializeButtonsResult.mutableMethod,
|
||||
initializeButtonsResult.mutableClass
|
||||
)
|
||||
)
|
||||
return it.toErrorResult()
|
||||
}
|
||||
.map { it.result!!.scanResult.patternScanResult!! }
|
||||
|
||||
|
||||
val enumScanResult = fingerprintResults[0]
|
||||
val buttonViewResult = fingerprintResults[1]
|
||||
|
||||
val enumHookInsertIndex = enumScanResult.startIndex + 2
|
||||
val buttonHookInsertIndex = buttonViewResult.endIndex
|
||||
|
||||
/*
|
||||
* Inject hooks
|
||||
*/
|
||||
|
||||
val enumHook = "sput-object v$REGISTER_TEMPLATE_REPLACEMENT, " +
|
||||
"$INTEGRATIONS_CLASS_DESCRIPTOR->lastPivotTab:Ljava/lang/Enum;"
|
||||
val buttonHook = "invoke-static { v$REGISTER_TEMPLATE_REPLACEMENT }, " +
|
||||
"$INTEGRATIONS_CLASS_DESCRIPTOR->hideShortsButton(Landroid/view/View;)V"
|
||||
|
||||
// Inject bottom to top to not mess up the indices
|
||||
mapOf(
|
||||
buttonHook to buttonHookInsertIndex,
|
||||
enumHook to enumHookInsertIndex
|
||||
).forEach { (hook, insertIndex) ->
|
||||
initializeButtonsResult.mutableMethod.injectHook(hook, insertIndex)
|
||||
}
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package app.revanced.patches.youtube.layout.theme.bytecode.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
||||
object SetSeekbarClickedColorFingerprint : MethodFingerprint(
|
||||
opcodes = listOf(Opcode.CONST_HIGH16),
|
||||
strings = listOf("YOUTUBE", "PREROLL", "POSTROLL")
|
||||
)
|
||||
@@ -5,6 +5,7 @@ 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.BytecodePatch
|
||||
@@ -12,9 +13,11 @@ 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.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.theme.resource.ThemeResourcePatch
|
||||
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||
import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction
|
||||
@@ -25,7 +28,9 @@ import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction
|
||||
@DependsOn([ThemeLithoComponentsPatch::class, ThemeResourcePatch::class, IntegrationsPatch::class])
|
||||
@ThemeCompatibility
|
||||
@Version("0.0.1")
|
||||
class ThemeBytecodePatch : BytecodePatch(listOf(CreateDarkThemeSeekbarFingerprint)) {
|
||||
class ThemeBytecodePatch : BytecodePatch(
|
||||
listOf(CreateDarkThemeSeekbarFingerprint, SetSeekbarClickedColorFingerprint)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
CreateDarkThemeSeekbarFingerprint.result?.let {
|
||||
val putColorValueIndex = it.method.indexOfInstructionWithSeekbarId!! + 3
|
||||
@@ -42,6 +47,27 @@ class ThemeBytecodePatch : BytecodePatch(listOf(CreateDarkThemeSeekbarFingerprin
|
||||
)
|
||||
}
|
||||
} ?: 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->getSeekbarClickedColorValue(I)I
|
||||
move-result v$colorRegister
|
||||
"""
|
||||
)
|
||||
}
|
||||
}
|
||||
} ?: return SetSeekbarClickedColorFingerprint.toErrorResult()
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user