fix(hide-time-stamp): player overlay button not working when hide-time-stamp is on

This commit is contained in:
inotia00 2023-04-20 07:44:31 +09:00
parent dde487258d
commit 9e96f5d398
4 changed files with 33 additions and 30 deletions

View File

@ -0,0 +1,27 @@
package app.revanced.patches.youtube.layout.seekbar.timestamps.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
@FuzzyPatternScanMethod(3)
object TimeCounterFingerprint : MethodFingerprint(
returnType = "V",
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf(),
opcodes = listOf(
Opcode.IGET_OBJECT,
Opcode.IGET_WIDE,
Opcode.CONST_WIDE_16,
Opcode.CMP_LONG,
Opcode.IF_LEZ,
Opcode.IGET_OBJECT,
Opcode.IF_EQZ,
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT,
Opcode.IF_EQZ,
Opcode.GOTO
)
)

View File

@ -1,16 +0,0 @@
package app.revanced.patches.youtube.layout.seekbar.timestamps.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
object TimeStampsContainerFingerprint : MethodFingerprint(
returnType = "V",
customFingerprint = { methodDef ->
methodDef.implementation?.instructions?.any {
it.opcode.ordinal == Opcode.CONST.ordinal &&
(it as? WideLiteralInstruction)?.wideLiteral == SharedResourceIdPatch.timeStampsContainerLabelId
} == true
}
)

View File

@ -14,30 +14,24 @@ 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.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.layout.seekbar.timestamps.fingerprints.TimeStampsContainerFingerprint
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.layout.seekbar.timestamps.fingerprints.TimeCounterFingerprint
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
import app.revanced.util.integrations.Constants.SEEKBAR
@Patch
@Name("hide-time-stamp")
@Description("Hides the time counter above the seekbar.")
@DependsOn(
[
SettingsPatch::class,
SharedResourceIdPatch::class
]
)
@Description("Hides timestamp in video player.")
@DependsOn([SettingsPatch::class])
@YouTubeCompatibility
@Version("0.0.1")
class HideTimeStampPatch : BytecodePatch(
listOf(
TimeStampsContainerFingerprint
TimeCounterFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
TimeStampsContainerFingerprint.result?.mutableMethod?.let {
TimeCounterFingerprint.result?.mutableMethod?.let {
it.addInstructions(
0, """
invoke-static {}, $SEEKBAR->hideTimeStamp()Z
@ -46,7 +40,7 @@ class HideTimeStampPatch : BytecodePatch(
return-void
""", listOf(ExternalLabel("show_time_stamp", it.instruction(0)))
)
} ?: return TimeStampsContainerFingerprint.toErrorResult()
} ?: return TimeCounterFingerprint.toErrorResult()
/*
* Add settings

View File

@ -50,7 +50,6 @@ class SharedResourceIdPatch : ResourcePatch {
var searchSuggestionEntryLabelId: Long = -1
var scrubbingLabelId: Long = -1
var timeBarPlayedDarkLabelId: Long = -1
var timeStampsContainerLabelId: Long = -1
var tooltipLabelId: Long = -1
var videoQualityFragmentLabelId: Long = -1
}
@ -93,7 +92,6 @@ class SharedResourceIdPatch : ResourcePatch {
searchSuggestionEntryLabelId = find(LAYOUT, "search_suggestion_entry")
scrubbingLabelId = find(DIMEN, "vertical_touch_offset_to_enter_fine_scrubbing")
timeBarPlayedDarkLabelId = find(COLOR, "inline_time_bar_colorized_bar_played_color_dark")
timeStampsContainerLabelId = find(ID, "timestamps_container")
tooltipLabelId = find(LAYOUT, "tooltip_content_view")
videoQualityFragmentLabelId = find(LAYOUT, "video_quality_bottom_sheet_list_fragment_title")