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
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")
}

View File

@@ -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)
}
}