Skip to content

Commit bedde60

Browse files
authored
feat(NU.nl): Support version 11.3.0 (#4925)
1 parent 845084d commit bedde60

File tree

4 files changed

+12
-18
lines changed

4 files changed

+12
-18
lines changed

extensions/nunl/src/main/java/app/revanced/extension/nunl/ads/HideAdsPatch.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public static void filterAds(List<Block> blocks) {
8282

8383
// Filter HeaderBlock with known ads until next HeaderBlock.
8484
if (currentBlock instanceof HeaderBlock headerBlock) {
85-
StyledText headerText = headerBlock.component20();
85+
StyledText headerText = headerBlock.getTitle();
8686
if (headerText != null) {
8787
skipFullHeader = false;
8888
for (String blockedHeaderBlock : blockedHeaderBlocks) {

extensions/nunl/stub/src/main/java/nl/nu/performance/api/client/objects/HeaderBlock.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
import nl.nu.performance.api.client.interfaces.Block;
44

55
public class HeaderBlock extends Block {
6-
// returns title
7-
public final StyledText component20() {
6+
public final StyledText getTitle() {
87
throw new UnsupportedOperationException("Stub");
98
}
109
}

patches/src/main/kotlin/app/revanced/patches/nunl/ads/Fingerprints.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import app.revanced.patcher.fingerprint
44
import com.android.tools.smali.dexlib2.AccessFlags
55
import com.android.tools.smali.dexlib2.Opcode
66

7-
internal val jwUtilCreateAdvertisementFingerprint = fingerprint {
8-
accessFlags(AccessFlags.PRIVATE, AccessFlags.STATIC)
7+
internal val jwPlayerConfigFingerprint = fingerprint {
8+
accessFlags(AccessFlags.PUBLIC)
99
custom { methodDef, classDef ->
10-
classDef.type == "Lnl/sanomamedia/android/nu/video/util/JWUtil;" && methodDef.name == "createAdvertising"
10+
classDef.type == "Lcom/jwplayer/pub/api/configuration/PlayerConfig${'$'}Builder;" && methodDef.name == "advertisingConfig"
1111
}
1212
}
1313

patches/src/main/kotlin/app/revanced/patches/nunl/ads/HideAdsPatch.kt

+7-12
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,27 @@ package app.revanced.patches.nunl.ads
22

33
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
44
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
5+
import app.revanced.patcher.extensions.InstructionExtensions.removeInstructions
56
import app.revanced.patcher.patch.bytecodePatch
67
import app.revanced.patches.shared.misc.extension.sharedExtensionPatch
8+
import app.revanced.util.indexOfFirstInstructionOrThrow
9+
import com.android.tools.smali.dexlib2.Opcode
710
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
811

912
@Suppress("unused")
1013
val hideAdsPatch = bytecodePatch(
1114
name = "Hide ads",
1215
description = "Hide ads and sponsored articles in list pages and remove pre-roll ads on videos.",
1316
) {
14-
compatibleWith("nl.sanomamedia.android.nu"("11.0.0", "11.0.1", "11.1.0"))
17+
compatibleWith("nl.sanomamedia.android.nu"("11.3.0"))
1518

1619
dependsOn(sharedExtensionPatch("nunl", mainActivityOnCreateHook))
1720

1821
execute {
1922
// Disable video pre-roll ads.
20-
// 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.
21-
jwUtilCreateAdvertisementFingerprint.method.addInstructions(
22-
0,
23-
"""
24-
new-instance v0, Lcom/jwplayer/pub/api/configuration/ads/VastAdvertisingConfig${'$'}Builder;
25-
invoke-direct { v0 }, Lcom/jwplayer/pub/api/configuration/ads/VastAdvertisingConfig${'$'}Builder;-><init>()V
26-
invoke-virtual { v0 }, Lcom/jwplayer/pub/api/configuration/ads/VastAdvertisingConfig${'$'}Builder;->build()Lcom/jwplayer/pub/api/configuration/ads/VastAdvertisingConfig;
27-
move-result-object v0
28-
return-object v0
29-
""",
30-
)
23+
// Whenever the app tries to define the advertising config for JWPlayer, don't set the advertising config and directly return.
24+
val iputInstructionIndex = jwPlayerConfigFingerprint.method.indexOfFirstInstructionOrThrow(Opcode.IPUT_OBJECT)
25+
jwPlayerConfigFingerprint.method.removeInstructions(iputInstructionIndex, 1)
3126

3227
// Filter injected content from API calls out of lists.
3328
arrayOf(screenMapperFingerprint, nextPageRepositoryImplFingerprint).forEach {

0 commit comments

Comments
 (0)