|
|
|
@@ -7,9 +7,11 @@ import app.revanced.patcher.data.BytecodeContext
|
|
|
|
import app.revanced.patcher.data.toMethodWalker
|
|
|
|
import app.revanced.patcher.data.toMethodWalker
|
|
|
|
import app.revanced.patcher.extensions.addInstruction
|
|
|
|
import app.revanced.patcher.extensions.addInstruction
|
|
|
|
import app.revanced.patcher.extensions.addInstructions
|
|
|
|
import app.revanced.patcher.extensions.addInstructions
|
|
|
|
|
|
|
|
import app.revanced.patcher.extensions.replaceInstruction
|
|
|
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
|
|
|
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
|
|
|
|
import app.revanced.patcher.patch.BytecodePatch
|
|
|
|
import app.revanced.patcher.patch.BytecodePatch
|
|
|
|
import app.revanced.patcher.patch.PatchResult
|
|
|
|
import app.revanced.patcher.patch.PatchResult
|
|
|
|
|
|
|
|
import app.revanced.patcher.patch.PatchResultError
|
|
|
|
import app.revanced.patcher.patch.PatchResultSuccess
|
|
|
|
import app.revanced.patcher.patch.PatchResultSuccess
|
|
|
|
import app.revanced.patcher.patch.annotations.DependsOn
|
|
|
|
import app.revanced.patcher.patch.annotations.DependsOn
|
|
|
|
import app.revanced.patcher.patch.annotations.Patch
|
|
|
|
import app.revanced.patcher.patch.annotations.Patch
|
|
|
|
@@ -17,7 +19,6 @@ import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
|
|
|
import app.revanced.patches.shared.fingerprints.SeekbarFingerprint
|
|
|
|
import app.revanced.patches.shared.fingerprints.SeekbarFingerprint
|
|
|
|
import app.revanced.patches.shared.fingerprints.SeekbarOnDrawFingerprint
|
|
|
|
import app.revanced.patches.shared.fingerprints.SeekbarOnDrawFingerprint
|
|
|
|
import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch
|
|
|
|
import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch
|
|
|
|
import app.revanced.patches.youtube.layout.autocaptions.fingerprints.StartVideoInformerFingerprint
|
|
|
|
|
|
|
|
import app.revanced.patches.youtube.layout.sponsorblock.annotations.SponsorBlockCompatibility
|
|
|
|
import app.revanced.patches.youtube.layout.sponsorblock.annotations.SponsorBlockCompatibility
|
|
|
|
import app.revanced.patches.youtube.layout.sponsorblock.bytecode.fingerprints.*
|
|
|
|
import app.revanced.patches.youtube.layout.sponsorblock.bytecode.fingerprints.*
|
|
|
|
import app.revanced.patches.youtube.layout.sponsorblock.resource.patch.SponsorBlockResourcePatch
|
|
|
|
import app.revanced.patches.youtube.layout.sponsorblock.resource.patch.SponsorBlockResourcePatch
|
|
|
|
@@ -29,7 +30,9 @@ import app.revanced.patches.youtube.misc.video.videoid.patch.VideoIdPatch
|
|
|
|
import org.jf.dexlib2.Opcode
|
|
|
|
import org.jf.dexlib2.Opcode
|
|
|
|
import org.jf.dexlib2.iface.instruction.*
|
|
|
|
import org.jf.dexlib2.iface.instruction.*
|
|
|
|
import org.jf.dexlib2.iface.instruction.formats.Instruction35c
|
|
|
|
import org.jf.dexlib2.iface.instruction.formats.Instruction35c
|
|
|
|
|
|
|
|
import org.jf.dexlib2.iface.reference.FieldReference
|
|
|
|
import org.jf.dexlib2.iface.reference.MethodReference
|
|
|
|
import org.jf.dexlib2.iface.reference.MethodReference
|
|
|
|
|
|
|
|
import org.jf.dexlib2.iface.reference.StringReference
|
|
|
|
|
|
|
|
|
|
|
|
@Patch
|
|
|
|
@Patch
|
|
|
|
@DependsOn(
|
|
|
|
@DependsOn(
|
|
|
|
@@ -52,7 +55,6 @@ class SponsorBlockBytecodePatch : BytecodePatch(
|
|
|
|
NextGenWatchLayoutFingerprint,
|
|
|
|
NextGenWatchLayoutFingerprint,
|
|
|
|
AppendTimeFingerprint,
|
|
|
|
AppendTimeFingerprint,
|
|
|
|
PlayerOverlaysLayoutInitFingerprint,
|
|
|
|
PlayerOverlaysLayoutInitFingerprint,
|
|
|
|
StartVideoInformerFingerprint
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
|
|
|
|
|
|
|
|
@@ -233,6 +235,39 @@ class SponsorBlockBytecodePatch : BytecodePatch(
|
|
|
|
"invoke-static {p0}, Lapp/revanced/integrations/sponsorblock/player/ui/SponsorBlockView;->initialize(Ljava/lang/Object;)V"
|
|
|
|
"invoke-static {p0}, Lapp/revanced/integrations/sponsorblock/player/ui/SponsorBlockView;->initialize(Ljava/lang/Object;)V"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// get rectangle field name
|
|
|
|
|
|
|
|
RectangleFieldInvalidatorFingerprint.resolve(context, seekbarSignatureResult.classDef)
|
|
|
|
|
|
|
|
val rectangleFieldInvalidatorInstructions =
|
|
|
|
|
|
|
|
RectangleFieldInvalidatorFingerprint.result!!.method.implementation!!.instructions
|
|
|
|
|
|
|
|
val rectangleFieldName =
|
|
|
|
|
|
|
|
((rectangleFieldInvalidatorInstructions.elementAt(rectangleFieldInvalidatorInstructions.count() - 3) as ReferenceInstruction).reference as FieldReference).name
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// replace the "replaceMeWith*" strings
|
|
|
|
|
|
|
|
context
|
|
|
|
|
|
|
|
.proxy(context.classes.first { it.type.endsWith("PlayerController;") })
|
|
|
|
|
|
|
|
.mutableClass
|
|
|
|
|
|
|
|
.methods
|
|
|
|
|
|
|
|
.find { it.name == "setSponsorBarRect" }
|
|
|
|
|
|
|
|
?.let { method ->
|
|
|
|
|
|
|
|
fun MutableMethod.replaceStringInstruction(index: Int, instruction: Instruction, with: String) {
|
|
|
|
|
|
|
|
val register = (instruction as OneRegisterInstruction).registerA
|
|
|
|
|
|
|
|
this.replaceInstruction(
|
|
|
|
|
|
|
|
index, "const-string v$register, \"$with\""
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for ((index, it) in method.implementation!!.instructions.withIndex()) {
|
|
|
|
|
|
|
|
if (it.opcode.ordinal != Opcode.CONST_STRING.ordinal) continue
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
when (((it as ReferenceInstruction).reference as StringReference).string) {
|
|
|
|
|
|
|
|
"replaceMeWithsetSponsorBarRect" -> method.replaceStringInstruction(
|
|
|
|
|
|
|
|
index,
|
|
|
|
|
|
|
|
it,
|
|
|
|
|
|
|
|
rectangleFieldName
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} ?: return PatchResultError("Could not find the method which contains the replaceMeWith* strings")
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: isSBChannelWhitelisting implementation
|
|
|
|
// TODO: isSBChannelWhitelisting implementation
|
|
|
|
|
|
|
|
|
|
|
|
return PatchResultSuccess()
|
|
|
|
return PatchResultSuccess()
|
|
|
|
|