mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-07 18:14:36 +02:00
feat(youtube): add enable-new-thumbnail-preview
patch
This commit is contained in:
parent
2d13212511
commit
b606d38afa
@ -0,0 +1,10 @@
|
|||||||
|
package app.revanced.patches.youtube.seekbar.thumbnailpreview.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
|
import app.revanced.util.bytecode.isWide32LiteralExists
|
||||||
|
|
||||||
|
object ThumbnailPreviewConfigFingerprint : MethodFingerprint(
|
||||||
|
returnType = "Z",
|
||||||
|
parameters = listOf(),
|
||||||
|
customFingerprint = { it, _ -> it.isWide32LiteralExists(45398577) }
|
||||||
|
)
|
@ -0,0 +1,60 @@
|
|||||||
|
package app.revanced.patches.youtube.seekbar.thumbnailpreview.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.InstructionExtensions.addInstructions
|
||||||
|
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||||
|
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.patch.annotations.Patch
|
||||||
|
import app.revanced.patches.shared.annotation.YouTubeCompatibility
|
||||||
|
import app.revanced.patches.youtube.seekbar.thumbnailpreview.fingerprints.ThumbnailPreviewConfigFingerprint
|
||||||
|
import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch
|
||||||
|
import app.revanced.util.integrations.Constants.SEEKBAR
|
||||||
|
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
|
|
||||||
|
@Patch
|
||||||
|
@Name("enable-new-thumbnail-preview")
|
||||||
|
@Description("Enables a new type of thumbnail preview.")
|
||||||
|
@DependsOn([SettingsPatch::class])
|
||||||
|
@YouTubeCompatibility
|
||||||
|
@Version("0.0.1")
|
||||||
|
class NewThumbnailPreviewPatch : BytecodePatch(
|
||||||
|
listOf(ThumbnailPreviewConfigFingerprint)
|
||||||
|
) {
|
||||||
|
override fun execute(context: BytecodeContext): PatchResult {
|
||||||
|
|
||||||
|
ThumbnailPreviewConfigFingerprint.result?.let {
|
||||||
|
it.mutableMethod.apply {
|
||||||
|
val insertIndex = implementation!!.instructions.size - 1
|
||||||
|
val targetRegister = getInstruction<OneRegisterInstruction>(insertIndex).registerA
|
||||||
|
|
||||||
|
addInstructions(
|
||||||
|
insertIndex, """
|
||||||
|
invoke-static {v$targetRegister}, $SEEKBAR->enableNewThumbnailPreview(Z)Z
|
||||||
|
move-result v$targetRegister
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} ?: return ThumbnailPreviewConfigFingerprint.toErrorResult()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add settings
|
||||||
|
*/
|
||||||
|
SettingsPatch.addPreference(
|
||||||
|
arrayOf(
|
||||||
|
"PREFERENCE: SEEKBAR_SETTINGS",
|
||||||
|
"SETTINGS: ENABLE_NEW_THUMBNAIL_PREVIEW"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
SettingsPatch.updatePatchStatus("enable-new-thumbnail-preview")
|
||||||
|
|
||||||
|
return PatchResultSuccess()
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user