Skip to content

Commit

Permalink
fix(youtube/theme): colore the comment action bar (#762)
Browse files Browse the repository at this point in the history
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
  • Loading branch information
OxrxL and oSumAtrIX committed Oct 11, 2022
1 parent 2247958 commit fdea41b
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package app.revanced.patches.youtube.layout.theme.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.patches.youtube.layout.theme.annotations.ThemeCompatibility
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode

@Name("comment-actionbar-fingerprint")
@ThemeCompatibility
@Version("0.0.1")
object CommentsFilterBarFingerprint : MethodFingerprint(
"V", AccessFlags.PROTECTED or AccessFlags.FINAL, listOf("L"), listOf(
Opcode.APUT,
Opcode.NEW_INSTANCE,
Opcode.INVOKE_DIRECT,
Opcode.IGET_OBJECT,
Opcode.SGET_OBJECT,
Opcode.INVOKE_VIRTUAL,
Opcode.IPUT_OBJECT,
Opcode.IGET,
Opcode.IF_EQZ,
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT,
Opcode.IF_NEZ,
Opcode.IGET_OBJECT,
Opcode.INVOKE_VIRTUAL,
Opcode.RETURN_VOID
)
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package app.revanced.patches.youtube.layout.theme.patch

import app.revanced.patcher.annotation.Description
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.patch.PatchResultSuccess
import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.patches.youtube.layout.theme.annotations.ThemeCompatibility
import app.revanced.patches.youtube.layout.theme.fingerprints.CommentsFilterBarFingerprint

@Name("comment-filter-bar-theme")
@Description("Applies custom theming to comments filter action bar.")
@ThemeCompatibility
@Version("0.0.1")
class CommentsFilterBarPatch : BytecodePatch(
listOf(
CommentsFilterBarFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
val result = CommentsFilterBarFingerprint.result!!
val method = result.mutableMethod
val patchIndex = result.scanResult.patternScanResult!!.endIndex - 1

method.addInstructions(
patchIndex, """
const v1, -0x1
if-ne v1, p1, :comments_filter_white
const v1, -0xdededf
if-ne v1, p1, :comments_filter_dark
const/4 p1, 0x0
:comments_filter_white
""", listOf(ExternalLabel("comments_filter_dark", method.instruction(patchIndex)))
)
return PatchResultSuccess()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import app.revanced.patches.youtube.misc.manifest.patch.FixLocaleConfigErrorPatc
import org.w3c.dom.Element

@Patch
@DependsOn([FixLocaleConfigErrorPatch::class])
@DependsOn([CommentsFilterBarPatch::class, FixLocaleConfigErrorPatch::class])
@Name("theme")
@Description("Applies a custom theme.")
@ThemeCompatibility
Expand Down

0 comments on commit fdea41b

Please sign in to comment.