-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathdeclarativeWebRequest.html
1434 lines (1387 loc) · 65.9 KB
/
declarativeWebRequest.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="stable/static/css/site.css" rel="stylesheet" type="text/css">
<link href="stable/static/css/print.css" rel="stylesheet" type="text/css" media="print">
<link href="stable/static/css/prettify.css" rel="stylesheet" type="text/css">
<link href="//www.google.com/images/icons/product/chrome-16.png" rel="icon" type="image/ico">
<link href="stable/static/css/api.css" rel="stylesheet" type="text/css">
<title>chrome.declarativeWebRequest - chrome插件中文开发文档(非官方)</title>
</head>
<body>
<a id="top"></a>
<div id="header">{Header content}</div>
<a id="gc-topnav-anchor"></a>
<div id="gc-topnav">
<h1>Google Chrome Extensions</h1>
<ul id="home" class="gc-topnav-tabs">
<li id="home_link">
<a href="index.html" title="Google Chrome Extensions home page"><div>Home</div></a>
</li>
<li id="docs_link">
<a href="docs.html" title="Official Google Chrome Extensions documentation"><div>Docs</div></a>
</li>
<li id="faq_link">
<a href="faq.html" title="Answers to frequently asked questions about Google Chrome Extensions"><div>FAQ</div></a>
</li>
<li id="samples_link">
<a href="samples.html" title="Sample Extensions (with source code)"><div>Samples</div></a>
</li>
<li id="group_link">
<a href="http://groups.google.com/a/chromium.org/group/chromium-extensions" title="Google Chrome Extensions developer forum"><div>Group</div></a>
</li>
<li id="so_link">
<a href="http://stackoverflow.com/questions/tagged/google-chrome-extension" title="[google-chrome-extension] tag on Stack Overflow"><div>Questions?</div></a>
</li>
</ul>
</div>
<div id="gc-container">
<div id="gc-sidebar">
<ul
class="level1 ">
<li class="level2">
<a href="getstarted.html" class="level2 ">Getting Started</a>
</li>
<li class="level2">
<a href="overview.html" class="level2 ">Overview</a>
</li>
<li class="level2">
<a href="whats_new.html" class="level2 ">What's New?</a>
</li>
<li class="level2">
<a href="devguide.html" class="level2 ">Developer's Guide</a>
<ul
class="level2 ">
<li class="level3">
<a class="button level3">
<span class="level3">Browser UI</span>
<div class="toggleIndicator level3"></div>
</a>
<ul toggleable
class="level3 hidden">
<li class="level4">
<a href="browserAction.html" class="level4 ">Browser Actions</a>
</li>
<li class="level4">
<a href="contextMenus.html" class="level4 ">Context Menus</a>
</li>
<li class="level4">
<a href="notifications.html" class="level4 ">Desktop Notifications</a>
</li>
<li class="level4">
<a href="omnibox.html" class="level4 ">Omnibox</a>
</li>
<li class="level4">
<a href="options.html" class="level4 ">Options Pages</a>
</li>
<li class="level4">
<a href="override.html" class="level4 ">Override Pages</a>
</li>
<li class="level4">
<a href="pageAction.html" class="level4 ">Page Actions</a>
</li>
</ul>
</li>
<li class="level3">
<a class="button level3">
<span class="level3">Browser Interaction</span>
<div class="toggleIndicator level3"></div>
</a>
<ul toggleable
class="level3 hidden">
<li class="level4">
<a href="bookmarks.html" class="level4 ">Bookmarks</a>
</li>
<li class="level4">
<a href="cookies.html" class="level4 ">Cookies</a>
</li>
<li class="level4">
<a href="devtools.html" class="level4 ">Developer Tools</a>
</li>
<li class="level4">
<a href="events.html" class="level4 ">Events</a>
</li>
<li class="level4">
<a href="history.html" class="level4 ">History</a>
</li>
<li class="level4">
<a href="management.html" class="level4 ">Management</a>
</li>
<li class="level4">
<a href="tabs.html" class="level4 ">Tabs</a>
</li>
<li class="level4">
<a href="windows.html" class="level4 ">Windows</a>
</li>
</ul>
</li>
<li class="level3">
<a class="button level3">
<span class="level3">Implementation</span>
<div class="toggleIndicator level3"></div>
</a>
<ul toggleable
class="level3 hidden">
<li class="level4">
<a href="a11y.html" class="level4 ">Accessibility</a>
</li>
<li class="level4">
<a href="event_pages.html" class="level4 ">Event Pages</a>
</li>
<li class="level4">
<a href="contentSecurityPolicy.html" class="level4 ">Content Security Policy</a>
</li>
<li class="level4">
<a href="content_scripts.html" class="level4 ">Content Scripts</a>
</li>
<li class="level4">
<a href="xhr.html" class="level4 ">Cross-Origin XHR</a>
</li>
<li class="level4">
<a href="i18n.html" class="level4 ">Internationalization</a>
</li>
<li class="level4">
<a href="messaging.html" class="level4 ">Message Passing</a>
</li>
<li class="level4">
<a href="permissions.html" class="level4 ">Optional Permissions</a>
</li>
<li class="level4">
<a href="npapi.html" class="level4 ">NPAPI Plugins</a>
</li>
</ul>
</li>
<li class="level3">
<a class="button level3">
<span class="level3">Finishing</span>
<div class="toggleIndicator level3"></div>
</a>
<ul toggleable
class="level3 hidden">
<li class="level4">
<a href="hosting.html" class="level4 ">Hosting</a>
</li>
<li class="level4">
<a href="external_extensions.html" class="level4 ">Other Deployment Options</a>
</li>
</ul>
</li>
</ul>
</li>
<li class="level2">
<a href="tutorials.html" class="level2 ">Tutorials</a>
<ul
class="level2 ">
<li class="level3">
<a href="tut_migration_to_manifest_v2.html" class="level3 ">Manifest V2</a>
</li>
<li class="level3">
<a href="tut_debugging.html" class="level3 ">Debugging</a>
</li>
<li class="level3">
<a href="tut_analytics.html" class="level3 ">Google Analytics</a>
</li>
<li class="level3">
<a href="tut_oauth.html" class="level3 ">OAuth</a>
</li>
</ul>
</li>
<li class="level2">
<span class="level2">Reference</span>
<ul
class="level2 ">
<li class="level3">
<a class="button level3">
<span class="level3">Formats</span>
<div class="toggleIndicator level3"></div>
</a>
<ul toggleable
class="level3 hidden">
<li class="level4">
<a href="manifest.html" class="level4 ">Manifest Files</a>
</li>
<li class="level4">
<a href="match_patterns.html" class="level4 ">Match Patterns</a>
</li>
</ul>
</li>
<li class="level3">
<a href="permission_warnings.html" class="level3 ">Permission Warnings</a>
</li>
<li class="level3">
<a href="api_index.html" class="level3 ">chrome.* APIs</a>
</li>
<li class="level3">
<a href="api_other.html" class="level3 ">Other APIs</a>
</li>
</ul>
</li>
<li class="level2">
<span class="level2">More</span>
<ul
class="level2 ">
<li class="level3">
<a href="http://code.google.com/chrome/webstore/docs/index.html" class="level3 ">Chrome Web Store</a>
</li>
<li class="level3">
<a href="http://code.google.com/chrome/apps/docs/developers_guide.html" class="level3 ">Hosted Apps</a>
</li>
<li class="level3">
<a href="themes.html" class="level3 ">Themes</a>
</li>
</ul>
</li>
</ul>
</div>
<div id="gc-pagecontent">
<h1 class="page_title">chrome.declarativeWebRequest</h1>
<p class="warning"> <em>Warning:</em> This API is still under development. It is only available for Chrome users on the <span> <strong>dev</strong> <a href="http://www.chromium.org/getting-involved/beta-channel">early release channel</a> and <strong>beta</strong> <a href="https://www.google.com/landing/chrome/beta/"> release channel. </span></p>
<div id="toc">
<h2>Contents</h2>
<ol>
<li>
<a href=#notes>Notes</a>
</li>
<li>
<a href=#manifest>Manifest</a>
</li>
<li>
<a href=#rules>Rules</a>
</li>
<li>
<a href=#evaluation>Evaluation of conditions and actions</a>
</li>
<li>
<a href=#precedences>Using priorities to override rules</a>
</li>
<li>
<a href="#apiReference">API reference: chrome.declarativeWebRequest</a>
<ol>
<li><a href="#types">Types</a><ol> <li> <a href="#type-HeaderFilter">HeaderFilter</a> </li> <li> <a href="#type-RequestMatcher">RequestMatcher</a> </li> <li> <a href="#type-CancelRequest">CancelRequest</a> </li> <li> <a href="#type-RedirectRequest">RedirectRequest</a> </li> <li> <a href="#type-RedirectToTransparentImage">RedirectToTransparentImage</a> </li> <li> <a href="#type-RedirectToEmptyDocument">RedirectToEmptyDocument</a> </li> <li> <a href="#type-RedirectByRegEx">RedirectByRegEx</a> </li> <li> <a href="#type-SetRequestHeader">SetRequestHeader</a> </li> <li> <a href="#type-RemoveRequestHeader">RemoveRequestHeader</a> </li> <li> <a href="#type-AddResponseHeader">AddResponseHeader</a> </li> <li> <a href="#type-RemoveResponseHeader">RemoveResponseHeader</a> </li> <li> <a href="#type-IgnoreRules">IgnoreRules</a> </li> <li> <a href="#type-RequestCookie">RequestCookie</a> </li> <li> <a href="#type-ResponseCookie">ResponseCookie</a> </li> <li> <a href="#type-AddRequestCookie">AddRequestCookie</a> </li> <li> <a href="#type-AddResponseCookie">AddResponseCookie</a> </li> <li> <a href="#type-EditRequestCookie">EditRequestCookie</a> </li> <li> <a href="#type-EditResponseCookie">EditResponseCookie</a> </li> <li> <a href="#type-RemoveRequestCookie">RemoveRequestCookie</a> </li> <li> <a href="#type-RemoveResponseCookie">RemoveResponseCookie</a> </li></ol></li>
<li><a href="#events">Events</a><ol> <li><a href="#event-onRequest">onRequest</a></li></ol></li>
<li><a href="#samples">Sample Extensions</a></li>
</ol>
</li>
</ol>
</div>
<h2 id="notes">Notes</h2>
<p>
Use the <code>chrome.declarativeWebRequest</code> module to intercept, block, or
modify requests in-flight. It is significantly faster than the <a
href="webRequest.html"><code>chrome.webRequest</code> API</a> because you can
register rules that are evaluated in the browser rather than the
JavaScript engine which reduces roundtrip latencies and allows for very high
efficiency.
</p>
<h2 id="manifest">Manifest</h2>
<p>
You must declare the "declarativeWebRequest" permission in the
<a href="manifest.html">extension manifest</a> to use this API,
along with <a href="manifest.html#permissions">host permissions</a> for any
hosts whose network requests you want to access.
</p>
<pre>{
"name": "My extension",
...
<b> "permissions": [
"declarativeWebRequest",
"*://*.google.com"
]</b>,
...
}</pre>
<h2 id="rules">Rules</h2>
<p>
The Declarative Web Request API follows the concepts of the <a
href="events.html#declarative">Declarative API</a>. You can register rules to
the <code>chrome.declarativeWebRequest.onRequest</code> event object.
</p>
<p>
The Declarative Web Request API supports a single type of match criteria, the
<code>RequestMatcher</code>. The <code>RequestMatcher</code> matches network
requests if and only if all listed criteria are met. The following
<code>RequestMatcher</code> would match a network request when the user enters
"http://www.example.com" in the URL bar:
</p>
<pre>
var matcher = new chrome.declarativeWebRequest.RequestMatcher({
url: { hostSuffix: 'example.com', schemes: ['http'] },
resourceType: ['main_frame']
});
</pre>
<p>
Requests to "https://www.example.com" would be rejected by the
<code>RequestMatcher</code> due to the scheme. Also all requests for an embedded
iframe would be rejected due to the <code>resourceType</code>.
</p>
<p class="note">
<strong>Note:</strong> All conditions and actions are created via a constructor
as shown in the example above.
<p>
<p>
In order to cancel all requests to "example.com", you can define a rule as
follows:
</p>
<pre>
var rule = {
conditions: [
new chrome.declarativeWebRequest.RequestMatcher({
url: { hostSuffix: 'example.com' } })
],
actions: [
new chrome.declarativeWebRequest.CancelRequest()
]};
</pre>
<p>
In order to cancel all requests to "example.com" and "foobar.com", you can add a
second condition, as each condition is sufficient to trigger all specified
actions:
</p>
<pre>
var rule2 = {
conditions: [
new chrome.declarativeWebRequest.RequestMatcher({
url: { hostSuffix: 'example.com' } }),
new chrome.declarativeWebRequest.RequestMatcher({
url: { hostSuffix: 'foobar.com' } })
],
actions: [
new chrome.declarativeWebRequest.CancelRequest()
]};
</pre>
<p>
Register rules as follows:
</p>
<pre>
chrome.declarativeWebRequest.onRequest.addRules([rule2]);
</pre>
<p class="note">
<strong>Note:</strong> You should always register or unregister rules in bulk rather than
individually because each of these operations recreates internal data
structures. This re-creation is computationally expensive but facilitates a
very fast URL matching algorithm for hundreds of thousands of URLs.
</p>
<h2 id="evaluation">Evaluation of conditions and actions</h2>
<p>
The Declarative Web Request API follows the
<a href="webRequest.html#life_cycle">Life cycle model for web requests</a> of
the <a href="webRequest.html">Web Request API</a>. This means that conditions
can only be tested at specific stages of a web request and, likewise, actions
can also only be executed at specific stages. The following tables list the
request stages that are compatible with conditions and actions.
</p>
<p>
<table>
<tr>
<th colspan="5">Request stages during which condition attributes can be processed.
</tr>
<tr>
<th>Condition attribute
<th>onBeforeRequest
<th>onBeforeSendHeaders
<th>onHeadersReceived
<th>onAuthRequired
</tr>
<tr><td>url<td>✓<td>✓<td>✓<td>✓
<tr><td>resourceType<td>✓<td>✓<td>✓<td>✓
<tr><td>contentType<td><td><td>✓<td>
<tr><td>excludeContentType<td><td><td>✓<td>
<tr><td>responseHeaders<td><td><td>✓<td>
<tr><td>excludeResponseHeaders<td><td><td>✓<td>
<tr>
<th colspan="5" style="padding-top:2em">Request stages during which actions can be executed.
</tr>
<tr>
<th>Event
<th>onBeforeRequest
<th>onBeforeSendHeaders
<th>onHeadersReceived
<th>onAuthRequired
</tr>
<tr><td>AddRequestCookie<td><td>✓<td><td>
<tr><td>AddResponseCookie<td><td><td>✓<td>
<tr><td>AddResponseHeader<td><td><td>✓<td>
<tr><td>CancelRequest<td>✓<td>✓<td>✓<td>✓
<tr><td>EditRequestCookie<td><td>✓<td><td>
<tr><td>EditResponseCookie<td><td><td>✓<td>
<tr><td>IgnoreRules<td>✓<td>✓<td>✓<td>✓
<tr><td>RedirectByRegEx<td>✓<td><td><td>
<tr><td>RedirectRequest<td>✓<td><td><td>
<tr><td>RedirectToEmptyDocument<td>✓<td><td><td>
<tr><td>RedirectToTransparentImage<td>✓<td><td><td>
<tr><td>RemoveRequestCookie<td><td>✓<td><td>
<tr><td>RemoveRequestHeader<td><td>✓<td><td>
<tr><td>RemoveResponseCookie<td><td><td>✓<td>
<tr><td>RemoveResponseHeader<td><td><td>✓<td>
<tr><td>SetRequestHeader<td><td>✓<td><td>
</table>
</p>
<p>
<strong>Example:</strong> It is possible to combine a
<code>new chrome.declarativeWebRequest.RequestMatcher({contentType: ["image/jpeg"]})</code>
condition with a <code>new chrome.declarativeWebRequest.CancelRequest()</code>
action because both of them can be evaluated in the onHeadersReceived stage.
It is, however, impossible to combine the request matcher with a
<code>new chrome.declarativeWebRequest.RedirectToTransparentImage()</code>
because redirects cannot be executed any more by the time the content
type has been determined.
</p>
<h2 id="precedences">Using priorities to override rules</h2>
<p>
Rules can be associated with priorities as described in the
<a href="events.html#declarative">Events API</a>. This mechanism can be used
to express exceptions. The following example will block all requests to
images named "evil.jpg" except on the server "myserver.com".
</p>
<pre>
var rule1 = {
priority: 100,
conditions: [
new chrome.declarativeWebRequest.RequestMatcher({
url: { pathEquals: 'evil.jpg' } })
],
actions: [
new chrome.declarativeWebRequest.CancelRequest()
]
};
var rule2 = {
priority: 1000,
conditions: [
new chrome.declarativeWebRequest.RequestMatcher({
url: { hostSuffix: '.myserver.com' } })
],
actions: [
new chrome.declarativeWebRequest.IgnoreRules({
lowerPriorityThan: 1000 })
]
};
chrome.declarativeWebRequest.onRequest.addRules([rule1, rule2]);
</pre>
<p>
It is important to recognize that the <code>IgnoreRules</code> action is not
persisted across <a href="#evaluation">request stages</a>. All conditions of
all rules are evaluated at each stage of a web request. If an
<code>IgnoreRules</code> action is executed, it applies only to other actions
that are executed for the same web request in the same stage.
</p>
<h2 id="apiReference">API Reference: chrome.declarativeWebRequest</h2>
<div class="api_reference">
<h3 id="types">Types</h3>
<div>
<h3 id="type-HeaderFilter">HeaderFilter</h3>
<div>
<dt><span class="type_name"> ( <span id="typeTemplate">object</span> )</span></dt>
<dd>
Filters request headers for various criteria.
</dd> <h4 id="HeaderFilter-properties">
Properties of <a href="#type-HeaderFilter">HeaderFilter</a>
</h4>
<dd><dl> <div>
<a name="property-HeaderFilter-namePrefix"></a>
<dt>
<span class="variable">namePrefix</span>
<span class="property">
(
<span class="optional">optional</span>
<span id="typeTemplate">string</span>
)
</span>
</dt>
<dd>
Matches if the header name starts with the specified string.
</dd>
</div>
<div>
<a name="property-HeaderFilter-nameSuffix"></a>
<dt>
<span class="variable">nameSuffix</span>
<span class="property">
(
<span class="optional">optional</span>
<span id="typeTemplate">string</span>
)
</span>
</dt>
<dd>
Matches if the header name ends with the specified string.
</dd>
</div>
<div>
<a name="property-HeaderFilter-nameContains"></a>
<dt>
<span class="variable">nameContains</span>
<span class="property">
(
<span class="optional">optional</span>
<span id="typeTemplate">array of string or string</span>
)
</span>
</dt>
<dd>
Matches if the header name contains all of the specified strings.
</dd>
</div>
<div>
<a name="property-HeaderFilter-nameEquals"></a>
<dt>
<span class="variable">nameEquals</span>
<span class="property">
(
<span class="optional">optional</span>
<span id="typeTemplate">string</span>
)
</span>
</dt>
<dd>
Matches if the header name is equal to the specified string.
</dd>
</div>
<div>
<a name="property-HeaderFilter-valuePrefix"></a>
<dt>
<span class="variable">valuePrefix</span>
<span class="property">
(
<span class="optional">optional</span>
<span id="typeTemplate">string</span>
)
</span>
</dt>
<dd>
Matches if the header value starts with the specified string.
</dd>
</div>
<div>
<a name="property-HeaderFilter-valueSuffix"></a>
<dt>
<span class="variable">valueSuffix</span>
<span class="property">
(
<span class="optional">optional</span>
<span id="typeTemplate">string</span>
)
</span>
</dt>
<dd>
Matches if the header value ends with the specified string.
</dd>
</div>
<div>
<a name="property-HeaderFilter-valueContains"></a>
<dt>
<span class="variable">valueContains</span>
<span class="property">
(
<span class="optional">optional</span>
<span id="typeTemplate">array of string or string</span>
)
</span>
</dt>
<dd>
Matches if the header value contains all of the specified strings.
</dd>
</div>
<div>
<a name="property-HeaderFilter-valueEquals"></a>
<dt>
<span class="variable">valueEquals</span>
<span class="property">
(
<span class="optional">optional</span>
<span id="typeTemplate">string</span>
)
</span>
</dt>
<dd>
Matches if the header value is equal to the specified string.
</dd>
</div>
</dl></dd>
</div>
</div>
<div>
<h3 id="type-RequestMatcher">RequestMatcher</h3>
<div>
<dt><span class="type_name"> ( <span id="typeTemplate">object</span> )</span></dt>
<dd>
Matches network events by various criteria.
</dd> <h4 id="RequestMatcher-properties">
Properties of <a href="#type-RequestMatcher">RequestMatcher</a>
</h4>
<dd><dl> <div>
<a name="property-RequestMatcher-url"></a>
<dt>
<span class="variable">url</span>
<span class="property">
(
<span class="optional">optional</span>
<span id="typeTemplate"><a href="events.html#type-UrlFilter">events.UrlFilter</a></span>
)
</span>
</dt>
<dd>
Matches if the condition of the UrlFilter are fulfilled for the URL of the request.
</dd>
</div>
<div>
<a name="property-RequestMatcher-resourceType"></a>
<dt>
<span class="variable">resourceType</span>
<span class="property">
(
<span class="optional">optional</span>
<span id="typeTemplate">array of enumerated string ["main_frame", "sub_frame", "stylesheet", "script", "image", "object", "xmlhttprequest", "other"]</span>
)
</span>
</dt>
<dd>
Matches if the request type of a request is contained in the list. Requests that cannot match any of the types will be filtered out.
</dd>
</div>
<div>
<a name="property-RequestMatcher-contentType"></a>
<dt>
<span class="variable">contentType</span>
<span class="property">
(
<span class="optional">optional</span>
<span id="typeTemplate">array of string</span>
)
</span>
</dt>
<dd>
Matches if the MIME media type of a response (from the HTTP Content-Type header) is contained in the list.
</dd>
</div>
<div>
<a name="property-RequestMatcher-excludeContentType"></a>
<dt>
<span class="variable">excludeContentType</span>
<span class="property">
(
<span class="optional">optional</span>
<span id="typeTemplate">array of string</span>
)
</span>
</dt>
<dd>
Matches if the MIME media type of a response (from the HTTP Content-Type header) is <em>not</em> contained in the list.
</dd>
</div>
<div>
<a name="property-RequestMatcher-responseHeaders"></a>
<dt>
<span class="variable">responseHeaders</span>
<span class="property">
(
<span class="optional">optional</span>
<span id="typeTemplate">array of <a href="declarativeWebRequest.html#type-HeaderFilter">HeaderFilter</a></span>
)
</span>
</dt>
<dd>
Matches if some of the response headers is matched by one of the HeaderFilters.
</dd>
</div>
<div>
<a name="property-RequestMatcher-excludeResponseHeaders"></a>
<dt>
<span class="variable">excludeResponseHeaders</span>
<span class="property">
(
<span class="optional">optional</span>
<span id="typeTemplate">array of <a href="declarativeWebRequest.html#type-HeaderFilter">HeaderFilter</a></span>
)
</span>
</dt>
<dd>
Matches if none of the response headers is matched by one of the HeaderFilters.
</dd>
</div>
</dl></dd>
</div>
</div>
<div>
<h3 id="type-CancelRequest">CancelRequest</h3>
<div>
<dt><span class="type_name"> ( <span id="typeTemplate">object</span> )</span></dt>
<dd>
Declarative event action that cancels a network request.
</dd> </div>
</div>
<div>
<h3 id="type-RedirectRequest">RedirectRequest</h3>
<div>
<dt><span class="type_name"> ( <span id="typeTemplate">object</span> )</span></dt>
<dd>
Declarative event action that redirects a network request.
</dd> <h4 id="RedirectRequest-properties">
Properties of <a href="#type-RedirectRequest">RedirectRequest</a>
</h4>
<dd><dl> <div>
<a name="property-RedirectRequest-redirectUrl"></a>
<dt>
<span class="variable">redirectUrl</span>
<span class="property">
(
<span id="typeTemplate">string</span>
)
</span>
</dt>
<dd>
Destination to where the request is redirected.
</dd>
</div>
</dl></dd>
</div>
</div>
<div>
<h3 id="type-RedirectToTransparentImage">RedirectToTransparentImage</h3>
<div>
<dt><span class="type_name"> ( <span id="typeTemplate">object</span> )</span></dt>
<dd>
Declarative event action that redirects a network request to a transparent image.
</dd> </div>
</div>
<div>
<h3 id="type-RedirectToEmptyDocument">RedirectToEmptyDocument</h3>
<div>
<dt><span class="type_name"> ( <span id="typeTemplate">object</span> )</span></dt>
<dd>
Declarative event action that redirects a network request to an empty document.
</dd> </div>
</div>
<div>
<h3 id="type-RedirectByRegEx">RedirectByRegEx</h3>
<div>
<dt><span class="type_name"> ( <span id="typeTemplate">object</span> )</span></dt>
<dd>
Redirects a request by applying a regular expression on the URL. The regular expressions use the <a href="http://code.google.com/p/re2/wiki/Syntax">RE2 syntax</a>.
</dd> <h4 id="RedirectByRegEx-properties">
Properties of <a href="#type-RedirectByRegEx">RedirectByRegEx</a>
</h4>
<dd><dl> <div>
<a name="property-RedirectByRegEx-from"></a>
<dt>
<span class="variable">from</span>
<span class="property">
(
<span id="typeTemplate">string</span>
)
</span>
</dt>
<dd>
A match pattern that may contain capture groups. Capture groups are referenced in the Perl syntax ($1, $2, ...) instead of the RE2 syntax (\1, \2, ...) in order to be closer to JavaScript Regular Expressions.
</dd>
</div>
<div>
<a name="property-RedirectByRegEx-to"></a>
<dt>
<span class="variable">to</span>
<span class="property">
(
<span id="typeTemplate">string</span>
)
</span>
</dt>
<dd>
Destination pattern.
</dd>
</div>
</dl></dd>
</div>
</div>
<div>
<h3 id="type-SetRequestHeader">SetRequestHeader</h3>
<div>
<dt><span class="type_name"> ( <span id="typeTemplate">object</span> )</span></dt>
<dd>
Sets the request header of the specified name to the specified value. If a header with the specified name did not exist before, a new one is created. Header name comparison is always case-insensitive. Each request header name occurs only once in each request.
</dd> <h4 id="SetRequestHeader-properties">
Properties of <a href="#type-SetRequestHeader">SetRequestHeader</a>
</h4>
<dd><dl> <div>
<a name="property-SetRequestHeader-name"></a>
<dt>
<span class="variable">name</span>
<span class="property">
(
<span id="typeTemplate">string</span>
)
</span>
</dt>
<dd>
HTTP request header name.
</dd>
</div>
<div>
<a name="property-SetRequestHeader-value"></a>
<dt>
<span class="variable">value</span>
<span class="property">
(
<span id="typeTemplate">string</span>
)
</span>
</dt>
<dd>
HTTP request header value.
</dd>
</div>
</dl></dd>
</div>
</div>
<div>
<h3 id="type-RemoveRequestHeader">RemoveRequestHeader</h3>
<div>
<dt><span class="type_name"> ( <span id="typeTemplate">object</span> )</span></dt>
<dd>
Removes the request header of the specified name. Do not use SetRequestHeader and RemoveRequestHeader with the same header name on the same request. Each request header name occurs only once in each request.
</dd> <h4 id="RemoveRequestHeader-properties">
Properties of <a href="#type-RemoveRequestHeader">RemoveRequestHeader</a>
</h4>
<dd><dl> <div>
<a name="property-RemoveRequestHeader-name"></a>
<dt>
<span class="variable">name</span>
<span class="property">
(
<span id="typeTemplate">string</span>
)
</span>
</dt>
<dd>
HTTP request header name (case-insensitive).
</dd>
</div>
</dl></dd>
</div>
</div>
<div>
<h3 id="type-AddResponseHeader">AddResponseHeader</h3>
<div>
<dt><span class="type_name"> ( <span id="typeTemplate">object</span> )</span></dt>
<dd>
Adds the response header to the response of this web request. As multiple response headers may share the same name, you need to first remove and then add a new response header in order to replace one.
</dd> <h4 id="AddResponseHeader-properties">
Properties of <a href="#type-AddResponseHeader">AddResponseHeader</a>
</h4>
<dd><dl> <div>
<a name="property-AddResponseHeader-name"></a>
<dt>
<span class="variable">name</span>
<span class="property">
(
<span id="typeTemplate">string</span>
)
</span>
</dt>
<dd>
HTTP response header name.
</dd>
</div>
<div>
<a name="property-AddResponseHeader-value"></a>
<dt>
<span class="variable">value</span>
<span class="property">
(
<span id="typeTemplate">string</span>
)
</span>
</dt>
<dd>
HTTP response header value.
</dd>
</div>
</dl></dd>
</div>
</div>
<div>
<h3 id="type-RemoveResponseHeader">RemoveResponseHeader</h3>
<div>
<dt><span class="type_name"> ( <span id="typeTemplate">object</span> )</span></dt>
<dd>
Removes all response headers of the specified names and values.
</dd> <h4 id="RemoveResponseHeader-properties">
Properties of <a href="#type-RemoveResponseHeader">RemoveResponseHeader</a>
</h4>
<dd><dl> <div>
<a name="property-RemoveResponseHeader-name"></a>
<dt>
<span class="variable">name</span>
<span class="property">
(
<span id="typeTemplate">string</span>
)
</span>
</dt>
<dd>
HTTP request header name (case-insensitive).
</dd>
</div>
<div>
<a name="property-RemoveResponseHeader-value"></a>
<dt>
<span class="variable">value</span>
<span class="property">
(
<span class="optional">optional</span>
<span id="typeTemplate">string</span>
)
</span>
</dt>
<dd>
HTTP request header value (case-insensitive).
</dd>
</div>
</dl></dd>
</div>
</div>
<div>
<h3 id="type-IgnoreRules">IgnoreRules</h3>
<div>
<dt><span class="type_name"> ( <span id="typeTemplate">object</span> )</span></dt>
<dd>
Masks all rules that match the specified criteria.
</dd> <h4 id="IgnoreRules-properties">
Properties of <a href="#type-IgnoreRules">IgnoreRules</a>
</h4>
<dd><dl> <div>
<a name="property-IgnoreRules-lowerPriorityThan"></a>
<dt>
<span class="variable">lowerPriorityThan</span>
<span class="property">
(
<span id="typeTemplate">integer</span>
)
</span>
</dt>
<dd>
If set, rules with a lower priority than the specified value are ignored. This boundary is not persisted, it affects only rules and their actions of the same network request stage.
</dd>