Skip to content

Add contextual subtree text and regex matching to UI Hider - #356

Merged
nethical6 merged 4 commits into
curbox-app:kt-rewritefrom
erdemyasar-web:feature/ui-hider-contextual-text-matching
Jul 24, 2026
Merged

nethical6 merged 4 commits into
curbox-app:kt-rewritefrom
erdemyasar-web:feature/ui-hider-contextual-text-matching

Conversation

@erdemyasar-web

Copy link
Copy Markdown
Contributor

Summary

This pull request adds contextual text-matching capabilities to UI Hider scripts.

It implements:

  • bounded subtree text collection
  • case-insensitive string matching
  • regex matching with supported flags
  • compiled regex caching
  • execution-budget charging for regex operations
  • node-budget charging for subtree traversal
  • interpreter tests covering the new functionality

Added scripting functions

subtreeText(node, maxDepth, maxChars)
containsIgnoreCase(text, value)
lower(text)
matchesRegex(text, pattern, flags)

Motivation

Some UI cards expose their title, description, source, and exception context through separate Accessibility nodes.

For example:

Title: Revenge porn
Description: Legal information and victim support

Matching only the title node can create a false positive. Bounded subtree-text collection allows scripts to evaluate the candidate card as a whole before deciding whether to hide it.

This also enables generic contextual rules such as:

risk term AND supporting term AND NOT protected context

The implementation is generic and does not contain TemizWeb-specific or PMO-specific rules.

Safety and performance

  • Subtree traversal is bounded by depth and character limits.
  • Visited nodes are charged against the existing node budget.
  • Regex operations are charged against the execution budget based on input size.
  • Compiled regex objects are cached in a static ConcurrentHashMap.
  • Invalid or unsupported regex input is handled safely.
  • Regex and subtree limits prevent unbounded script work.

Tests

Tests were added for:

  • nested subtree text
  • maximum depth
  • maximum character count
  • case-insensitive matching
  • Turkish and Unicode text
  • regex flags
  • invalid regex patterns
  • regex caching
  • regex budget exhaustion
  • subtree node-budget exhaustion
  • contextual trigger and protected-context evaluation

Closes #355

@erdemyasar-web
erdemyasar-web marked this pull request as ready for review July 16, 2026 08:13
@erdemyasar-web
erdemyasar-web marked this pull request as draft July 16, 2026 08:14
@erdemyasar-web

Copy link
Copy Markdown
Contributor Author

CI is green, and I tested the generated APK on a real Android device.

The new scripting functions were individually confirmed:

  • subtreeText() collected accessible Chrome page text
  • containsIgnoreCase() worked
  • matchesRegex() worked with flags and contextual patterns
  • explicit Turkish [iı] expansion worked for Turkish dotted/dotless-I cases

During end-to-end overlay testing, I encountered device/browser-specific Accessibility and overlay instability. Curbox’s existing Instagram UI reducers also did not work reliably on this device, so I could not establish a reliable end-to-end card-filtering result. This appears separate from the new interpreter functions, but I want to report the limitation transparently.

The PR is ready for maintainer review, especially regarding the implementation and automated tests.

@erdemyasar-web
erdemyasar-web marked this pull request as ready for review July 16, 2026 13:13
@erdemyasar-web

Copy link
Copy Markdown
Contributor Author

Update/correction to my previous testing note:

After further testing, I realized that Curbox’s existing Instagram and YouTube UI Hider features do work on my device. My earlier conclusion was premature and was likely caused by my testing setup or configuration rather than Curbox itself.

Because of this, I would like to continue testing the proposed subtreeText, containsIgnoreCase, and matchesRegex additions. The individual new functions already worked in my controlled tests, and the working built-in Instagram/YouTube filters give me more confidence that Curbox may be suitable for the broader filtering use case I am exploring.

I apologize for the confusion in my earlier comment. Please continue to consider this pull request. I am happy for it to be reviewed primarily on the implementation, execution-budget safety, caching, and automated tests while I continue investigating the end-to-end custom script behavior.

@nethical6

Copy link
Copy Markdown
Member

sure, it looks fine to me. i'll merge it in a while.

the instagram blocker stuff is very experimental and doesnt seem to work if you use instagram in any other language except english

@nethical6
nethical6 merged commit c31c624 into curbox-app:kt-rewrite Jul 24, 2026
1 check passed
@nethical6

Copy link
Copy Markdown
Member

Thank you for your contribution :)

@erdemyasar-web

Copy link
Copy Markdown
Contributor Author

Thank you for building the app and letting me contribute :)

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.

[Feature]: Add contextual subtree-text and regex matching to UI Hider scripts

2 participants