feat(hide-video-ads): change to abstract patch

This commit is contained in:
inotia00
2023-06-18 23:14:42 +09:00
parent ef03b3afbd
commit e83fa54c87
4 changed files with 70 additions and 99 deletions

View File

@ -4,37 +4,30 @@ 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.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.shared.patch.videoads.GeneralVideoAdsPatch
import app.revanced.patches.shared.patch.videoads.AbstractVideoAdsPatch
import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch
import app.revanced.util.integrations.Constants.ADS_PATH
@Patch
@Name("hide-video-ads")
@Description("Removes ads in the video player.")
@DependsOn(
[
GeneralVideoAdsPatch::class,
SettingsPatch::class
]
)
@DependsOn([SettingsPatch::class])
@YouTubeCompatibility
@Version("0.0.1")
class VideoAdsPatch : BytecodePatch() {
class VideoAdsPatch : AbstractVideoAdsPatch(
"$ADS_PATH/HideVideoAdsPatch;->hideVideoAds()Z"
) {
override fun execute(context: BytecodeContext): PatchResult {
GeneralVideoAdsPatch.injectLegacyAds(INTEGRATIONS_CLASS_DESCRIPTOR)
GeneralVideoAdsPatch.injectMainstreamAds(INTEGRATIONS_CLASS_DESCRIPTOR)
super.execute(context)
/**
* Add settings
*/
SettingsPatch.addPreference(
arrayOf(
"PREFERENCE: ADS_SETTINGS",
@ -46,8 +39,4 @@ class VideoAdsPatch : BytecodePatch() {
return PatchResultSuccess()
}
private companion object {
const val INTEGRATIONS_CLASS_DESCRIPTOR = "$ADS_PATH/HideVideoAdsPatch;->hideVideoAds()Z"
}
}