OLD | NEW |
(Empty) | |
| 1 <h1>event_rules</h1> |
| 2 |
| 3 <p> |
| 4 The <code>event_rules</code> manifest property provides a mechanism to add rules
that intercept, block, or modify web requests in-flight using <a href="../decla
rativeWebRequest">declarativeWebRequest</a> or take actions depending on the con
tent of a page, without requiring permission to read the page's content using <a
href="../declarativeContent">declarativeContent</a>. |
| 5 </p> |
| 6 |
| 7 <h2 id="translation">Translating rules from javascript to manifest</h2> |
| 8 |
| 9 <p> |
| 10 The following defines a rule to display a page action if the current page has a
video css tag in javascript: |
| 11 </p> |
| 12 |
| 13 <pre data-filename="example.js"> |
| 14 chrome.<b>declarativeContent.onPageChanged</b>.addRules([{ |
| 15 actions: [ |
| 16 new chrome.<b>declarativeContent.ShowPageAction</b>() |
| 17 ], |
| 18 conditions: [ |
| 19 new chrome.<b>declarativeContent.PageStateMatcher</b>( |
| 20 <b>{css: ["video"]}</b> |
| 21 ) |
| 22 ] |
| 23 }]); |
| 24 </pre> |
| 25 |
| 26 <p> |
| 27 This is the same definition in the manifest: |
| 28 </p> |
| 29 |
| 30 <pre data-filename="manifest.json"> |
| 31 { |
| 32 "name": "Sample {{platform}}", |
| 33 "event_rules": {[ |
| 34 "event": <b>"declarativeContent.onPageChanged"</b>, |
| 35 "actions": [{ |
| 36 "type": <b>"declarativeContent.ShowPageAction"</b> |
| 37 }], |
| 38 "conditions": [{ |
| 39 "type": <b>"declarativeContent.PageStateMatcher"</b>, |
| 40 <b>"css": ["video"]</b> |
| 41 }] |
| 42 }], |
| 43 ... |
| 44 } |
| 45 </pre> |
OLD | NEW |