generated from ReVanced/revanced-patches-template
-
-
Notifications
You must be signed in to change notification settings - Fork 236
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(YouTube): Add
Disable rolling number animations
patch (#3298)
- Loading branch information
1 parent
acf26ea
commit a0121ae
Showing
16 changed files
with
133 additions
and
25 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
78 changes: 78 additions & 0 deletions
78
.../revanced/patches/youtube/layout/hide/rollingnumber/DisableRollingNumberAnimationPatch.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,78 @@ | ||
package app.revanced.patches.youtube.layout.hide.rollingnumber | ||
|
||
import app.revanced.extensions.exception | ||
import app.revanced.patcher.data.BytecodeContext | ||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions | ||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels | ||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction | ||
import app.revanced.patcher.patch.BytecodePatch | ||
import app.revanced.patcher.patch.annotation.CompatiblePackage | ||
import app.revanced.patcher.patch.annotation.Patch | ||
import app.revanced.patcher.util.smali.ExternalLabel | ||
import app.revanced.patches.shared.settings.preference.impl.StringResource | ||
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference | ||
import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch | ||
import app.revanced.patches.youtube.misc.settings.SettingsPatch | ||
import app.revanced.patches.youtube.shared.fingerprints.RollingNumberTextViewAnimationUpdateFingerprint | ||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction | ||
|
||
@Patch( | ||
name = "Disable rolling number animations", | ||
description = "Disables rolling number animations of video view count, upload time, and user likes", | ||
dependencies = [IntegrationsPatch::class, SettingsPatch::class], | ||
compatiblePackages = [ | ||
CompatiblePackage( | ||
"com.google.android.youtube", [ | ||
"18.43.45", | ||
"18.44.41", | ||
"18.45.41" | ||
] | ||
) | ||
] | ||
) | ||
@Suppress("unused") | ||
object DisableRollingNumberAnimationPatch : BytecodePatch( | ||
setOf( | ||
RollingNumberTextViewAnimationUpdateFingerprint | ||
) | ||
) { | ||
private const val INTEGRATIONS_CLASS_DESCRIPTOR = | ||
"Lapp/revanced/integrations/patches/DisableRollingNumberAnimationsPatch;" | ||
|
||
override fun execute(context: BytecodeContext) { | ||
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( | ||
SwitchPreference( | ||
"revanced_disable_rolling_number_animations", | ||
StringResource("revanced_disable_rolling_number_animations_title", "Disable rolling number animations"), | ||
StringResource("revanced_disable_rolling_number_animations_summary_on", "Rolling numbers are not animated"), | ||
StringResource("revanced_disable_rolling_number_animations_summary_off", "Rolling numbers are animated") | ||
) | ||
) | ||
|
||
// Animations are disabled by preventing an Image from being applied to the text span, | ||
// which prevents the animations from appearing. | ||
RollingNumberTextViewAnimationUpdateFingerprint.result?.apply { | ||
val patternScanResult = scanResult.patternScanResult!! | ||
val blockStartIndex = patternScanResult.startIndex | ||
val blockEndIndex = patternScanResult.endIndex + 1 | ||
mutableMethod.apply { | ||
val freeRegister = getInstruction<OneRegisterInstruction>(blockStartIndex).registerA | ||
|
||
// ReturnYouTubeDislike also makes changes to this same method, | ||
// and must add control flow label to a noop instruction to | ||
// ensure RYD patch adds it's changes after the control flow label. | ||
addInstructions(blockEndIndex, "nop") | ||
|
||
addInstructionsWithLabels( | ||
blockStartIndex, | ||
""" | ||
invoke-static { }, $INTEGRATIONS_CLASS_DESCRIPTOR->disableRollingNumberAnimations()Z | ||
move-result v$freeRegister | ||
if-nez v$freeRegister, :disable_animations | ||
""", | ||
ExternalLabel("disable_animations", getInstruction(blockEndIndex)) | ||
) | ||
} | ||
} ?: throw RollingNumberTextViewAnimationUpdateFingerprint.exception | ||
} | ||
} |
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
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
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
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
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
2 changes: 1 addition & 1 deletion
2
...gerprints/LayoutConstructorFingerprint.kt → ...gerprints/LayoutConstructorFingerprint.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
30 changes: 30 additions & 0 deletions
30
...ed/patches/youtube/shared/fingerprints/RollingNumberTextViewAnimationUpdateFingerprint.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,30 @@ | ||
package app.revanced.patches.youtube.shared.fingerprints | ||
|
||
import app.revanced.patcher.extensions.or | ||
import app.revanced.patcher.fingerprint.MethodFingerprint | ||
import com.android.tools.smali.dexlib2.AccessFlags | ||
import com.android.tools.smali.dexlib2.Opcode | ||
|
||
object RollingNumberTextViewAnimationUpdateFingerprint : MethodFingerprint( | ||
returnType = "V", | ||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, | ||
parameters = listOf("Landroid/graphics/Bitmap;"), | ||
opcodes = listOf( | ||
Opcode.NEW_INSTANCE, // bitmap ImageSpan | ||
Opcode.INVOKE_VIRTUAL, | ||
Opcode.MOVE_RESULT_OBJECT, | ||
Opcode.CONST_4, | ||
Opcode.INVOKE_DIRECT, | ||
Opcode.INVOKE_VIRTUAL, | ||
Opcode.MOVE_RESULT, | ||
Opcode.CONST_16, | ||
Opcode.INVOKE_VIRTUAL, | ||
Opcode.INVOKE_VIRTUAL, | ||
Opcode.MOVE_RESULT, | ||
Opcode.INT_TO_FLOAT, | ||
Opcode.INVOKE_VIRTUAL, // set textview padding using bitmap width | ||
), | ||
customFingerprint = { _, classDef -> | ||
classDef.superclass == "Landroid/support/v7/widget/AppCompatTextView;" | ||
} | ||
) |
3 changes: 1 addition & 2 deletions
3
.../fingerprints/SeekbarOnDrawFingerprint.kt → .../fingerprints/SeekbarOnDrawFingerprint.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
2 changes: 1 addition & 1 deletion
2
...erprints/WatchWhileActivityFingerprint.kt → ...erprints/WatchWhileActivityFingerprint.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