Skip to content

Commit 96e17cf

Browse files
LisoUseInAIKyriosoSumAtrIX
andauthored
feat(YouTube): Support version 19.09.38, 19.10.39 and 19.11.43 (#2971)
Co-authored-by: oSumAtrIX <[email protected]>
1 parent a7bd0b1 commit 96e17cf

File tree

77 files changed

+402
-288
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+402
-288
lines changed

api/revanced-patches.api

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,7 @@ public final class app/revanced/patches/shared/misc/mapping/ResourceMappingPatch
724724
public static final field INSTANCE Lapp/revanced/patches/shared/misc/mapping/ResourceMappingPatch;
725725
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
726726
public fun execute (Lapp/revanced/patcher/data/ResourceContext;)V
727+
public final fun get (Ljava/lang/String;Ljava/lang/String;)J
727728
}
728729

729730
public final class app/revanced/patches/shared/misc/mapping/ResourceMappingPatch$ResourceElement {
@@ -1846,11 +1847,12 @@ public final class app/revanced/patches/yuka/misc/unlockpremium/UnlockPremiumPat
18461847

18471848
public final class app/revanced/util/BytecodeUtilsKt {
18481849
public static final fun containsWideLiteralInstructionValue (Lcom/android/tools/smali/dexlib2/iface/Method;J)Z
1849-
public static final fun findIndexForIdResource (Lcom/android/tools/smali/dexlib2/iface/Method;Ljava/lang/String;)I
18501850
public static final fun findMutableMethodOf (Lapp/revanced/patcher/util/proxy/mutableTypes/MutableClass;Lcom/android/tools/smali/dexlib2/iface/Method;)Lapp/revanced/patcher/util/proxy/mutableTypes/MutableMethod;
18511851
public static final fun getException (Lapp/revanced/patcher/fingerprint/MethodFingerprint;)Lapp/revanced/patcher/patch/PatchException;
18521852
public static final fun indexOfFirstInstruction (Lcom/android/tools/smali/dexlib2/iface/Method;Lkotlin/jvm/functions/Function1;)I
18531853
public static final fun indexOfFirstWideLiteralInstructionValue (Lcom/android/tools/smali/dexlib2/iface/Method;J)I
1854+
public static final fun indexOfIdResource (Lcom/android/tools/smali/dexlib2/iface/Method;Ljava/lang/String;)I
1855+
public static final fun indexOfIdResourceOrThrow (Lcom/android/tools/smali/dexlib2/iface/Method;Ljava/lang/String;)I
18541856
public static final fun injectHideViewCall (Lapp/revanced/patcher/util/proxy/mutableTypes/MutableMethod;IILjava/lang/String;Ljava/lang/String;)V
18551857
public static final fun resultOrThrow (Lapp/revanced/patcher/fingerprint/MethodFingerprint;)Lapp/revanced/patcher/fingerprint/MethodFingerprintResult;
18561858
public static final fun returnEarly (Ljava/util/List;Z)V

src/main/kotlin/app/revanced/patches/shared/misc/mapping/ResourceMappingPatch.kt

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,15 @@ import java.util.concurrent.Executors
88
import java.util.concurrent.TimeUnit
99

1010
object ResourceMappingPatch : ResourcePatch() {
11-
internal lateinit var resourceMappings: List<ResourceElement>
12-
private set
11+
private val resourceMappings = Collections.synchronizedList(mutableListOf<ResourceElement>())
1312

1413
private val THREAD_COUNT = Runtime.getRuntime().availableProcessors()
1514
private val threadPoolExecutor = Executors.newFixedThreadPool(THREAD_COUNT)
1615

1716
override fun execute(context: ResourceContext) {
18-
// save the file in memory to concurrently read from
17+
// sSve the file in memory to concurrently read from it.
1918
val resourceXmlFile = context.get("res/values/public.xml").readBytes()
2019

21-
// create a synchronized list to store the resource mappings
22-
val mappings = Collections.synchronizedList(mutableListOf<ResourceElement>())
23-
2420
for (threadIndex in 0 until THREAD_COUNT) {
2521
threadPoolExecutor.execute thread@{
2622
context.xmlEditor[resourceXmlFile.inputStream()].use { editor ->
@@ -33,7 +29,7 @@ object ResourceMappingPatch : ResourcePatch() {
3329
val batchStart = jobSize * threadIndex
3430
val batchEnd = jobSize * (threadIndex + 1)
3531
element@ for (i in batchStart until batchEnd) {
36-
// make sure to not go out of bounds when rounding errors occur at calculating the jobSize
32+
// Prevent out of bounds.
3733
if (i >= resourcesLength) return@thread
3834

3935
val node = resources.item(i)
@@ -46,18 +42,18 @@ object ResourceMappingPatch : ResourcePatch() {
4642

4743
val id = node.getAttribute("id").substring(2).toLong(16)
4844

49-
mappings.add(ResourceElement(typeAttribute, nameAttribute, id))
45+
resourceMappings.add(ResourceElement(typeAttribute, nameAttribute, id))
5046
}
5147
}
5248
}
5349
}
5450

55-
threadPoolExecutor
56-
.also { it.shutdown() }
57-
.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS)
58-
59-
resourceMappings = mappings
51+
threadPoolExecutor.also { it.shutdown() }.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS)
6052
}
6153

54+
operator fun get(type: String, name: String) = resourceMappings.first {
55+
it.type == type && it.name == name
56+
}.id
57+
6258
data class ResourceElement(val type: String, val name: String, val id: Long)
6359
}

src/main/kotlin/app/revanced/patches/spotify/navbar/PremiumNavbarTabResourcePatch.kt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,11 @@ object PremiumNavbarTabResourcePatch : ResourcePatch() {
1111
internal var premiumTabId = -1L
1212

1313
override fun execute(context: ResourceContext) {
14-
premiumTabId = ResourceMappingPatch.resourceMappings.single {
15-
it.type == "id" && it.name == "premium_tab"
16-
}.id
14+
premiumTabId = ResourceMappingPatch["id", "premium_tab"]
1715

18-
showBottomNavigationItemsTextId = ResourceMappingPatch.resourceMappings.single {
19-
it.type == "bool" && it.name == "show_bottom_navigation_items_text"
20-
}.id
16+
showBottomNavigationItemsTextId = ResourceMappingPatch[
17+
"bool",
18+
"show_bottom_navigation_items_text",
19+
]
2120
}
2221
}

src/main/kotlin/app/revanced/patches/youtube/ad/general/HideAdsPatch.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction35c
4242
"19.06.39",
4343
"19.07.40",
4444
"19.08.36",
45-
"19.09.37"
45+
"19.09.38",
46+
"19.10.39",
47+
"19.11.43"
4648
],
4749
),
4850
],

