2023-09-20 05:33:02 +02:00
|
|
|
package app.revanced.patches.twitch.ad.audio
|
2022-11-14 00:27:59 +01:00
|
|
|
|
|
|
|
import app.revanced.patcher.data.BytecodeContext
|
2023-06-07 03:46:13 +02:00
|
|
|
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
|
|
|
|
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
2022-11-14 00:27:59 +01:00
|
|
|
import app.revanced.patcher.patch.BytecodePatch
|
2023-09-20 05:33:02 +02:00
|
|
|
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
|
|
|
import app.revanced.patcher.patch.annotation.Patch
|
2022-11-29 00:20:58 +01:00
|
|
|
import app.revanced.patcher.util.smali.ExternalLabel
|
2024-01-27 02:34:01 +01:00
|
|
|
import app.revanced.patches.all.misc.resources.AddResourcesPatch
|
|
|
|
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
|
2022-11-14 00:27:59 +01:00
|
|
|
import app.revanced.patches.twitch.ad.audio.fingerprints.AudioAdsPresenterPlayFingerprint
|
2023-09-20 05:33:02 +02:00
|
|
|
import app.revanced.patches.twitch.misc.integrations.IntegrationsPatch
|
|
|
|
import app.revanced.patches.twitch.misc.settings.SettingsPatch
|
2022-11-14 00:27:59 +01:00
|
|
|
|
2023-09-20 05:33:02 +02:00
|
|
|
@Patch(
|
|
|
|
name = "Block audio ads",
|
|
|
|
description = "Blocks audio ads in streams and VODs.",
|
2024-01-27 02:34:01 +01:00
|
|
|
dependencies = [IntegrationsPatch::class, SettingsPatch::class, AddResourcesPatch::class],
|
2023-11-21 21:05:04 +01:00
|
|
|
compatiblePackages = [CompatiblePackage("tv.twitch.android.app", ["15.4.1", "16.1.0", "16.9.1"])],
|
2023-09-20 05:33:02 +02:00
|
|
|
)
|
|
|
|
@Suppress("unused")
|
|
|
|
object AudioAdsPatch : BytecodePatch(
|
|
|
|
setOf(AudioAdsPresenterPlayFingerprint)
|
2022-11-14 00:27:59 +01:00
|
|
|
) {
|
2023-08-27 21:40:49 +02:00
|
|
|
override fun execute(context: BytecodeContext) {
|
2024-01-27 02:34:01 +01:00
|
|
|
AddResourcesPatch(this::class)
|
|
|
|
|
2024-03-02 08:27:05 +01:00
|
|
|
SettingsPatch.PreferenceScreen.ADS.CLIENT_SIDE.addPreferences(
|
|
|
|
SwitchPreference("revanced_block_audio_ads")
|
|
|
|
)
|
2024-01-27 02:34:01 +01:00
|
|
|
|
2022-11-14 00:27:59 +01:00
|
|
|
// Block playAds call
|
|
|
|
with(AudioAdsPresenterPlayFingerprint.result!!) {
|
2023-06-07 03:46:13 +02:00
|
|
|
mutableMethod.addInstructionsWithLabels(
|
2022-11-29 00:20:58 +01:00
|
|
|
0,
|
|
|
|
"""
|
2024-01-01 16:33:07 +01:00
|
|
|
invoke-static { }, Lapp/revanced/integrations/twitch/patches/AudioAdsPatch;->shouldBlockAudioAds()Z
|
2022-11-29 00:20:58 +01:00
|
|
|
move-result v0
|
|
|
|
if-eqz v0, :show_audio_ads
|
|
|
|
return-void
|
|
|
|
""",
|
2023-06-07 03:46:13 +02:00
|
|
|
ExternalLabel("show_audio_ads", mutableMethod.getInstruction(0))
|
2022-11-29 00:20:58 +01:00
|
|
|
)
|
2022-11-14 00:27:59 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|