feat(sponsorblock): automatically hide skip button

This commit is contained in:
inotia00
2023-04-28 16:38:16 +09:00
parent be9d745d9c
commit 183b806bdb
5 changed files with 50 additions and 38 deletions

View File

@ -29,7 +29,6 @@ class SharedResourceIdPatch : ResourcePatch {
var compactLinkLabelId: Long = -1
var controlsLayoutStubResourceId: Long = -1
var donationCompanionResourceId: Long = -1
var emptyColorLabelId: Long = -1
var fabLabelId: Long = -1
var filterBarHeightLabelId: Long = -1
var floatyBarQueueLabelId: Long = -1
@ -71,7 +70,6 @@ class SharedResourceIdPatch : ResourcePatch {
compactLinkLabelId = find(LAYOUT, "compact_link")
controlsLayoutStubResourceId = find(ID, "controls_layout_stub")
donationCompanionResourceId = find(LAYOUT, "donation_companion")
emptyColorLabelId = find(COLOR, "inline_time_bar_colorized_bar_empty_color_dark")
fabLabelId = find(ID, "fab")
filterBarHeightLabelId = find(DIMEN, "filter_bar_height")
floatyBarQueueLabelId = find(STRING, "floaty_bar_queue_status")

View File

@ -8,6 +8,7 @@ import app.revanced.patcher.extensions.addInstruction
import app.revanced.patcher.extensions.replaceInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultError
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
@ -33,6 +34,7 @@ import org.jf.dexlib2.iface.reference.MethodReference
@Name("sponsorblock-bytecode-patch")
@DependsOn(
[
HookTimebarPatch::class,
LegacyVideoIdPatch::class,
MainstreamVideoIdPatch::class,
OverrideSpeedHookPatch::class,
@ -112,6 +114,9 @@ class SponsorBlockBytecodePatch : BytecodePatch(
insertInstructions.indexOf(it) to (it as FiveRegisterInstruction).registerD
}
if (drawRectangleInstructions.size < 4)
return PatchResultError("Couldn't find drawRect reference")
mapOf(
"setSponsorBarAbsoluteLeft" to 3,
"setSponsorBarAbsoluteRight" to 0

View File

@ -1,17 +1,20 @@
package app.revanced.patches.youtube.misc.timebar.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
import org.jf.dexlib2.Opcode
object EmptyColorFingerprint : MethodFingerprint(
returnType = "V",
opcodes = listOf(Opcode.DIV_LONG_2ADDR),
customFingerprint = { methodDef ->
methodDef.implementation?.instructions?.any {
it.opcode.ordinal == Opcode.CONST.ordinal &&
(it as? WideLiteralInstruction)?.wideLiteral == SharedResourceIdPatch.emptyColorLabelId
} == true
}
opcodes = listOf(
Opcode.MOVE_RESULT_WIDE,
Opcode.CMP_LONG,
Opcode.IF_LEZ,
Opcode.IGET_OBJECT,
Opcode.CHECK_CAST,
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_WIDE,
Opcode.GOTO,
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_WIDE
)
)

View File

@ -8,14 +8,11 @@ import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.
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.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.misc.timebar.fingerprints.*
@Name("hook-timebar-patch")
@DependsOn([SharedResourceIdPatch::class])
@YouTubeCompatibility
@Version("0.0.1")
class HookTimebarPatch : BytecodePatch(