generated from ReVanced/revanced-patches-template
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(twitch):
block-audio-ads
patch (#1041)
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
- Loading branch information
1 parent
2d10caf
commit 3419bae
Showing
3 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
src/main/kotlin/app/revanced/patches/twitch/ad/audio/annotations/AudioAdsCompatibility.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package app.revanced.patches.twitch.ad.audio.annotations | ||
|
||
import app.revanced.patcher.annotation.Compatibility | ||
import app.revanced.patcher.annotation.Package | ||
|
||
@Compatibility([Package("tv.twitch.android.app")]) | ||
@Target(AnnotationTarget.CLASS) | ||
@Retention(AnnotationRetention.RUNTIME) | ||
internal annotation class AudioAdsCompatibility | ||
|
16 changes: 16 additions & 0 deletions
16
...lin/app/revanced/patches/twitch/ad/audio/fingerprints/AudioAdsPresenterPlayFingerprint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package app.revanced.patches.twitch.ad.audio.fingerprints | ||
|
||
import app.revanced.patcher.annotation.Name | ||
import app.revanced.patcher.annotation.Version | ||
|
||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint | ||
import app.revanced.patches.twitch.ad.audio.annotations.AudioAdsCompatibility | ||
|
||
@Name("audio-ads-presenter-play-fingerprint") | ||
@AudioAdsCompatibility | ||
@Version("0.0.1") | ||
object AudioAdsPresenterPlayFingerprint : MethodFingerprint( | ||
customFingerprint = { method -> | ||
method.definingClass.endsWith("AudioAdsPlayerPresenter;") && method.name == "playAd" | ||
} | ||
) |
31 changes: 31 additions & 0 deletions
31
src/main/kotlin/app/revanced/patches/twitch/ad/audio/patch/AudioAdsPatch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package app.revanced.patches.twitch.ad.audio.patch | ||
|
||
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.addInstruction | ||
import app.revanced.patcher.patch.BytecodePatch | ||
import app.revanced.patcher.patch.PatchResult | ||
import app.revanced.patcher.patch.PatchResultSuccess | ||
import app.revanced.patcher.patch.annotations.Patch | ||
import app.revanced.patches.twitch.ad.audio.annotations.AudioAdsCompatibility | ||
import app.revanced.patches.twitch.ad.audio.fingerprints.AudioAdsPresenterPlayFingerprint | ||
|
||
@Patch | ||
@Name("block-audio-ads") | ||
@Description("Blocks audio ads in streams and VODs.") | ||
@AudioAdsCompatibility | ||
@Version("0.0.1") | ||
class AudioAdsPatch : BytecodePatch( | ||
listOf(AudioAdsPresenterPlayFingerprint) | ||
) { | ||
override fun execute(context: BytecodeContext): PatchResult { | ||
// Block playAds call | ||
with(AudioAdsPresenterPlayFingerprint.result!!) { | ||
mutableMethod.addInstruction(0, "return-void") | ||
} | ||
|
||
return PatchResultSuccess() | ||
} | ||
} |