mirror of
https://github.com/revanced/revanced-patches
synced 2024-08-29 02:25:15 +02:00
feat: hide-time-and-seekbar
patch (#544)
This commit is contained in:
parent
a1625a0c8a
commit
ef7afc7231
@ -0,0 +1,13 @@
|
||||
package app.revanced.patches.youtube.layout.hidetimeandseekbar.annotations
|
||||
|
||||
import app.revanced.patcher.annotation.Compatibility
|
||||
import app.revanced.patcher.annotation.Package
|
||||
|
||||
@Compatibility(
|
||||
[Package(
|
||||
"com.google.android.youtube", arrayOf("17.25.34", "17.26.35", "17.27.39", "17.28.34", "17.29.34", "17.32.35", "17.33.42", "17.36.37")
|
||||
)]
|
||||
)
|
||||
@Target(AnnotationTarget.CLASS)
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
internal annotation class HideTimeAndSeekbarCompatibility
|
@ -0,0 +1,35 @@
|
||||
package app.revanced.patches.youtube.layout.hidetimeandseekbar.fingerprints
|
||||
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod
|
||||
import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import app.revanced.patches.youtube.layout.hidetimeandseekbar.annotations.HideTimeAndSeekbarCompatibility
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
||||
@Name("inline-time-bar-wrapper-fingerprint")
|
||||
@MatchingMethod("Lcom/google/android/apps/youtube/app/common/player/overlay/InlineTimeBarWrapper;", "onLayout")
|
||||
@FuzzyPatternScanMethod(3)
|
||||
@HideTimeAndSeekbarCompatibility
|
||||
@Version("0.0.1")
|
||||
object InlineTimeBarWrapperFingerprint : MethodFingerprint(
|
||||
"V", AccessFlags.PROTECTED or AccessFlags.FINAL, listOf("Z", "I", "I", "I", "I"), listOf(
|
||||
Opcode.SUB_INT_2ADDR,
|
||||
Opcode.SUB_INT,
|
||||
Opcode.IF_EQZ,
|
||||
Opcode.IF_NEZ,
|
||||
Opcode.GOTO_16,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.MOVE_RESULT,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.MOVE_RESULT,
|
||||
Opcode.SUB_INT,
|
||||
Opcode.CONST_4,
|
||||
Opcode.INVOKE_STATIC,
|
||||
Opcode.MOVE_RESULT,
|
||||
Opcode.IGET_OBJECT,
|
||||
)
|
||||
)
|
@ -0,0 +1,26 @@
|
||||
package app.revanced.patches.youtube.layout.hidetimeandseekbar.fingerprints
|
||||
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod
|
||||
import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import app.revanced.patches.youtube.layout.hidetimeandseekbar.annotations.HideTimeAndSeekbarCompatibility
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
||||
@Name("time-counter-fingerprint")
|
||||
@MatchingMethod("Lfez", "a")
|
||||
@FuzzyPatternScanMethod(3)
|
||||
@HideTimeAndSeekbarCompatibility
|
||||
@Version("0.0.1")
|
||||
object TimeCounterFingerprint : MethodFingerprint(
|
||||
"L", AccessFlags.PUBLIC or AccessFlags.STATIC, listOf("J"), listOf(
|
||||
Opcode.SGET_OBJECT,
|
||||
Opcode.CONST_WIDE_16,
|
||||
Opcode.ADD_LONG_2ADDR,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.MOVE_RESULT_WIDE,
|
||||
)
|
||||
)
|
@ -0,0 +1,72 @@
|
||||
package app.revanced.patches.youtube.layout.hidetimeandseekbar.patch
|
||||
|
||||
import app.revanced.patcher.annotation.Description
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.data.impl.BytecodeData
|
||||
import app.revanced.patcher.extensions.addInstructions
|
||||
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.patch.impl.BytecodePatch
|
||||
import app.revanced.patches.youtube.layout.hidetimeandseekbar.fingerprints.InlineTimeBarWrapperFingerprint
|
||||
import app.revanced.patches.youtube.layout.hidetimeandseekbar.fingerprints.TimeCounterFingerprint
|
||||
import app.revanced.patches.youtube.layout.hidetimeandseekbar.annotations.HideTimeAndSeekbarCompatibility
|
||||
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.settings.framework.components.impl.StringResource
|
||||
import app.revanced.patches.youtube.misc.settings.framework.components.impl.SwitchPreference
|
||||
|
||||
@Patch
|
||||
@DependsOn([IntegrationsPatch::class, SettingsPatch::class])
|
||||
@Name("hide-time-and-seekbar")
|
||||
@Description("Hides progress bar and time counter on videos.")
|
||||
@HideTimeAndSeekbarCompatibility
|
||||
@Version("0.0.1")
|
||||
class HideTimeAndSeekbarPatch : BytecodePatch(
|
||||
listOf(
|
||||
InlineTimeBarWrapperFingerprint, TimeCounterFingerprint
|
||||
)
|
||||
) {
|
||||
override fun execute(data: BytecodeData): PatchResult {
|
||||
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
|
||||
SwitchPreference(
|
||||
"revanced_hide_time_and_seekbar",
|
||||
StringResource("revanced_hide_time_and_seekbar_title", "Hide time and seekbar"),
|
||||
false,
|
||||
StringResource("revanced_hide_time_and_seekbar_summary_on", "Time and seekbar are hidden"),
|
||||
StringResource("revanced_hide_time_and_seekbar_summary_off", "Time and seekbar are visible")
|
||||
)
|
||||
)
|
||||
|
||||
val inlineTimeBarWrapperMethod = InlineTimeBarWrapperFingerprint.result!!.mutableMethod
|
||||
|
||||
inlineTimeBarWrapperMethod.addInstructions(
|
||||
0, """
|
||||
invoke-static { }, Lapp/revanced/integrations/patches/HideTimeAndSeekbarPatch;->hideTimeAndSeekbar()Z
|
||||
move-result v0
|
||||
if-eqz v0, :hide_time_and_seekbar
|
||||
return-void
|
||||
:hide_time_and_seekbar
|
||||
nop
|
||||
"""
|
||||
)
|
||||
|
||||
val timeCounterMethod = TimeCounterFingerprint.result!!.mutableMethod
|
||||
|
||||
timeCounterMethod.addInstructions(
|
||||
0, """
|
||||
invoke-static { }, Lapp/revanced/integrations/patches/HideTimeAndSeekbarPatch;->hideTimeAndSeekbar()Z
|
||||
move-result v0
|
||||
if-eqz v0, :hide_time_and_seekbar
|
||||
const-string v0, ""
|
||||
return-object v0
|
||||
:hide_time_and_seekbar
|
||||
nop
|
||||
"""
|
||||
)
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user