chore: merge branch dev to main (#1441)

This commit is contained in:
oSumAtrIX 2023-01-07 09:47:33 +01:00 committed by GitHub
commit 67e18b6fde
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 278 additions and 68 deletions

View file

@ -1,3 +1,18 @@
# [2.153.0-dev.1](https://github.com/revanced/revanced-patches/compare/v2.152.1-dev.1...v2.153.0-dev.1) (2023-01-07)
### Features
* **youtube/remember-video-quality:** simplify settings switch state description ([9bd42ec](https://github.com/revanced/revanced-patches/commit/9bd42ec1a1b54b103cd2550211515acdaf90e9de))
* **youtube:** `remember-playback-rate` patch ([177e908](https://github.com/revanced/revanced-patches/commit/177e908dba260f184a2835b73b834563ca9c29fd))
## [2.152.1-dev.1](https://github.com/revanced/revanced-patches/compare/v2.152.0...v2.152.1-dev.1) (2023-01-07)
### Bug Fixes
* **youtube/general-ads:** move settings to correct preference screens ([cde45fc](https://github.com/revanced/revanced-patches/commit/cde45fca769eddea64072f13f836d46560a4a89a))
# [2.152.0](https://github.com/revanced/revanced-patches/compare/v2.151.0...v2.152.0) (2023-01-04) # [2.152.0](https://github.com/revanced/revanced-patches/compare/v2.151.0...v2.152.0) (2023-01-04)

View file

@ -48,6 +48,7 @@ The official Patch bundle provided by ReVanced and the community.
| `old-quality-layout` | Enables the original video quality flyout in the video player settings | 17.49.37 | | `old-quality-layout` | Enables the original video quality flyout in the video player settings | 17.49.37 |
| `open-links-directly` | Bypasses URL redirects and opens links directly inside YouTube app. | 17.49.37 | | `open-links-directly` | Bypasses URL redirects and opens links directly inside YouTube app. | 17.49.37 |
| `premium-heading` | Shows premium branding on the home screen. | all | | `premium-heading` | Shows premium branding on the home screen. | all |
| `remember-playback-rate` | Adds the ability to remember the playback rate you chose in the video playback rate flyout. | 17.49.37 |
| `remember-video-quality` | Adds the ability to remember the video quality you chose in the video quality flyout. | 17.49.37 | | `remember-video-quality` | Adds the ability to remember the video quality you chose in the video quality flyout. | 17.49.37 |
| `remove-player-button-background` | Removes the background from the video player buttons. | 17.49.37 | | `remove-player-button-background` | Removes the background from the video player buttons. | 17.49.37 |
| `return-youtube-dislike` | Shows the dislike count of videos using the Return YouTube Dislike API. | 17.49.37 | | `return-youtube-dislike` | Shows the dislike count of videos using the Return YouTube Dislike API. | 17.49.37 |

View file

@ -1,2 +1,2 @@
kotlin.code.style = official kotlin.code.style = official
version = 2.152.0 version = 2.153.0-dev.1

File diff suppressed because one or more lines are too long

View file

@ -7,22 +7,21 @@ import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch
import app.revanced.patches.shared.settings.preference.impl.InputType import app.revanced.patches.shared.settings.preference.impl.*
import app.revanced.patches.shared.settings.preference.impl.StringResource
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
import app.revanced.patches.shared.settings.preference.impl.TextPreference
import app.revanced.patches.youtube.ad.general.annotation.GeneralAdsCompatibility import app.revanced.patches.youtube.ad.general.annotation.GeneralAdsCompatibility
import app.revanced.patches.youtube.misc.litho.filter.patch.LithoFilterPatch import app.revanced.patches.youtube.misc.litho.filter.patch.LithoFilterPatch
import app.revanced.patches.youtube.misc.manifest.patch.FixLocaleConfigErrorPatch import app.revanced.patches.youtube.misc.manifest.patch.FixLocaleConfigErrorPatch
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch.PreferenceScreen import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch.PreferenceScreen
@DependsOn(dependencies = [ @DependsOn(
FixLocaleConfigErrorPatch::class, dependencies = [
LithoFilterPatch::class, FixLocaleConfigErrorPatch::class,
SettingsPatch::class, LithoFilterPatch::class,
ResourceMappingPatch::class SettingsPatch::class,
]) ResourceMappingPatch::class
]
)
@GeneralAdsCompatibility @GeneralAdsCompatibility
@Version("0.0.1") @Version("0.0.1")
class GeneralAdsResourcePatch : ResourcePatch { class GeneralAdsResourcePatch : ResourcePatch {
@ -32,20 +31,42 @@ class GeneralAdsResourcePatch : ResourcePatch {
} }
override fun execute(context: ResourceContext): PatchResult { override fun execute(context: ResourceContext): PatchResult {
PreferenceScreen.ADS.addPreferences( PreferenceScreen.LAYOUT.addPreferences(
SwitchPreference( SwitchPreference(
"revanced_adremover_ad_removal", "revanced_adremover_separator",
StringResource("revanced_adremover_ad_removal_enabled_title", "Hide general ads"), StringResource("revanced_adremover_separator_title", "Hide gray separator"),
true, true,
StringResource("revanced_adremover_ad_removal_enabled_summary_on", "General ads are hidden"), StringResource("revanced_adremover_separator_summary_on", "Gray separators are hidden"),
StringResource("revanced_adremover_ad_removal_enabled_summary_off", "General ads are shown") StringResource("revanced_adremover_separator_summary_off", "Gray separators are shown")
), ),
SwitchPreference( SwitchPreference(
"revanced_adremover_buttoned", "revanced_adremover_hide_channel_guidelines",
StringResource("revanced_adremover_buttoned_enabled_title", "Hide buttoned ad"), StringResource("revanced_adremover_hide_channel_guidelines_enabled_title", "Hide channel guidelines"),
true, true,
StringResource("revanced_adremover_buttoned_enabled_summary_on", "Buttoned ads are hidden"), StringResource(
StringResource("revanced_adremover_buttoned_enabled_summary_off", "Buttoned ads are shown") "revanced_adremover_hide_channel_guidelines_enabled_summary_on",
"Channel guidelines are hidden"
),
StringResource(
"revanced_adremover_hide_channel_guidelines_enabled_summary_off",
"Channel guidelines are shown"
)
),
SwitchPreference(
"revanced_adremover_chapter_teaser",
StringResource(
"revanced_adremover_chapter_teaser_enabled_title",
"Hide chapter teaser under videos"
),
true,
StringResource(
"revanced_adremover_chapter_teaser_enabled_summary_on",
"Chapter teasers are hidden"
),
StringResource(
"revanced_adremover_chapter_teaser_enabled_summary_off",
"Chapter teasers are shown"
)
), ),
SwitchPreference( SwitchPreference(
"revanced_adremover_merchandise", "revanced_adremover_merchandise",
@ -104,17 +125,32 @@ class GeneralAdsResourcePatch : ResourcePatch {
), ),
SwitchPreference( SwitchPreference(
"revanced_adremover_subscribers_community_guidelines_removal", "revanced_adremover_subscribers_community_guidelines_removal",
StringResource("revanced_adremover_subscribers_community_guidelines_enabled_title", "Hide subscribers community guidelines"), StringResource(
"revanced_adremover_subscribers_community_guidelines_enabled_title",
"Hide subscribers community guidelines"
),
true, true,
StringResource("revanced_adremover_subscribers_community_guidelines_enabled_summary_on", "Subscribers community guidelines are hidden"), StringResource(
StringResource("revanced_adremover_subscribers_community_guidelines_enabled_summary_off", "Subscribers community guidelines are shown") "revanced_adremover_subscribers_community_guidelines_enabled_summary_on",
"Subscribers community guidelines are hidden"
),
StringResource(
"revanced_adremover_subscribers_community_guidelines_enabled_summary_off",
"Subscribers community guidelines are shown"
)
), ),
SwitchPreference( SwitchPreference(
"revanced_adremover_channel_member_shelf_removal", "revanced_adremover_channel_member_shelf_removal",
StringResource("revanced_adremover_channel_member_shelf_enabled_title", "Hide channel member shelf"), StringResource("revanced_adremover_channel_member_shelf_enabled_title", "Hide channel member shelf"),
true, true,
StringResource("revanced_adremover_channel_member_shelf_enabled_summary_on", "Channel member shelf is hidden"), StringResource(
StringResource("revanced_adremover_channel_member_shelf_enabled_summary_off", "Channel member shelf is shown") "revanced_adremover_channel_member_shelf_enabled_summary_on",
"Channel member shelf is hidden"
),
StringResource(
"revanced_adremover_channel_member_shelf_enabled_summary_off",
"Channel member shelf is shown"
)
), ),
SwitchPreference( SwitchPreference(
"revanced_adremover_emergency_box_removal", "revanced_adremover_emergency_box_removal",
@ -137,6 +173,23 @@ class GeneralAdsResourcePatch : ResourcePatch {
StringResource("revanced_adremover_medical_panel_enabled_summary_on", "Medical panels are hidden"), StringResource("revanced_adremover_medical_panel_enabled_summary_on", "Medical panels are hidden"),
StringResource("revanced_adremover_medical_panel_enabled_summary_off", "Medical panels are shown") StringResource("revanced_adremover_medical_panel_enabled_summary_off", "Medical panels are shown")
), ),
)
PreferenceScreen.ADS.addPreferences(
SwitchPreference(
"revanced_adremover_ad_removal",
StringResource("revanced_adremover_ad_removal_enabled_title", "Hide general ads"),
true,
StringResource("revanced_adremover_ad_removal_enabled_summary_on", "General ads are hidden"),
StringResource("revanced_adremover_ad_removal_enabled_summary_off", "General ads are shown")
),
SwitchPreference(
"revanced_adremover_buttoned",
StringResource("revanced_adremover_buttoned_enabled_title", "Hide buttoned ad"),
true,
StringResource("revanced_adremover_buttoned_enabled_summary_on", "Buttoned ads are hidden"),
StringResource("revanced_adremover_buttoned_enabled_summary_off", "Buttoned ads are shown")
),
SwitchPreference( SwitchPreference(
"revanced_adremover_paid_content", "revanced_adremover_paid_content",
StringResource("revanced_adremover_paid_content_enabled_title", "Hide paid content"), StringResource("revanced_adremover_paid_content_enabled_title", "Hide paid content"),
@ -158,19 +211,6 @@ class GeneralAdsResourcePatch : ResourcePatch {
StringResource("revanced_adremover_hide_latest_posts_enabled_summary_on", "Latest posts are hidden"), StringResource("revanced_adremover_hide_latest_posts_enabled_summary_on", "Latest posts are hidden"),
StringResource("revanced_adremover_hide_latest_posts_enabled_summary_off", "Latest posts are shown") StringResource("revanced_adremover_hide_latest_posts_enabled_summary_off", "Latest posts are shown")
), ),
SwitchPreference(
"revanced_adremover_hide_channel_guidelines",
StringResource("revanced_adremover_hide_channel_guidelines_enabled_title", "Hide channel guidelines"),
true,
StringResource(
"revanced_adremover_hide_channel_guidelines_enabled_summary_on",
"Channel guidelines are hidden"
),
StringResource(
"revanced_adremover_hide_channel_guidelines_enabled_summary_off",
"Channel guidelines are shown"
)
),
SwitchPreference( SwitchPreference(
"revanced_adremover_self_sponsor", "revanced_adremover_self_sponsor",
StringResource("revanced_adremover_self_sponsor_enabled_title", "Hide self sponsored cards"), StringResource("revanced_adremover_self_sponsor_enabled_title", "Hide self sponsored cards"),
@ -178,30 +218,7 @@ class GeneralAdsResourcePatch : ResourcePatch {
StringResource("revanced_adremover_self_sponsor_enabled_summary_on", "Self sponsored cards are hidden"), StringResource("revanced_adremover_self_sponsor_enabled_summary_on", "Self sponsored cards are hidden"),
StringResource("revanced_adremover_self_sponsor_enabled_summary_off", "Self sponsored cards are shown") StringResource("revanced_adremover_self_sponsor_enabled_summary_off", "Self sponsored cards are shown")
), ),
SwitchPreference( PreferenceScreen(
"revanced_adremover_separator",
StringResource("revanced_adremover_separator_title", "Hide gray separator"),
true,
StringResource("revanced_adremover_separator_summary_on", "Gray separators are hidden"),
StringResource("revanced_adremover_separator_summary_off", "Gray separators are shown")
),
SwitchPreference(
"revanced_adremover_chapter_teaser",
StringResource(
"revanced_adremover_chapter_teaser_enabled_title",
"Hide chapter teaser under videos"
),
true,
StringResource(
"revanced_adremover_chapter_teaser_enabled_summary_on",
"Chapter teasers are hidden"
),
StringResource(
"revanced_adremover_chapter_teaser_enabled_summary_off",
"Chapter teasers are shown"
)
),
app.revanced.patches.shared.settings.preference.impl.PreferenceScreen(
"revanced_adremover_custom", "revanced_adremover_custom",
StringResource("revanced_adremover_custom_title", "Custom filter"), StringResource("revanced_adremover_custom_title", "Custom filter"),
listOf( listOf(
@ -221,7 +238,7 @@ class GeneralAdsResourcePatch : ResourcePatch {
"Custom filter is disabled" "Custom filter is disabled"
) )
), ),
// TODO: This should be a ListPreference, which does not exist yet // TODO: This should be a dynamic ListPreference, which does not exist yet
TextPreference( TextPreference(
"revanced_adremover_custom_strings", "revanced_adremover_custom_strings",
StringResource("revanced_adremover_custom_strings_title", "Custom filter"), StringResource("revanced_adremover_custom_strings_title", "Custom filter"),

View file

@ -12,14 +12,14 @@ import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch 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.misc.integrations.patch.IntegrationsPatch 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.quality.annotations.RememberVideoQualityCompatibility import app.revanced.patches.youtube.misc.video.quality.annotations.RememberVideoQualityCompatibility
import app.revanced.patches.youtube.misc.video.quality.fingerprints.VideoQualityReferenceFingerprint import app.revanced.patches.youtube.misc.video.quality.fingerprints.VideoQualityReferenceFingerprint
import app.revanced.patches.youtube.misc.video.quality.fingerprints.VideoQualitySetterFingerprint import app.revanced.patches.youtube.misc.video.quality.fingerprints.VideoQualitySetterFingerprint
import app.revanced.patches.youtube.misc.video.quality.fingerprints.VideoUserQualityChangeFingerprint import app.revanced.patches.youtube.misc.video.quality.fingerprints.VideoUserQualityChangeFingerprint
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
import app.revanced.patches.shared.settings.preference.impl.StringResource
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
import app.revanced.patches.youtube.misc.video.videoid.patch.VideoIdPatch import app.revanced.patches.youtube.misc.video.videoid.patch.VideoIdPatch
import org.jf.dexlib2.iface.instruction.ReferenceInstruction import org.jf.dexlib2.iface.instruction.ReferenceInstruction
import org.jf.dexlib2.iface.reference.FieldReference import org.jf.dexlib2.iface.reference.FieldReference
@ -47,7 +47,7 @@ class RememberVideoQualityPatch : BytecodePatch(
), ),
StringResource( StringResource(
"revanced_remember_video_quality_last_selected_summary_off", "revanced_remember_video_quality_last_selected_summary_off",
"Quality changes only apply to the current video and are reverted back to the last remembered quality for future playbacks" "Quality changes only apply to the current video"
) )
) )
) )

View file

@ -0,0 +1,13 @@
package app.revanced.patches.youtube.misc.video.speed.remember.annotation
import app.revanced.patcher.annotation.Compatibility
import app.revanced.patcher.annotation.Package
@Compatibility(
[Package(
"com.google.android.youtube", arrayOf("17.49.37")
)]
)
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.RUNTIME)
internal annotation class RememberPlaybackRateCompatibility

View file

@ -0,0 +1,8 @@
package app.revanced.patches.youtube.misc.video.speed.remember.fingerprint
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
object ChangePlaybackRateFragmentStateFingerprint : MethodFingerprint(
"V",
strings = listOf("PLAYBACK_RATE_MENU_BOTTOM_SHEET_FRAGMENT")
)

View file

@ -0,0 +1,7 @@
package app.revanced.patches.youtube.misc.video.speed.remember.fingerprint
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
object InitializePlaybackRateValuesFingerprint : MethodFingerprint(
parameters = listOf("[L", "I")
)

View file

@ -0,0 +1,12 @@
package app.revanced.patches.youtube.misc.video.speed.remember.fingerprint
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.Opcode
object OnPlaybackRateItemClickFingerprint : MethodFingerprint(
customFingerprint = { it.name == "onItemClick" },
opcodes = listOf(
Opcode.IGET_OBJECT,
Opcode.INVOKE_VIRTUAL
)
)

View file

@ -0,0 +1,137 @@
package app.revanced.patches.youtube.misc.video.speed.remember.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.addInstruction
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.extensions.instruction
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
import app.revanced.patcher.patch.*
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.util.smali.ExternalLabel
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.patch.IntegrationsPatch
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
import app.revanced.patches.youtube.misc.video.speed.remember.annotation.RememberPlaybackRateCompatibility
import app.revanced.patches.youtube.misc.video.speed.remember.fingerprint.ChangePlaybackRateFragmentStateFingerprint
import app.revanced.patches.youtube.misc.video.speed.remember.fingerprint.InitializePlaybackRateValuesFingerprint
import app.revanced.patches.youtube.misc.video.speed.remember.fingerprint.OnPlaybackRateItemClickFingerprint
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.iface.instruction.FiveRegisterInstruction
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
@Patch
@Name("remember-playback-rate")
@Description("Adds the ability to remember the playback rate you chose in the video playback rate flyout.")
@DependsOn([IntegrationsPatch::class, SettingsPatch::class])
@RememberPlaybackRateCompatibility
@Version("0.0.1")
class RememberPlaybackRatePatch : BytecodePatch(
listOf(ChangePlaybackRateFragmentStateFingerprint)
) {
private companion object {
const val INTEGRATIONS_CLASS_DESCRIPTOR =
"Lapp/revanced/integrations/patches/playback/speed/RememberPlaybackRatePatch;"
fun MethodFingerprint.getReference(offsetFromPatternScanResultStartIndex: Int = 0) = this.result!!.let {
val referenceInstruction = it.mutableMethod
.instruction(it.scanResult.patternScanResult!!.startIndex + offsetFromPatternScanResultStartIndex) as ReferenceInstruction
referenceInstruction.reference.toString()
}
fun BytecodeContext.resolveFingerprints() {
ChangePlaybackRateFragmentStateFingerprint.result?.also {
fun MethodFingerprint.resolve() = resolve(this@resolveFingerprints, it.classDef)
OnPlaybackRateItemClickFingerprint.resolve()
InitializePlaybackRateValuesFingerprint.resolve()
} ?: throw ChangePlaybackRateFragmentStateFingerprint.toErrorResult()
}
}
override fun execute(context: BytecodeContext): PatchResult {
SettingsPatch.PreferenceScreen.MISC.addPreferences(
SwitchPreference(
"revanced_remember_playback_rate_last_selected",
StringResource("revanced_remember_playback_rate_last_selected_title", "Remember playback rate changes"),
true,
StringResource(
"revanced_remember_playback_rate_last_selected_summary_on",
"Playback rate changes apply to all videos"
),
StringResource(
"revanced_remember_playback_rate_last_selected_summary_off",
"Playback rate changes only apply to the current video"
)
)
)
context.resolveFingerprints()
// Set the remembered playback rate.
InitializePlaybackRateValuesFingerprint.result!!.apply {
// Infer everything necessary for setPlaybackRate()
val playbackHandlerWrapperFieldReference =
(object : MethodFingerprint(opcodes = listOf(Opcode.IF_EQZ)) {}).apply {
OnPlaybackRateItemClickFingerprint.result!!.apply {
resolve(
context,
method,
classDef
)
}
}.getReference(-1)
val playbackHandlerWrapperImplementorClassReference = OnPlaybackRateItemClickFingerprint
.getReference(-1)
val playbackHandlerFieldReference = OnPlaybackRateItemClickFingerprint
.getReference()
val setPlaybackRateMethodReference = OnPlaybackRateItemClickFingerprint
.getReference(1)
mutableMethod.addInstructions(
0,
"""
invoke-static { }, $INTEGRATIONS_CLASS_DESCRIPTOR->getRememberedPlaybackRate()F
move-result v0
# check if the playback rate is below 0 (when a playback rate was never remembered)
const/4 v1, 0x0
cmpg-float v1, v0, v1
if-lez v1, :do_not_override
# invoke setPlaybackRate
iget-object v1, p0, $playbackHandlerWrapperFieldReference
check-cast v1, $playbackHandlerWrapperImplementorClassReference
iget-object v2, v1, $playbackHandlerFieldReference
invoke-virtual {v2, v0}, $setPlaybackRateMethodReference
""".trimIndent(),
listOf(ExternalLabel("do_not_override", mutableMethod.instruction(0)))
)
}
// Remember the selected playback rate.
OnPlaybackRateItemClickFingerprint.result!!.apply {
val setPlaybackRateIndex = scanResult.patternScanResult!!.endIndex
val selectedPlaybackRateRegister =
(mutableMethod.instruction(setPlaybackRateIndex) as FiveRegisterInstruction).registerD
mutableMethod.addInstruction(
setPlaybackRateIndex,
"invoke-static { v$selectedPlaybackRateRegister }, $INTEGRATIONS_CLASS_DESCRIPTOR->rememberPlaybackRate(F)V"
)
}
return PatchResultSuccess()
}
}