bump v2.147.0

This commit is contained in:
inotia00
2022-12-23 17:49:31 +09:00
parent 74aecf4720
commit 187d905bdb
1034 changed files with 21004 additions and 11645 deletions

View File

@ -0,0 +1,20 @@
package app.revanced.patches.youtube.ads.general.bytecode.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.Opcode
object ComponentContextParserFingerprint : MethodFingerprint(
opcodes = listOf(
Opcode.INVOKE_INTERFACE,
Opcode.MOVE_RESULT_OBJECT,
Opcode.CHECK_CAST,
Opcode.INVOKE_VIRTUAL,
Opcode.GOTO,
Opcode.INVOKE_VIRTUAL,
Opcode.CONST_16,
Opcode.INVOKE_VIRTUAL,
Opcode.IPUT_OBJECT,
Opcode.NEW_INSTANCE
),
strings = listOf("LoggingProperties are not in proto format")
)

View File

@ -0,0 +1,10 @@
package app.revanced.patches.youtube.ads.general.bytecode.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.Opcode
object EmptyComponentBuilderFingerprint : MethodFingerprint(
opcodes = listOf(
Opcode.INVOKE_STATIC_RANGE
),
)

View File

@ -0,0 +1,99 @@
package app.revanced.patches.youtube.ads.general.bytecode.patch
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.addInstruction
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.extensions.instruction
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultError
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.util.proxy.mutableTypes.MutableClass
import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.patches.youtube.ads.general.bytecode.fingerprints.ComponentContextParserFingerprint
import app.revanced.patches.youtube.ads.general.bytecode.fingerprints.EmptyComponentBuilderFingerprint
import app.revanced.shared.annotation.YouTubeCompatibility
import app.revanced.shared.patches.mapping.ResourceMappingPatch
import app.revanced.shared.util.bytecode.BytecodeHelper
import app.revanced.shared.util.integrations.Constants.ADS_PATH
import org.jf.dexlib2.builder.instruction.BuilderInstruction21s
import org.jf.dexlib2.iface.instruction.formats.Instruction31i
import org.jf.dexlib2.iface.instruction.Instruction
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
import org.jf.dexlib2.iface.reference.FieldReference
import org.jf.dexlib2.iface.reference.MethodReference
import org.jf.dexlib2.Opcode
@DependsOn([ResourceMappingPatch::class])
@Name("hide-general-ads-bytecode-patch")
@YouTubeCompatibility
@Version("0.0.1")
class GeneralAdsBytecodePatch : BytecodePatch(
listOf(ComponentContextParserFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
ComponentContextParserFingerprint.result?.let { result ->
val builderMethodIndex = EmptyComponentBuilderFingerprint
.also { it.resolve(context, result.mutableMethod, result.mutableClass) }
.let { it.result!!.scanResult.patternScanResult!!.startIndex }
val emptyComponentFieldIndex = builderMethodIndex + 2
with(result.mutableMethod) {
val insertHookIndex = implementation!!.instructions.indexOfFirst {
it.opcode == Opcode.CONST_16 &&
(it as BuilderInstruction21s).narrowLiteral == 124
} + 3
val stringBuilderRegister = (instruction(insertHookIndex) as OneRegisterInstruction).registerA
val clobberedRegister = (instruction(insertHookIndex - 3) as OneRegisterInstruction).registerA
val bufferIndex = implementation!!.instructions.indexOfFirst {
it.opcode == Opcode.CONST &&
(it as Instruction31i).narrowLiteral == 183314536
} - 1
val bufferRegister = (instruction(bufferIndex) as OneRegisterInstruction).registerA
val builderMethodDescriptor = instruction(builderMethodIndex).toDescriptor()
val emptyComponentFieldDescriptor = instruction(emptyComponentFieldIndex).toDescriptor()
addInstructions(
insertHookIndex, // right after setting the component.pathBuilder field,
"""
invoke-static {v$stringBuilderRegister, v$bufferRegister}, $ADS_PATH/LithoFilterPatch;->filter(Ljava/lang/StringBuilder;Ljava/lang/String;)Z
move-result v$clobberedRegister
if-eqz v$clobberedRegister, :not_an_ad
move-object/from16 v$bufferRegister, p1
invoke-static {v$bufferRegister}, $builderMethodDescriptor
move-result-object v0
iget-object v0, v0, $emptyComponentFieldDescriptor
return-object v0
""",
listOf(ExternalLabel("not_an_ad", instruction(insertHookIndex)))
)
}
} ?: return PatchResultError("Could not find the method to hook.")
BytecodeHelper.patchStatus(context, "GeneralAds")
return PatchResultSuccess()
}
private companion object {
fun Instruction.toDescriptor() = when (val reference = (this as? ReferenceInstruction)?.reference) {
is MethodReference -> "${reference.definingClass}->${reference.name}(${
reference.parameterTypes.joinToString(
""
) { it }
})${reference.returnType}"
is FieldReference -> "${reference.definingClass}->${reference.name}:${reference.type}"
else -> throw PatchResultError("Unsupported reference type")
}
}
}

