Skip to content

Commit

Permalink
fix(Pixiv - Hide ads): Fix for latest version (#3616)
Browse files Browse the repository at this point in the history
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
  • Loading branch information
Anajrim01 and oSumAtrIX authored Sep 6, 2024
1 parent 3a537c7 commit 98956e8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 32 deletions.
19 changes: 8 additions & 11 deletions src/main/kotlin/app/revanced/patches/pixiv/ads/HideAdsPatch.kt
Original file line number Diff line number Diff line change
@@ -1,28 +1,25 @@
package app.revanced.patches.pixiv.ads

import app.revanced.util.exception
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.annotation.CompatiblePackage
import app.revanced.patcher.patch.annotation.Patch
import app.revanced.patches.pixiv.ads.fingerprints.IsNotPremiumFingerprint
import app.revanced.patches.pixiv.ads.fingerprints.ShouldShowAdsFingerprint
import app.revanced.util.exception

@Patch(
name = "Hide ads",
compatiblePackages = [CompatiblePackage("jp.pxv.android")]
compatiblePackages = [CompatiblePackage("jp.pxv.android")],
)
@Suppress("unused")
object HideAdsPatch : BytecodePatch(setOf(IsNotPremiumFingerprint)) {
// Always return false in the "isNotPremium" method which normally returns !this.accountManager.isPremium.
// However, this is not the method that controls the user's premium status.
// Instead, this method is used to determine whether ads should be shown.
object HideAdsPatch : BytecodePatch(setOf(ShouldShowAdsFingerprint)) {
override fun execute(context: BytecodeContext) =
IsNotPremiumFingerprint.result?.mutableClass?.virtualMethods?.first()?.addInstructions(
ShouldShowAdsFingerprint.result?.mutableMethod?.addInstructions(
0,
"""
const/4 v0, 0x0
return v0
"""
) ?: throw IsNotPremiumFingerprint.exception
}
""",
) ?: throw ShouldShowAdsFingerprint.exception
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package app.revanced.patches.pixiv.ads.fingerprints

import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.MethodFingerprint
import com.android.tools.smali.dexlib2.AccessFlags


internal object ShouldShowAdsFingerprint : MethodFingerprint(
"Z",
AccessFlags.PUBLIC or AccessFlags.FINAL,
customFingerprint = { methodDef, classDef ->
classDef.type.endsWith("AdUtils;") && methodDef.name == "shouldShowAds"
}
)

0 comments on commit 98956e8

Please sign in to comment.