src/main/kotlin/app/revanced/patches/youtube/ad/general/HideAdsResourcePatch.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import app.revanced.patches.youtube.misc.settings.SettingsPatch
1414
LithoFilterPatch::class,
1515
SettingsPatch::class,
1616
ResourceMappingPatch::class,
17-
AddResourcesPatch::class
18-
]
17+
AddResourcesPatch::class,
18+
],
1919
)
2020
object HideAdsResourcePatch : ResourcePatch() {
2121
private const val FILTER_CLASS_DESCRIPTOR =
@@ -35,11 +35,11 @@ object HideAdsResourcePatch : ResourcePatch() {
3535
SwitchPreference("revanced_hide_products_banner"),
3636
SwitchPreference("revanced_hide_shopping_links"),
3737
SwitchPreference("revanced_hide_web_search_results"),
38-
SwitchPreference("revanced_hide_merchandise_banners")
38+
SwitchPreference("revanced_hide_merchandise_banners"),
3939
)
4040

4141
LithoFilterPatch.addFilter(FILTER_CLASS_DESCRIPTOR)
4242

43-
adAttributionId = ResourceMappingPatch.resourceMappings.single { it.name == "ad_attribution" }.id
43+
adAttributionId = ResourceMappingPatch["id", "ad_attribution"]
4444
}
4545
}

src/main/kotlin/app/revanced/patches/youtube/ad/getpremium/HideGetPremiumPatch.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
3636
"19.06.39",
3737
"19.07.40",
3838
"19.08.36",
39-
"19.09.37"
39+
"19.09.38",
40+
"19.10.39",
41+
"19.11.43"
4042
]
4143
)
4244
]

src/main/kotlin/app/revanced/patches/youtube/ad/video/VideoAdsPatch.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ import app.revanced.patches.youtube.misc.settings.SettingsPatch
4141
"19.06.39",
4242
"19.07.40",
4343
"19.08.36",
44-
"19.09.37"
44+
"19.09.38",
45+
"19.10.39",
46+
"19.11.43"
4547
]
4648
)
4749
]

src/main/kotlin/app/revanced/patches/youtube/interaction/copyvideourl/CopyVideoUrlBytecodePatch.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ import app.revanced.patches.youtube.video.information.VideoInformationPatch
2929
"19.06.39",
3030
"19.07.40",
3131
"19.08.36",
32-
"19.09.37"
32+
"19.09.38",
33+
"19.10.39",
34+
"19.11.43"
3335
],
3436
),
3537
],

src/main/kotlin/app/revanced/patches/youtube/interaction/dialog/RemoveViewerDiscretionDialogPatch.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
3838
"19.06.39",
3939
"19.07.40",
4040
"19.08.36",
41-
"19.09.37"
41+
"19.09.38",
42+
"19.10.39",
43+
"19.11.43"
4244
]
4345
)
4446
]

src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/DownloadsPatch.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ import app.revanced.util.resultOrThrow
3535
"19.06.39",
3636
"19.07.40",
3737
"19.08.36",
38-
"19.09.37"
38+
"19.09.38",
39+
"19.10.39",
40+
"19.11.43"
3941
],
4042
),
4143
],

0 commit comments

Comments
 (0)