mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-01 23:24:28 +02:00
refactor: Hide paid promotion
setting now removes includes paid promotion
banner in Shorts player
This commit is contained in:
parent
0203354a1a
commit
c3ae530021
@ -3,14 +3,18 @@ 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.addInstructions
|
||||
import app.revanced.patcher.extensions.instruction
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.util.smali.ExternalLabel
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.shared.annotation.YouTubeCompatibility
|
||||
import app.revanced.shared.extensions.findMutableMethodOf
|
||||
import app.revanced.shared.extensions.injectHideCall
|
||||
import app.revanced.shared.extensions.toResult
|
||||
import app.revanced.shared.patches.mapping.ResourceMappingPatch
|
||||
import app.revanced.shared.util.integrations.Constants.ADS_PATH
|
||||
import org.jf.dexlib2.Opcode
|
||||
import org.jf.dexlib2.iface.instruction.formats.*
|
||||
|
||||
@ -20,11 +24,15 @@ import org.jf.dexlib2.iface.instruction.formats.*
|
||||
@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
|
||||
"id" to "ad_attribution",
|
||||
"layout" to "horizontal_card_list",
|
||||
"layout" to "album_card",
|
||||
"id" to "reel_player_badge",
|
||||
"id" to "reel_player_badge2"
|
||||
).map { (type, name) ->
|
||||
ResourceMappingPatch
|
||||
.resourceMappings
|
||||
.single { it.type == type && it.name == name }.id
|
||||
}
|
||||
private var patchSuccessArray = Array(resourceIds.size) {false}
|
||||
|
||||
@ -71,6 +79,28 @@ class GeneralAdsSecondaryBytecodePatch : BytecodePatch() {
|
||||
mutableMethod.implementation!!.injectHideCall(insertIndex, viewRegister, "ads/GeneralAdsPatch", "hideAlbumCards")
|
||||
patchSuccessArray[2] = true;
|
||||
}
|
||||
|
||||
resourceIds[3], resourceIds[4] -> { // paid content banner
|
||||
val insertIndex = index + 3
|
||||
val invokeInstruction = instructions.elementAt(insertIndex)
|
||||
if (invokeInstruction.opcode != Opcode.CHECK_CAST) return@forEachIndexed
|
||||
|
||||
val mutableMethod = context.proxy(classDef).mutableClass.findMutableMethodOf(method)
|
||||
val dummyRegister = (instructions.elementAt(index) as Instruction31i).registerA
|
||||
val viewRegister = (invokeInstruction as Instruction21c).registerA
|
||||
|
||||
mutableMethod.addInstructions(
|
||||
insertIndex + 1, """
|
||||
invoke-static {}, $ADS_PATH/GeneralAdsPatch;->hidePaidContentBanner()Z
|
||||
move-result v$dummyRegister
|
||||
if-eqz v$dummyRegister, :shown
|
||||
const v$viewRegister, 0x0
|
||||
""", listOf(ExternalLabel("shown", mutableMethod.instruction(insertIndex + 1)))
|
||||
)
|
||||
|
||||
patchSuccessArray[3] = true;
|
||||
patchSuccessArray[4] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else -> return@forEachIndexed
|
||||
|
Loading…
x
Reference in New Issue
Block a user