generated from ReVanced/revanced-patches-template
-
-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(Pixiv - Hide ads): Fix for latest version (#3616)
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
- Loading branch information
Showing
3 changed files
with
22 additions
and
32 deletions.
There are no files selected for viewing
19 changes: 8 additions & 11 deletions
19
src/main/kotlin/app/revanced/patches/pixiv/ads/HideAdsPatch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
21 changes: 0 additions & 21 deletions
21
src/main/kotlin/app/revanced/patches/pixiv/ads/fingerprints/IsNotPremiumFingerprint.kt
This file was deleted.
Oops, something went wrong.
14 changes: 14 additions & 0 deletions
14
src/main/kotlin/app/revanced/patches/pixiv/ads/fingerprints/ShouldShowAdsFingerprint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
) |