Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Pixiv - Hide ads): Fix for latest version #3616

Merged
merged 7 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions src/main/kotlin/app/revanced/patches/pixiv/ads/HideAdsPatch.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,28 @@ 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

@Patch(
name = "Hide ads",
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.
object HideAdsPatch : BytecodePatch(setOf(IsNotPremiumFingerprint, ShouldShowAdsFingerprint)) {
// Always return false in the "isNotPremium" or "shouldShowAds" 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.
override fun execute(context: BytecodeContext) =
IsNotPremiumFingerprint.result?.mutableClass?.virtualMethods?.first()?.addInstructions(
override fun execute(context: BytecodeContext) {
val method = IsNotPremiumFingerprint.result?.mutableClass?.virtualMethods?.first()
?: ShouldShowAdsFingerprint.result?.mutableMethod
?: throw ShouldShowAdsFingerprint.exception

method.addInstructions(
0,
"""
const/4 v0, 0x0
return v0
"""
) ?: throw IsNotPremiumFingerprint.exception
}
)
}
}
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"
}
)