connect.net
Content blocking — adblock-tier control plus your own declarative (DNR) rules.
Content blocking, in two halves — both per-profile. Adblock-tier control is a facade over Connect+'s own adblocker; declarative rules are your own DNR-equivalent block/allow/redirect rules that run ahead of the adblocker.
- Capabilities:
net.observe(read-only status),net.block(toggle + rules) - Namespace:
connect.net
Walkthrough
Block a tracker with a declarative rule.
- Declare
net.block(or justnet.observeif you only read status):{ "capabilities": ["net.block"] } - Add a rule — an all-or-nothing batch:
await connect.net.updateRules({ addRules: [{ id: 1, priority: 1, action: { type: 'block' }, condition: { urlFilter: '||doubleclick.net^', resourceTypes: ['script', 'image'] }, }]}); - Read status any time with
status(). - Remember rules are cleared on uninstall.
Methods
net.status()
Read adblock status.
How to use it
- Call it to read
{ enabled, siteTiers }— needs onlynet.observe.
Signature — connect.net.status() · Capability: net.observe
Returns — Promise<{ enabled, siteTiers }>.
net.setEnabled(enabled)
Master adblock toggle for the profile.
How to use it
- Pass
true/falseto turn the profile's adblocker on / off.
Signature — connect.net.setEnabled(enabled) · Capability: net.block
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
enabled | boolean | yes | Turn the profile's adblocker on/off. |
Returns — Promise<void>.
net.setSiteTier(host, tier)
Set the blocking tier for one site.
How to use it
- Pass a
hostand atier('full'/'essential'/'off').
Signature — connect.net.setSiteTier(host, tier) · Capability: net.block
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
host | string | yes | The site. |
tier | 'full' | 'essential' | 'off' | yes | How aggressively to block on it. |
Returns — Promise<void>.
net.getRules()
Read your declarative rules.
How to use it
- Call it to see your current rule set (e.g. to compute a diff before
updateRules).
Signature — connect.net.getRules() · Capability: net.block · Returns
Promise<Rule[]>.
net.updateRules(changes)
Add and/or remove declarative rules — an all-or-nothing batch.
How to use it
- Build
removeRuleIdsand/oraddRules(each rule needs a uniqueid). awaitthe batch — it all applies or none does.- Keep under 5000 rules per extension.
Signature — connect.net.updateRules({ removeRuleIds?, addRules? }) · Capability:
net.block
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
removeRuleIds | number[] | no | Rule ids to remove first. |
addRules | Rule[] | no | Rules to add. Max 5000 per extension. |
Returns — Promise<void>. The whole batch applies or none of it does.
A rule (DNR subset)
| Field | Type | Description |
|---|---|---|
id | number | Unique per extension. |
priority | number | Higher wins. |
action.type | 'block' | 'allow' | 'redirect' | What to do. |
condition.urlFilter | string | Match pattern, e.g. ||doubleclick.net^. |
condition.resourceTypes | string[] | e.g. ['script', 'image']. |
await connect.net.updateRules({
addRules: [{
id: 1, priority: 1,
action: { type: 'block' },
condition: { urlFilter: '||doubleclick.net^', resourceTypes: ['script', 'image'] },
}],
});Notes
- Declarative rules run before the built-in adblocker and are cleared on uninstall (they live on the request hot path).
- Reading status needs only
net.observe; anything that changes behaviour needsnet.block.