View File

@ -0,0 +1,80 @@
package app.revanced.patches.youtube.ads.general.bytecode.patch
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.shared.annotation.YouTubeCompatibility
import app.revanced.shared.extensions.findMutableMethodOf
import app.revanced.shared.extensions.injectHideCall
import app.revanced.shared.patches.mapping.ResourceMappingPatch
import org.jf.dexlib2.iface.instruction.formats.*
import org.jf.dexlib2.Opcode
@Name("hide-general-ads-secondary-bytecode-patch")
@DependsOn([ResourceMappingPatch::class])
@YouTubeCompatibility
@Version("0.0.1")
class GeneralAdsSecondaryBytecodePatch : BytecodePatch() {
private val resourceIds = arrayOf(
"ad_attribution",
"horizontal_card_list",
"album_card"
).map { name ->
ResourceMappingPatch.resourceMappings.single { it.name == name }.id
}
override fun execute(context: BytecodeContext): PatchResult {
context.classes.forEach { classDef ->
classDef.methods.forEach { method ->
with(method.implementation) {
this?.instructions?.forEachIndexed { index, instruction ->
when (instruction.opcode) {
Opcode.CONST -> {
when ((instruction as Instruction31i).wideLiteral) {
resourceIds[0] -> { // general ads
val insertIndex = index + 1
val invokeInstruction = instructions.elementAt(insertIndex)
if (invokeInstruction.opcode != Opcode.INVOKE_VIRTUAL) return@forEachIndexed
val mutableMethod = context.proxy(classDef).mutableClass.findMutableMethodOf(method)
val viewRegister = (invokeInstruction as Instruction35c).registerC
mutableMethod.implementation!!.injectHideCall(insertIndex, viewRegister, "ads/GeneralAdsPatch", "hideAdAttributionView")
}
resourceIds[1] -> { // breaking news
val insertIndex = index + 4
val invokeInstruction = instructions.elementAt(insertIndex)
if (invokeInstruction.opcode != Opcode.CHECK_CAST) return@forEachIndexed
val mutableMethod = context.proxy(classDef).mutableClass.findMutableMethodOf(method)
val viewRegister = (invokeInstruction as Instruction21c).registerA
mutableMethod.implementation!!.injectHideCall(insertIndex, viewRegister, "ads/GeneralAdsPatch", "hideBreakingNewsShelf")
}
resourceIds[2] -> { // album cards
val insertIndex = index + 4
val invokeInstruction = instructions.elementAt(insertIndex)
if (invokeInstruction.opcode != Opcode.CHECK_CAST) return@forEachIndexed
val mutableMethod = context.proxy(classDef).mutableClass.findMutableMethodOf(method)
val viewRegister = (invokeInstruction as Instruction21c).registerA
mutableMethod.implementation!!.injectHideCall(insertIndex, viewRegister, "ads/GeneralAdsPatch", "hideAlbumCards")
}
}
}
else -> return@forEachIndexed
}
}
}
}
}
return PatchResultSuccess()
}
}

View File

