2022-09-21 02:58:39 +02:00
|
|
|
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
|
2022-10-05 04:03:10 +02:00
|
|
|
import app.revanced.patcher.data.BytecodeContext
|
2022-09-21 02:58:39 +02:00
|
|
|
import app.revanced.patcher.extensions.addInstructions
|
2022-12-18 22:18:28 +01:00
|
|
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
|
2022-10-05 04:03:10 +02:00
|
|
|
import app.revanced.patcher.patch.BytecodePatch
|
2022-09-21 02:58:39 +02:00
|
|
|
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
|
2022-12-18 22:18:28 +01:00
|
|
|
import app.revanced.patches.shared.fingerprints.SeekbarFingerprint
|
|
|
|
import app.revanced.patches.shared.fingerprints.SeekbarOnDrawFingerprint
|
|
|
|
import app.revanced.patches.shared.settings.preference.impl.StringResource
|
|
|
|
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
|
2022-09-21 02:58:39 +02:00
|
|
|
import app.revanced.patches.youtube.layout.hidetimeandseekbar.annotations.HideTimeAndSeekbarCompatibility
|
2022-10-05 04:03:10 +02:00
|
|
|
import app.revanced.patches.youtube.layout.hidetimeandseekbar.fingerprints.TimeCounterFingerprint
|
2022-09-21 02:58:39 +02:00
|
|
|
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])
|
|
|
|
@Name("hide-time-and-seekbar")
|
|
|
|
@Description("Hides progress bar and time counter on videos.")
|
|
|
|
@HideTimeAndSeekbarCompatibility
|
|
|
|
@Version("0.0.1")
|
|
|
|
class HideTimeAndSeekbarPatch : BytecodePatch(
|
|
|
|
listOf(
|
2022-12-18 22:18:28 +01:00
|
|
|
SeekbarFingerprint, TimeCounterFingerprint
|
2022-09-21 02:58:39 +02:00
|
|
|
)
|
|
|
|
) {
|
2022-10-05 04:03:10 +02:00
|
|
|
override fun execute(context: BytecodeContext): PatchResult {
|
2022-09-21 02:58:39 +02:00
|
|
|
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"),
|
2022-12-06 23:47:25 +01:00
|
|
|
StringResource("revanced_hide_time_and_seekbar_summary_off", "Time and seekbar are shown")
|
2022-09-21 02:58:39 +02:00
|
|
|
)
|
|
|
|
)
|
|
|
|
|
2022-12-18 22:18:28 +01:00
|
|
|
val createVideoPlayerSeekbarMethod = SeekbarFingerprint.result!!.let {
|
|
|
|
SeekbarOnDrawFingerprint.apply { resolve(context, it.mutableClass) }
|
|
|
|
}.result!!.mutableMethod
|
2022-09-21 02:58:39 +02:00
|
|
|
|
2022-09-23 12:51:58 +02:00
|
|
|
createVideoPlayerSeekbarMethod.addInstructions(
|
2022-09-21 02:58:39 +02:00
|
|
|
0, """
|
2022-09-23 12:51:58 +02:00
|
|
|
const/4 v0, 0x0
|
2022-09-21 02:58:39 +02:00
|
|
|
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
|
2022-09-23 12:51:58 +02:00
|
|
|
return-void
|
2022-09-21 02:58:39 +02:00
|
|
|
:hide_time_and_seekbar
|
|
|
|
nop
|
|
|
|
"""
|
|
|
|
)
|
|
|
|
|
|
|
|
return PatchResultSuccess()
|
|
|
|
}
|
|
|
|
}
|