feat: hide-infocard-suggestions
patch (#107)
This commit is contained in:
parent
5cb9fb3661
commit
31a767adbb
|
@ -0,0 +1,13 @@
|
||||||
|
package app.revanced.patches.youtube.ad.infocardsuggestions.annotations
|
||||||
|
|
||||||
|
import app.revanced.patcher.annotation.Compatibility
|
||||||
|
import app.revanced.patcher.annotation.Package
|
||||||
|
|
||||||
|
@Compatibility(
|
||||||
|
[Package(
|
||||||
|
"com.google.android.youtube", arrayOf("17.25.34")
|
||||||
|
)]
|
||||||
|
)
|
||||||
|
@Target(AnnotationTarget.CLASS)
|
||||||
|
@Retention(AnnotationRetention.RUNTIME)
|
||||||
|
internal annotation class HideInfocardSuggestionsCompatibility
|
|
@ -0,0 +1,24 @@
|
||||||
|
package app.revanced.patches.youtube.ad.infocardsuggestions.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.annotation.Name
|
||||||
|
import app.revanced.patcher.annotation.Version
|
||||||
|
import app.revanced.patcher.extensions.or
|
||||||
|
import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod
|
||||||
|
import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod
|
||||||
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
|
import app.revanced.patches.youtube.ad.infocardsuggestions.annotations.HideInfocardSuggestionsCompatibility
|
||||||
|
import org.jf.dexlib2.AccessFlags
|
||||||
|
|
||||||
|
@Name("hide-infocard-suggestions-fingerprint")
|
||||||
|
@MatchingMethod("Liff;", "i")
|
||||||
|
@FuzzyPatternScanMethod(2)
|
||||||
|
@HideInfocardSuggestionsCompatibility
|
||||||
|
@Version("0.0.1")
|
||||||
|
object HideInfocardSuggestionsFingerprint : MethodFingerprint(
|
||||||
|
"Ljava/lang/Boolean;",
|
||||||
|
AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
listOf("vibrator"),
|
||||||
|
null
|
||||||
|
)
|
|
@ -0,0 +1,24 @@
|
||||||
|
package app.revanced.patches.youtube.ad.infocardsuggestions.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.annotation.Name
|
||||||
|
import app.revanced.patcher.annotation.Version
|
||||||
|
import app.revanced.patcher.extensions.or
|
||||||
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
|
import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod
|
||||||
|
import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod
|
||||||
|
import app.revanced.patches.youtube.ad.infocardsuggestions.annotations.HideInfocardSuggestionsCompatibility
|
||||||
|
import org.jf.dexlib2.AccessFlags
|
||||||
|
|
||||||
|
@Name("hide-infocard-suggestions-parent-fingerprint")
|
||||||
|
@MatchingMethod("Liff;", "lE")
|
||||||
|
@FuzzyPatternScanMethod(2)
|
||||||
|
@HideInfocardSuggestionsCompatibility
|
||||||
|
@Version("0.0.1")
|
||||||
|
object HideInfocardSuggestionsParentFingerprint : MethodFingerprint(
|
||||||
|
"Ljava/lang/String;",
|
||||||
|
AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||||
|
listOf(),
|
||||||
|
null,
|
||||||
|
listOf("player_overlay_info_card_teaser"),
|
||||||
|
null
|
||||||
|
)
|
|
@ -0,0 +1,71 @@
|
||||||
|
package app.revanced.patches.youtube.ad.infocardsuggestions.patch
|
||||||
|
|
||||||
|
import app.revanced.patcher.annotation.Description
|
||||||
|
import app.revanced.patcher.annotation.Name
|
||||||
|
import app.revanced.patcher.annotation.Version
|
||||||
|
import app.revanced.patcher.data.impl.BytecodeData
|
||||||
|
import app.revanced.patcher.extensions.addInstruction
|
||||||
|
import app.revanced.patcher.extensions.addInstructions
|
||||||
|
import app.revanced.patcher.extensions.removeInstruction
|
||||||
|
import app.revanced.patcher.extensions.removeInstructions
|
||||||
|
import app.revanced.patcher.fingerprint.method.utils.MethodFingerprintUtils.resolve
|
||||||
|
import app.revanced.patcher.patch.annotations.Dependencies
|
||||||
|
import app.revanced.patcher.patch.annotations.Patch
|
||||||
|
import app.revanced.patcher.patch.impl.BytecodePatch
|
||||||
|
import app.revanced.patcher.patch.PatchResult
|
||||||
|
import app.revanced.patcher.patch.PatchResultError
|
||||||
|
import app.revanced.patcher.patch.PatchResultSuccess
|
||||||
|
import app.revanced.patcher.util.smali.toBuilderInstruction
|
||||||
|
import app.revanced.patches.youtube.ad.infocardsuggestions.annotations.HideInfocardSuggestionsCompatibility
|
||||||
|
import app.revanced.patches.youtube.ad.infocardsuggestions.fingerprints.HideInfocardSuggestionsFingerprint
|
||||||
|
import app.revanced.patches.youtube.ad.infocardsuggestions.fingerprints.HideInfocardSuggestionsParentFingerprint
|
||||||
|
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||||
|
import org.jf.dexlib2.Opcode
|
||||||
|
import org.jf.dexlib2.builder.instruction.BuilderInstruction21t
|
||||||
|
import org.jf.dexlib2.builder.instruction.BuilderInstruction35c
|
||||||
|
import org.jf.dexlib2.iface.instruction.FiveRegisterInstruction
|
||||||
|
import org.jf.dexlib2.iface.instruction.NarrowLiteralInstruction
|
||||||
|
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
|
import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction
|
||||||
|
|
||||||
|
@Patch
|
||||||
|
@Dependencies(dependencies = [IntegrationsPatch::class])
|
||||||
|
@Name("hide-infocard-suggestions")
|
||||||
|
@Description("Hides infocards in videos.")
|
||||||
|
@HideInfocardSuggestionsCompatibility
|
||||||
|
@Version("0.0.1")
|
||||||
|
class HideInfocardSuggestionsPatch : BytecodePatch(
|
||||||
|
listOf(
|
||||||
|
HideInfocardSuggestionsParentFingerprint
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
override fun execute(data: BytecodeData): PatchResult {
|
||||||
|
val parentResult = HideInfocardSuggestionsParentFingerprint.result
|
||||||
|
?: return PatchResultError("Parent fingerprint not resolved!")
|
||||||
|
|
||||||
|
|
||||||
|
HideInfocardSuggestionsFingerprint.resolve(data, parentResult.classDef)
|
||||||
|
val result = HideInfocardSuggestionsFingerprint.result
|
||||||
|
?: return PatchResultError("Required parent method could not be found.")
|
||||||
|
|
||||||
|
val method = result.mutableMethod
|
||||||
|
val implementation = method.implementation
|
||||||
|
?: return PatchResultError("Implementation not found.")
|
||||||
|
|
||||||
|
val index = implementation.instructions.indexOfFirst { ((it as? BuilderInstruction35c)?.reference.toString() == "Landroid/view/View;->setVisibility(I)V") }
|
||||||
|
val register = "v" + (implementation.instructions.get(index) as FiveRegisterInstruction).registerD
|
||||||
|
|
||||||
|
method.removeInstruction(index)
|
||||||
|
|
||||||
|
method.addInstructions(
|
||||||
|
index, """
|
||||||
|
invoke-static {}, Lapp/revanced/integrations/patches/HideInfoCardSuggestionsPatch;->hideInfoCardSuggestions()I
|
||||||
|
move-result $register
|
||||||
|
invoke-virtual {p1, $register}, Landroid/view/View;->setVisibility(I)V
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
|
||||||
|
return PatchResultSuccess()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue