mirror of
https://github.com/revanced/revanced-patches.git
synced 2025-06-12 13:17:38 +02:00
feat(NU.nl): Add Hide ads
and Spoof Certificate
patch (#4368)
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
This commit is contained in:
@ -348,6 +348,14 @@ public final class app/revanced/patches/nfctoolsse/misc/pro/UnlockProPatchKt {
|
||||
public static final fun getUnlockProPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||
}
|
||||
|
||||
public final class app/revanced/patches/nunl/ads/HideAdsPatchKt {
|
||||
public static final fun getHideAdsPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||
}
|
||||
|
||||
public final class app/revanced/patches/nunl/firebase/SpoofCertificatePatchKt {
|
||||
public static final fun getSpoofCertificatePatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||
}
|
||||
|
||||
public final class app/revanced/patches/nyx/misc/pro/UnlockProPatchKt {
|
||||
public static final fun getUnlockProPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||
}
|
||||
|
@ -0,0 +1,44 @@
|
||||
package app.revanced.patches.nunl.ads
|
||||
|
||||
import app.revanced.patcher.fingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
|
||||
internal val jwUtilCreateAdvertisementFingerprint = fingerprint {
|
||||
accessFlags(AccessFlags.PRIVATE, AccessFlags.STATIC)
|
||||
custom { methodDef, classDef ->
|
||||
classDef.type == "Lnl/sanomamedia/android/nu/video/util/JWUtil;" && methodDef.name == "createAdvertising"
|
||||
}
|
||||
}
|
||||
|
||||
internal val screenMapperFingerprint = fingerprint {
|
||||
accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL)
|
||||
returns("Lnl/nu/android/bff/domain/models/screen/ScreenEntity;")
|
||||
parameters("Lnl/nu/performance/api/client/objects/Screen;")
|
||||
|
||||
opcodes(
|
||||
Opcode.MOVE_RESULT_OBJECT,
|
||||
Opcode.IF_EQZ,
|
||||
Opcode.CHECK_CAST
|
||||
)
|
||||
|
||||
custom { methodDef, classDef ->
|
||||
classDef.type == "Lnl/nu/android/bff/data/mappers/ScreenMapper;" && methodDef.name == "map"
|
||||
}
|
||||
}
|
||||
|
||||
internal val nextPageRepositoryImplFingerprint = fingerprint {
|
||||
accessFlags(AccessFlags.PRIVATE, AccessFlags.FINAL)
|
||||
returns("Lnl/nu/android/bff/domain/models/Page;")
|
||||
parameters("Lnl/nu/performance/api/client/PacResponse;", "Ljava/lang/String;")
|
||||
|
||||
opcodes(
|
||||
Opcode.MOVE_RESULT_OBJECT,
|
||||
Opcode.IF_EQZ,
|
||||
Opcode.CHECK_CAST
|
||||
)
|
||||
|
||||
custom { methodDef, classDef ->
|
||||
classDef.type == "Lnl/nu/android/bff/data/repositories/NextPageRepositoryImpl;" && methodDef.name == "mapToPage"
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package app.revanced.patches.nunl.ads
|
||||
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.patch.bytecodePatch
|
||||
import app.revanced.patches.shared.misc.extension.sharedExtensionPatch
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
|
||||
@Suppress("unused")
|
||||
val hideAdsPatch = bytecodePatch(
|
||||
name = "Hide ads",
|
||||
description = "Hide ads and sponsored articles in list pages and remove pre-roll ads on videos.",
|
||||
) {
|
||||
compatibleWith("nl.sanomamedia.android.nu"("11.0.0", "11.0.1", "11.1.0"))
|
||||
|
||||
dependsOn(sharedExtensionPatch("nunl", mainActivityOnCreateHook))
|
||||
|
||||
execute {
|
||||
// Disable video pre-roll ads.
|
||||
// Whenever the app tries to create an ad via JWUtils.createAdvertising, don't actually tell the underlying JWPlayer library to do so => JWPlayer will not display ads.
|
||||
jwUtilCreateAdvertisementFingerprint.method.addInstructions(
|
||||
0,
|
||||
"""
|
||||
new-instance v0, Lcom/jwplayer/pub/api/configuration/ads/VastAdvertisingConfig${'$'}Builder;
|
||||
invoke-direct { v0 }, Lcom/jwplayer/pub/api/configuration/ads/VastAdvertisingConfig${'$'}Builder;-><init>()V
|
||||
invoke-virtual { v0 }, Lcom/jwplayer/pub/api/configuration/ads/VastAdvertisingConfig${'$'}Builder;->build()Lcom/jwplayer/pub/api/configuration/ads/VastAdvertisingConfig;
|
||||
move-result-object v0
|
||||
return-object v0
|
||||
""",
|
||||
)
|
||||
|
||||
// Filter injected content from API calls out of lists.
|
||||
arrayOf(screenMapperFingerprint, nextPageRepositoryImplFingerprint).forEach {
|
||||
// Index of instruction moving result of BlockPage;->getBlocks(...).
|
||||
val moveGetBlocksResultObjectIndex = it.patternMatch!!.startIndex
|
||||
it.method.apply {
|
||||
val moveInstruction = getInstruction<OneRegisterInstruction>(moveGetBlocksResultObjectIndex)
|
||||
|
||||
val listRegister = moveInstruction.registerA
|
||||
|
||||
// Add instruction after moving List<Block> to register and then filter this List<Block> in place.
|
||||
addInstructions(
|
||||
moveGetBlocksResultObjectIndex + 1,
|
||||
"""
|
||||
invoke-static { v$listRegister }, Lapp/revanced/extension/nunl/ads/HideAdsPatch;->filterAds(Ljava/util/List;)V
|
||||
""",
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package app.revanced.patches.nunl.ads
|
||||
|
||||
import app.revanced.patches.shared.misc.extension.extensionHook
|
||||
|
||||
internal val mainActivityOnCreateHook = extensionHook {
|
||||
custom { method, classDef ->
|
||||
classDef.type == "Lnl/sanomamedia/android/nu/main/NUMainActivity;" && method.name == "onCreate"
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package app.revanced.patches.nunl.firebase
|
||||
|
||||
import app.revanced.patcher.fingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
|
||||
internal val getFingerprintHashForPackageFingerprints = arrayOf(
|
||||
"Lcom/google/firebase/installations/remote/FirebaseInstallationServiceClient;",
|
||||
"Lcom/google/firebase/remoteconfig/internal/ConfigFetchHttpClient;",
|
||||
"Lcom/google/firebase/remoteconfig/internal/ConfigRealtimeHttpClient;"
|
||||
).map { className ->
|
||||
fingerprint {
|
||||
accessFlags(AccessFlags.PRIVATE)
|
||||
parameters()
|
||||
returns("Ljava/lang/String;")
|
||||
|
||||
custom { methodDef, classDef ->
|
||||
classDef.type == className && methodDef.name == "getFingerprintHashForPackage"
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package app.revanced.patches.nunl.firebase
|
||||
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.patch.bytecodePatch
|
||||
|
||||
@Suppress("unused")
|
||||
val spoofCertificatePatch = bytecodePatch(
|
||||
name = "Spoof certificate",
|
||||
description = "Spoofs the X-Android-Cert header to allow push messages.",
|
||||
) {
|
||||
compatibleWith("nl.sanomamedia.android.nu")
|
||||
|
||||
execute {
|
||||
getFingerprintHashForPackageFingerprints.forEach { fingerprint ->
|
||||
fingerprint.method.addInstructions(
|
||||
0,
|
||||
"""
|
||||
const-string v0, "eae41fc018df2731a9b6ae1ac327da44a288667b"
|
||||
return-object v0
|
||||
""",
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user