Skip to content

Commit ff2c456

Browse files
Anajrim01oSumAtrIX
andauthored
fix(Pixiv - Hide ads): Fix for latest version (#3616)
Co-authored-by: oSumAtrIX <[email protected]>
1 parent b568207 commit ff2c456

File tree

3 files changed

+22
-32
lines changed

3 files changed

+22
-32
lines changed
Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,25 @@
11
package app.revanced.patches.pixiv.ads
22

3-
import app.revanced.util.exception
43
import app.revanced.patcher.data.BytecodeContext
54
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
65
import app.revanced.patcher.patch.BytecodePatch
76
import app.revanced.patcher.patch.annotation.CompatiblePackage
87
import app.revanced.patcher.patch.annotation.Patch
9-
import app.revanced.patches.pixiv.ads.fingerprints.IsNotPremiumFingerprint
8+
import app.revanced.patches.pixiv.ads.fingerprints.ShouldShowAdsFingerprint
9+
import app.revanced.util.exception
1010

1111
@Patch(
1212
name = "Hide ads",
13-
compatiblePackages = [CompatiblePackage("jp.pxv.android")]
13+
compatiblePackages = [CompatiblePackage("jp.pxv.android")],
1414
)
1515
@Suppress("unused")
16-
object HideAdsPatch : BytecodePatch(setOf(IsNotPremiumFingerprint)) {
17-
// Always return false in the "isNotPremium" method which normally returns !this.accountManager.isPremium.
18-
// However, this is not the method that controls the user's premium status.
19-
// Instead, this method is used to determine whether ads should be shown.
16+
object HideAdsPatch : BytecodePatch(setOf(ShouldShowAdsFingerprint)) {
2017
override fun execute(context: BytecodeContext) =
21-
IsNotPremiumFingerprint.result?.mutableClass?.virtualMethods?.first()?.addInstructions(
18+
ShouldShowAdsFingerprint.result?.mutableMethod?.addInstructions(
2219
0,
2320
"""
2421
const/4 v0, 0x0
2522
return v0
26-
"""
27-
) ?: throw IsNotPremiumFingerprint.exception
28-
}
23+
""",
24+
) ?: throw ShouldShowAdsFingerprint.exception
25+
}

src/main/kotlin/app/revanced/patches/pixiv/ads/fingerprints/IsNotPremiumFingerprint.kt

Lines changed: 0 additions & 21 deletions
This file was deleted.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package app.revanced.patches.pixiv.ads.fingerprints
2+
3+
import app.revanced.patcher.extensions.or
4+
import app.revanced.patcher.fingerprint.MethodFingerprint
5+
import com.android.tools.smali.dexlib2.AccessFlags
6+
7+
8+
internal object ShouldShowAdsFingerprint : MethodFingerprint(
9+
"Z",
10+
AccessFlags.PUBLIC or AccessFlags.FINAL,
11+
customFingerprint = { methodDef, classDef ->
12+
classDef.type.endsWith("AdUtils;") && methodDef.name == "shouldShowAds"
13+
}
14+
)

0 commit comments

Comments
 (0)