refactor(pixiv): HideAdsPatch

This commit is contained in:
Pun Butrach 2026-01-11 23:59:39 +07:00
parent d5c56c4889
commit e7d596e4d8
2 changed files with 14 additions and 12 deletions

View file

@ -1,12 +1,16 @@
package app.revanced.patches.pixiv.ads 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 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) accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL)
returns("Z") returnType("Z")
custom { methodDef, classDef -> definingClass("AdUtils;"::endsWith)
classDef.type.endsWith("AdUtils;") && methodDef.name == "shouldShowAds" name("shouldShowAds")
}
} }

View file

@ -1,15 +1,13 @@
package app.revanced.patches.pixiv.ads package app.revanced.patches.pixiv.ads
import app.revanced.patcher.patch.bytecodePatch import app.revanced.patcher.patch.creatingBytecodePatch
import app.revanced.util.returnEarly import app.revanced.util.returnEarly
@Suppress("unused") @Suppress("unused", "ObjectPropertyName")
val hideAdsPatch = bytecodePatch( val `Hide ads` by creatingBytecodePatch {
name = "Hide ads",
) {
compatibleWith("jp.pxv.android"("6.141.1")) compatibleWith("jp.pxv.android"("6.141.1"))
apply { apply {
shouldShowAdsFingerprint.method.returnEarly(false) shouldShowAdsMethod.returnEarly(false)
} }
} }