● Use · rules.json
Updating filters remotely
fixes without an App Store release.
Optional. Put a rules.json on your own HTTPS server, set AppConfig.rulesURL, and every installed copy of your app downloads it at launch. Remote rules can only add selectors, labels and redirects; they cannot run scripts or switch built-in filters off.
01Turn it on
- Host the file anywhere that serves a static file over HTTPS with status 200: your website, a CDN, a storage bucket. Keep it under 256,000 bytes.
- Point the app at it in
AppConfig.swift:static let rulesURL: URL? = URL(string: "https://example.com/myapp/rules.json") - Ship that app version. From then on you can change the file without a new release.
02When the app reads it
- Once each time the app's window appears (
.taskinNoReelsApp.swift), with a plain GET, a 10-second timeout and no cache. No identifier or user data is sent; your server sees an ordinary request with the device's IP address. - A new file is accepted only if its
versionis greater than the version the device already has. Always raiseversionwhen you publish a change. - When offline, or when the file is broken, the device keeps the last good rules (stored in user defaults under
rules.remote). - Accepted rules apply at once: open tabs reload with them. In each site tab they act as one extra filter called "Updated rules", always on and not listed in Settings.
03rules.json format
{
"version": 2,
"platforms": {
"youtube": {
"selectors": ["ytm-shorts-new-shelf"],
"labels": [],
"redirects": [
{ "pattern": "^/shorts2/([^/?]+)", "target": "/watch?v=$1" }
]
},
"instagram": {
"selectors": [],
"labels": ["Suggested for you today"],
"redirects": []
},
"facebook": {
"selectors": ["a[href^=\"/reels-new\"]"],
"labels": ["Sponsored content"],
"redirects": []
}
}
}
| Field | Meaning |
|---|---|
version | Whole number. Raise it with every change. |
platforms | Keys instagram, youtube, facebook. Any other key is ignored. |
selectors | CSS selectors to hide (see Filters). |
labels | Exact feed texts whose post is hidden. |
redirects | pattern (regular expression over path and query) and target (a path on the same site). |
Every list is optional
A site may list only selectors, only labels or only redirects; missing lists count as empty. You may leave a whole site out.
04What the app drops for safety
Before use, the file is cleaned entry by entry (RemoteRules.sanitized()), so one bad line does not break the rest:
- Selectors that are empty, longer than 300 characters, or contain
{or}(no injected CSS rules). At most 200 per site. - Labels that are empty or longer than 40 characters. At most 100 per site.
- Redirects whose pattern is longer than 200 characters or is not a valid regular expression, or whose target does not start with
/or contains//(no sending users to another website). At most 50 per site.
05Test before you publish
- Validate the JSON, for example
python3 -m json.tool rules.json. - Test each selector and label in Safari Web Inspector on a real device (how).
- Publish to a test URL first, point a debug build at it, launch the app twice and check the effect.
- Publish to the production URL with a higher
version.
A mistake can be undone only by publishing a newer version without the bad entry; lowering version does nothing.