AdguardTeam / AdguardTeam/Scriptlets

Support text replacement via cosmetic/scriptlet rules (similar to uBlock Origin rpnt)

Đang mở
#547 4 bình luận 0 reaction 1 người được giao Được giao cho @maximtop Xem trên GitHub
Feature request Priority: P4
Ngôn ngữ chính
JavaScript
Star
195
Fork
33
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

### Issue Details

Currently, AdGuard Browser Extension supports cosmetic CSS rules for hiding or removing elements, but it does **not support text replacement** in page content.

In uBlock Origin, this is possible using trusted scriptlets such as `+js(rpnt, ...)`, which allow replacing text nodes in the DOM (for example, replacing all occurrences of `"microsoft"` with `"microslop"`).

Example (works in uBlock Origin):

```
*##+js(rpnt, #text, /microsoft/gi, microslop, stay, 1)
```

This functionality is **not available** in AdGuard. The same rule is silently ignored, and there is currently no alternative mechanism to perform text replacement using filters.

CSS-only cosmetic rules cannot solve this, since CSS cannot modify text content—only hide or style elements.

## **Additional Notes**

This feature would be useful for:

* Content modification
* Satirical or personal text replacements
* Accessibility or readability adjustments
* Consistency with advanced cosmetic filtering supported by other blockers

### Proposed solution

Add support for a **safe text-replacement mechanism** in cosmetic filtering, for example:

* A limited scriptlet-like rule for replacing text nodes
* Or a dedicated filter syntax for search/replace in visible text
* Executed after DOM load, without requiring full custom JavaScript

The goal is **not arbitrary JS execution**, but a controlled feature to replace text content in the DOM, similar in scope to uBlock Origin’s `rpnt`.

### Alternative solution

* Using CSS (`:has-text`, `:contains`) → only hides elements, does not replace text
* Using userscripts (Tampermonkey / Violentmonkey) → works, but requires an extra extension and is outside AdGuard’s filtering system
* Using uBlock Origin instead → not an option for users committed to AdGuard

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.