generated from ReVanced/revanced-patches-template
-
-
Notifications
You must be signed in to change notification settings - Fork 223
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat:
hide-infocard-suggestions
patch (#107)
- Loading branch information
Showing
6 changed files
with
134 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
kotlin.code.style = official | ||
version = 2.6.0 | ||
version = 2.6.0 |
13 changes: 13 additions & 0 deletions
13
...atches/youtube/ad/infocardsuggestions/annotations/HideInfocardSuggestionsCompatibility.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
24 changes: 24 additions & 0 deletions
24
...patches/youtube/ad/infocardsuggestions/fingerprints/HideInfocardSuggestionsFingerprint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
) |
24 changes: 24 additions & 0 deletions
24
...s/youtube/ad/infocardsuggestions/fingerprints/HideInfocardSuggestionsParentFingerprint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
) |
71 changes: 71 additions & 0 deletions
71
...app/revanced/patches/youtube/ad/infocardsuggestions/patch/HideInfocardSuggestionsPatch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
} | ||
|
||
} |