OLD | NEW |
1 <h2 id="notes">Notes</h2> | 1 <h2 id="notes">Notes</h2> |
2 | 2 |
3 <p> | 3 <p> |
4 Use the <code>chrome.declarativeWebRequest</code> module to intercept, block, or | 4 Use the <code>chrome.declarativeWebRequest</code> module to intercept, block, or |
5 modify requests in-flight. It is significantly faster than the <a | 5 modify requests in-flight. It is significantly faster than the <a |
6 href="webRequest.html"><code>chrome.webRequest</code> API</a> because you can | 6 href="webRequest.html"><code>chrome.webRequest</code> API</a> because you can |
7 register rules that are evaluated in the browser rather than the | 7 register rules that are evaluated in the browser rather than the |
8 JavaScript engine which reduces roundtrip latencies and allows very high | 8 JavaScript engine which reduces roundtrip latencies and allows very high |
9 efficiency. | 9 efficiency. |
10 </p> | 10 </p> |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 Register rules as follows: | 113 Register rules as follows: |
114 </p> | 114 </p> |
115 <pre> | 115 <pre> |
116 chrome.declarativeWebRequest.onRequest.addRules([rule2]); | 116 chrome.declarativeWebRequest.onRequest.addRules([rule2]); |
117 </pre> | 117 </pre> |
118 | 118 |
119 <p class="note"> | 119 <p class="note"> |
120 <strong>Note:</strong> You should always register or unregister rules in bulk ra
ther than | 120 <strong>Note:</strong> You should always register or unregister rules in bulk ra
ther than |
121 individually because each of these operations recreates internal data | 121 individually because each of these operations recreates internal data |
122 structures. This re-creation is computationally expensive but facilitates a | 122 structures. This re-creation is computationally expensive but facilitates a |
123 very fast URL matching algorithm for hundreds of thousands of URLs. | 123 very fast URL matching algorithm for hundreds of thousands of URLs. The |
| 124 <a href="events.html#performance">Performance section</a> of the $ref:[events |
| 125 Events] API provides further performance tips. |
124 </p> | 126 </p> |
125 | 127 |
126 | 128 |
127 <h2 id="evaluation">Evaluation of conditions and actions</h2> | 129 <h2 id="evaluation">Evaluation of conditions and actions</h2> |
128 | 130 |
129 <p> | 131 <p> |
130 The Declarative Web Request API follows the | 132 The Declarative Web Request API follows the |
131 <a href="webRequest.html#life_cycle">Life cycle model for web requests</a> of | 133 <a href="webRequest.html#life_cycle">Life cycle model for web requests</a> of |
132 the <a href="webRequest.html">Web Request API</a>. This means that conditions | 134 the <a href="webRequest.html">Web Request API</a>. This means that conditions |
133 can only be tested at specific stages of a web request and, likewise, actions | 135 can only be tested at specific stages of a web request and, likewise, actions |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 chrome.declarativeWebRequest.onRequest.addRules([rule1, rule2]); | 237 chrome.declarativeWebRequest.onRequest.addRules([rule1, rule2]); |
236 </pre> | 238 </pre> |
237 | 239 |
238 <p> | 240 <p> |
239 It is important to recognize that the <code>IgnoreRules</code> action is not | 241 It is important to recognize that the <code>IgnoreRules</code> action is not |
240 persisted across <a href="#evaluation">request stages</a>. All conditions of | 242 persisted across <a href="#evaluation">request stages</a>. All conditions of |
241 all rules are evaluated at each stage of a web request. If an | 243 all rules are evaluated at each stage of a web request. If an |
242 <code>IgnoreRules</code> action is executed, it applies only to other actions | 244 <code>IgnoreRules</code> action is executed, it applies only to other actions |
243 that are executed for the same web request in the same stage. | 245 that are executed for the same web request in the same stage. |
244 </p> | 246 </p> |
OLD | NEW |