@ -0,0 +1,85 @@
package app.revanced.patches.youtube.ads.general.resource.patch
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patches.youtube.ads.general.bytecode.patch.GeneralAdsBytecodePatch
import app.revanced.patches.youtube.ads.general.bytecode.patch.GeneralAdsSecondaryBytecodePatch
import app.revanced.patches.youtube.misc.litho.filter.patch.LithoFilterPatch
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
import app.revanced.shared.annotation.YouTubeCompatibility
import app.revanced.shared.extensions.doRecursively
import app.revanced.shared.extensions.startsWithAny
import app.revanced.shared.util.resources.ResourceHelper
import org.w3c.dom.Element
@Patch
@Name("hide-general-ads")
@Description("Hooks the method which parses the bytes into a ComponentContext to filter components.")
@DependsOn(
[
GeneralAdsBytecodePatch::class,
GeneralAdsSecondaryBytecodePatch::class,
LithoFilterPatch::class,
SettingsPatch::class
]
)
@YouTubeCompatibility
@Version("0.0.1")
class GeneralAdsPatch : ResourcePatch {
private val resourceFileNames = arrayOf(
"promoted_",
"promotion_",
"compact_premium_",
"compact_promoted_",
)
private val replacements = arrayOf(
"height",
"width",
"marginTop"
)
override fun execute(context: ResourceContext): PatchResult {
context.forEach {
if (!it.name.startsWithAny(*resourceFileNames)) return@forEach
// for each file in the "layouts" directory replace all necessary attributes content
context.xmlEditor[it.absolutePath].use { editor ->
editor.file.doRecursively { node ->
replacements.forEach replacement@{ replacement ->
if (node !is Element) return@replacement
node.getAttributeNode("android:layout_$replacement")?.let { attribute ->
attribute.textContent = "0.0dip"
}
}
}
}
}
/*
add settings
*/
ResourceHelper.addSettings(
context,
"PREFERENCE_CATEGORY: REVANCED_SETTINGS",
"PREFERENCE: ADS_SETTINGS",
"SETTINGS: HIDE_GENERAL_ADS"
)
ResourceHelper.patchSuccess(
context,
"hide-general-ads"
)
return PatchResultSuccess()
}
}

View File

@ -0,0 +1,37 @@
package app.revanced.patches.youtube.ads.video.bytecode.patch
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patches.youtube.misc.videoid.mainstream.patch.MainstreamVideoIdPatch
import app.revanced.shared.annotation.YouTubeCompatibility
import app.revanced.shared.patches.videoads.GeneralVideoAdsPatch
import app.revanced.shared.util.bytecode.BytecodeHelper
import app.revanced.shared.util.integrations.Constants.ADS_PATH
@DependsOn(
[
GeneralVideoAdsPatch::class,
MainstreamVideoIdPatch::class
]
)
@Name("hide-video-ads-bytecode-patch")
@YouTubeCompatibility
@Version("0.0.1")
class VideoAdsBytecodePatch : BytecodePatch() {
override fun execute(context: BytecodeContext): PatchResult {
val INTEGRATIONS_CLASS_DESCRIPTOR = "$ADS_PATH/HideVideoAdsPatch;->hideVideoAds()Z"
GeneralVideoAdsPatch.injectLegacyAds(INTEGRATIONS_CLASS_DESCRIPTOR)
GeneralVideoAdsPatch.injectMainstreamAds(INTEGRATIONS_CLASS_DESCRIPTOR)
BytecodeHelper.patchStatus(context, "VideoAds")
return PatchResultSuccess()
}
}

View File

@ -0,0 +1,56 @@
package app.revanced.patches.youtube.ads.video.resource.patch
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patches.youtube.ads.video.bytecode.patch.VideoAdsBytecodePatch
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
import app.revanced.shared.annotation.YouTubeCompatibility
import app.revanced.shared.util.resources.ResourceHelper
@Patch
@Name("hide-video-ads")
@Description("Removes ads in the video player.")
@DependsOn(
[
VideoAdsBytecodePatch::class,
SettingsPatch::class
]
)
@YouTubeCompatibility
@Version("0.0.1")
class VideoAdsPatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
/*
add settings
*/
ResourceHelper.addSettings(
context,
"PREFERENCE_CATEGORY: REVANCED_SETTINGS",
"PREFERENCE: ADS_SETTINGS",
"SETTINGS: HIDE_VIDEO_ADS"
)
ResourceHelper.addSettings2(
context,
"PREFERENCE_CATEGORY: REVANCED_EXTENDED_SETTINGS",
"PREFERENCE: EXTENDED_SETTINGS",
"SETTINGS: EXPERIMENTAL_FLAGS",
"SETTINGS: FIX_VIDEO_PLAYBACK"
)
ResourceHelper.patchSuccess(
context,
"hide-video-ads"
)
return PatchResultSuccess()
}
}