Skip to content

feat(YouTube): Introduce Litho text component and span filtering framework#1277

Open
ILoveOpenSourceApplications wants to merge 7 commits into
devfrom
feat/add-spans
Open

feat(YouTube): Introduce Litho text component and span filtering framework#1277
ILoveOpenSourceApplications wants to merge 7 commits into
devfrom
feat/add-spans

Conversation

@ILoveOpenSourceApplications
Copy link
Copy Markdown
Contributor

Description

Code adapted from @inotia00 https://github.com/inotia00/revanced-patches/

Additional context

Adds a new patching framework to intercept and filter SpannableString operations within Litho-based UI components.

Key additions:

  • Added InclusiveSpanPatch and TextComponentPatch to inject bytecode hooks into YouTube's text component constructors and spans.
  • Introduced a runtime filtering system (Filter, FilterGroup, InclusiveSpanType) to conditionally hide or remove spans (e.g., ClickableSpan, ImageSpan) based on context.
  • Implemented StringTrieSearch integration for highly efficient, multi-threaded pattern matching against span text.
  • Added necessary bytecode fingerprints to locate Litho text components and CustomCharacterStyles.

Test results

  • Tested on both the minimum and maximum supported versions
  • Tested on experimental supported versions (Optional)

@ILoveOpenSourceApplications
Copy link
Copy Markdown
Contributor Author

@LisoUseInAIKyrios, don't know how testing this works but just letting you know that I haven't tested it.

@ILoveOpenSourceApplications
Copy link
Copy Markdown
Contributor Author

If possible I would like this to be a shared patch across YouTube and YouTube Music, but I don't know how much ground work would be needed for that.

@ILoveOpenSourceApplications ILoveOpenSourceApplications changed the title feat(YouTube): Introduce Litho text component and span filtering fram feat(YouTube): Introduce Litho text component and span filtering framework Apr 24, 2026
@0xrxL
Copy link
Copy Markdown
Contributor

0xrxL commented Apr 26, 2026

This patch could be useful to hide the annoying "save" button, in the contextual menu (3-dots) of a comment.

Comment on lines +53 to +55
fun addSpanFilter(classDescriptor: String) {
helperMethodRef.get()!!.addInstructions(
0,
Copy link
Copy Markdown
Contributor

@LisoUseInAIKyrios LisoUseInAIKyrios May 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO:

  • Add at least one span filter to verify all this works.
  • Figure out if we want to refactor common code from litho and span filters into shared classes (may not be worth the effort considering this code is now rarely changed) edit: For now skip this.

@LandonMoran
Copy link
Copy Markdown

So does this make it easier to make patches

@0xrxL
Copy link
Copy Markdown
Contributor

0xrxL commented May 7, 2026

@ILoveOpenSourceApplications Any update about this PR? Seems interesting.

@ILoveOpenSourceApplications
Copy link
Copy Markdown
Contributor Author

Waiting on Liso and his to-do list, I don't think there's much from my end.

@LisoUseInAIKyrios
Copy link
Copy Markdown
Contributor

todo list: #1277 (comment)

We can skip refactoring into shared classes. This code is rarely touched and I think it may be more complex to share code for this.

@LisoUseInAIKyrios LisoUseInAIKyrios force-pushed the dev branch 5 times, most recently from f0be5b8 to a2c0681 Compare May 14, 2026 06:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants