event_rules
Warning
The Chrome Web Store no longer accepts Manifest V2 extensions. Follow the Manifest V3 Migration guide to convert your extension to Manifest V3.
You have been redirected from Manifest V3. Chrome extensions no longer support this feature.
The event_rules
manifest property provides a mechanism to add rules that intercept, block, or modify web requests in-flight using declarativeWebRequest or take actions depending on the content of a page, without requiring permission to read the page's content using declarativeContent.
Translating rules from javascript to manifest
The following defines a rule to display a page action if the current page has a video css tag in javascript:
chrome.declarativeContent.onPageChanged.addRules([{
actions: [
new chrome.declarativeContent.ShowPageAction()
],
conditions: [
new chrome.declarativeContent.PageStateMatcher(
{css: ["video"]}
)
]
}]);
This is the same definition in the manifest:
{
"name": "Sample extension",
"event_rules": [{
"event": "declarativeContent.onPageChanged",
"actions": [{
"type": "declarativeContent.ShowPageAction"
}],
"conditions": [{
"type": "declarativeContent.PageStateMatcher",
"css": ["video"]
}]
}],
...
}