Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / common / extensions / docs / templates / articles / manifest / event_rules.html
blob6d066edcb9dd669a603241473a622a8bb9e20494
1 <h1>event_rules</h1>
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="../declarativeWebRequest">declarativeWebRequest</a> or take actions depending on the content of a page, without requiring permission to read the page's content using <a href="../declarativeContent">declarativeContent</a>.
5 </p>
7 <h2 id="translation">Translating rules from javascript to manifest</h2>
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>
13 <pre data-filename="example.js">
14 chrome.<b>declarativeContent.onPageChanged</b>.addRules([{
15 actions: [
16 new chrome.<b>declarativeContent.ShowPageAction</b>()
18 conditions: [
19 new chrome.<b>declarativeContent.PageStateMatcher</b>(
20 <b>{css: ["video"]}</b>
23 }]);
24 </pre>
26 <p>
27 This is the same definition in the manifest:
28 </p>
30 <pre data-filename="manifest.json">
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>
42 }],
43 ...
45 </pre>