From e7d596e4d8afdbbdadf99f28364e40ae0e0d6cd7 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Sun, 11 Jan 2026 23:59:39 +0700 Subject: [PATCH] refactor(pixiv): HideAdsPatch --- .../revanced/patches/pixiv/ads/Fingerprints.kt | 16 ++++++++++------ .../revanced/patches/pixiv/ads/HideAdsPatch.kt | 10 ++++------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/pixiv/ads/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/pixiv/ads/Fingerprints.kt index 3e2addaa0..ce3d3d813 100644 --- a/patches/src/main/kotlin/app/revanced/patches/pixiv/ads/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/pixiv/ads/Fingerprints.kt @@ -1,12 +1,16 @@ package app.revanced.patches.pixiv.ads +import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively +import app.revanced.patcher.accessFlags +import app.revanced.patcher.definingClass +import app.revanced.patcher.name +import app.revanced.patcher.patch.BytecodePatchContext +import app.revanced.patcher.returnType import com.android.tools.smali.dexlib2.AccessFlags -import app.revanced.patcher.fingerprint -internal val shouldShowAdsFingerprint = fingerprint { +internal val BytecodePatchContext.shouldShowAdsMethod by gettingFirstMutableMethodDeclaratively { accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL) - returns("Z") - custom { methodDef, classDef -> - classDef.type.endsWith("AdUtils;") && methodDef.name == "shouldShowAds" - } + returnType("Z") + definingClass("AdUtils;"::endsWith) + name("shouldShowAds") } diff --git a/patches/src/main/kotlin/app/revanced/patches/pixiv/ads/HideAdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/pixiv/ads/HideAdsPatch.kt index 93962a332..c854e761f 100644 --- a/patches/src/main/kotlin/app/revanced/patches/pixiv/ads/HideAdsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/pixiv/ads/HideAdsPatch.kt @@ -1,15 +1,13 @@ package app.revanced.patches.pixiv.ads -import app.revanced.patcher.patch.bytecodePatch +import app.revanced.patcher.patch.creatingBytecodePatch import app.revanced.util.returnEarly -@Suppress("unused") -val hideAdsPatch = bytecodePatch( - name = "Hide ads", -) { +@Suppress("unused", "ObjectPropertyName") +val `Hide ads` by creatingBytecodePatch { compatibleWith("jp.pxv.android"("6.141.1")) apply { - shouldShowAdsFingerprint.method.returnEarly(false) + shouldShowAdsMethod.returnEarly(false) } }