About the Author |
|
xxiii | |
About the Technical Reviewer |
|
xxv | |
Acknowledgments |
|
xxvii | |
Foreword |
|
xxix | |
Introduction |
|
xxxi | |
|
Chapter 1 What Are Browser Extensions? |
|
|
1 | (16) |
|
History of Browser Extensions |
|
|
2 | (3) |
|
Customizing Software with Plugins |
|
|
2 | (1) |
|
|
3 | (1) |
|
|
4 | (1) |
|
From Browser Add-ons to Extensions |
|
|
4 | (1) |
|
The Browser Extension Landscape |
|
|
5 | (9) |
|
Comparing Mobile Apps and Browser Extensions |
|
|
5 | (1) |
|
|
6 | (1) |
|
Types of Browser Extensions |
|
|
7 | (7) |
|
|
14 | (1) |
|
|
15 | (2) |
|
Chapter 2 Fundamental Elements of Browser Extensions |
|
|
17 | (26) |
|
|
17 | (3) |
|
|
19 | (1) |
|
|
20 | (1) |
|
The Browser Extension Model |
|
|
20 | (4) |
|
Independent JavaScript Pages and Runtimes |
|
|
21 | (1) |
|
Native APIs and User Interfaces |
|
|
22 | (1) |
|
|
23 | (1) |
|
Observing and Intercepting Network Requests |
|
|
23 | (1) |
|
Elements of Browser Extensions |
|
|
24 | (9) |
|
|
24 | (1) |
|
|
25 | (1) |
|
|
26 | (2) |
|
|
28 | (2) |
|
|
30 | (1) |
|
Devtools Panels and Sidebars |
|
|
31 | (2) |
|
Extension Elements in Action |
|
|
33 | (9) |
|
|
33 | (2) |
|
|
35 | (3) |
|
|
38 | (2) |
|
|
40 | (2) |
|
|
42 | (1) |
|
Chapter 3 Browser Extension Crash Course |
|
|
43 | (32) |
|
|
44 | (1) |
|
|
45 | (1) |
|
Installing Your Extension |
|
|
45 | (5) |
|
|
50 | (2) |
|
Adding a Background Script |
|
|
52 | (4) |
|
|
56 | (4) |
|
|
60 | (4) |
|
|
64 | (3) |
|
Working with Multiple Tabs |
|
|
67 | (2) |
|
|
69 | (3) |
|
|
72 | (3) |
|
Chapter 4 Browser Extension Architecture |
|
|
75 | (22) |
|
|
76 | (4) |
|
Plurality, Lifecycles, and Updates |
|
|
80 | (3) |
|
Background Service Worker |
|
|
80 | (1) |
|
|
81 | (1) |
|
|
82 | (1) |
|
|
82 | (1) |
|
Browser Extension File Server |
|
|
83 | (11) |
|
|
94 | (2) |
|
|
96 | (1) |
|
Chapter 5 The Extension Manifest |
|
|
97 | (70) |
|
|
98 | (1) |
|
Supporting Different Locales |
|
|
99 | (2) |
|
|
101 | (2) |
|
|
101 | (1) |
|
|
102 | (1) |
|
|
102 | (1) |
|
|
103 | (63) |
|
|
104 | (6) |
|
|
110 | (1) |
|
|
110 | (1) |
|
|
111 | (3) |
|
|
114 | (1) |
|
Browser_Specific_Settings |
|
|
115 | (1) |
|
Chrome_Settings_Overrides |
|
|
116 | (8) |
|
|
124 | (1) |
|
|
125 | (6) |
|
|
131 | (1) |
|
|
131 | (3) |
|
|
134 | (2) |
|
Converted_From_User_Script |
|
|
136 | (1) |
|
Cross_Origin_Embedder_Policy |
|
|
136 | (1) |
|
Cross_Origin_Opener_Policy |
|
|
137 | (1) |
|
|
138 | (1) |
|
|
139 | (1) |
|
|
140 | (1) |
|
|
140 | (1) |
|
|
141 | (1) |
|
|
141 | (1) |
|
|
142 | (1) |
|
|
142 | (1) |
|
|
143 | (1) |
|
File_System_Provider_Capabilities |
|
|
144 | (1) |
|
|
145 | (1) |
|
|
146 | (1) |
|
|
146 | (1) |
|
|
147 | (1) |
|
|
148 | (1) |
|
|
149 | (1) |
|
|
150 | (1) |
|
|
150 | (1) |
|
|
150 | (1) |
|
|
151 | (1) |
|
|
152 | (1) |
|
|
152 | (1) |
|
Optional_Host_Permissions |
|
|
153 | (1) |
|
|
153 | (1) |
|
|
154 | (1) |
|
|
154 | (3) |
|
|
157 | (1) |
|
|
157 | (1) |
|
|
158 | (1) |
|
|
158 | (1) |
|
|
159 | (1) |
|
|
159 | (1) |
|
|
160 | (1) |
|
|
161 | (1) |
|
|
161 | (1) |
|
|
162 | (1) |
|
|
163 | (1) |
|
|
163 | (1) |
|
|
164 | (1) |
|
|
164 | (2) |
|
|
166 | (1) |
|
Chapter 6 Understanding the Implications of Manifest V3 |
|
|
167 | (20) |
|
Motivation for Manifest V3 |
|
|
168 | (2) |
|
|
168 | (1) |
|
|
168 | (1) |
|
|
169 | (1) |
|
|
169 | (1) |
|
Implications of Background Service Workers |
|
|
170 | (9) |
|
|
171 | (1) |
|
|
171 | (1) |
|
|
171 | (1) |
|
|
172 | (2) |
|
Service Worker Persistence |
|
|
174 | (2) |
|
|
176 | (3) |
|
|
179 | (1) |
|
Implications of Content Security Policy Restrictions |
|
|
179 | (1) |
|
Implications of DeclarativeNetRequest |
|
|
180 | (5) |
|
|
185 | (2) |
|
Chapter 7 Background Scripts |
|
|
187 | (38) |
|
Web Page Service Workers vs. Extension Service Workers |
|
|
187 | (7) |
|
|
190 | (2) |
|
|
192 | (2) |
|
Manifest v2 vs. Manifest v3 |
|
|
194 | (5) |
|
Scripts vs. Service Workers |
|
|
194 | (1) |
|
|
195 | (1) |
|
No Access to DOM and Limited Global APIs |
|
|
196 | (1) |
|
|
197 | (1) |
|
|
198 | (1) |
|
No Programmatic Background Access |
|
|
199 | (1) |
|
Working with Background Scripts |
|
|
199 | (8) |
|
Inspecting Background Service Workers |
|
|
200 | (2) |
|
|
202 | (3) |
|
Service Worker Termination |
|
|
205 | (2) |
|
|
207 | (13) |
|
|
208 | (2) |
|
Secret Management and Authentication |
|
|
210 | (1) |
|
|
211 | (3) |
|
|
214 | (1) |
|
|
215 | (1) |
|
|
216 | (1) |
|
|
217 | (1) |
|
|
218 | (2) |
|
Forcing Service Worker Persistence |
|
|
220 | (4) |
|
|
220 | (3) |
|
Drawbacks and Limitations |
|
|
223 | (1) |
|
|
224 | (1) |
|
Chapter 8 Popup and Options Pages |
|
|
225 | (20) |
|
|
225 | (8) |
|
|
226 | (3) |
|
Opening and Closing Popup Pages |
|
|
229 | (2) |
|
|
231 | (1) |
|
|
231 | (1) |
|
|
232 | (1) |
|
|
233 | (10) |
|
|
234 | (2) |
|
Opening and Closing Options Pages |
|
|
236 | (1) |
|
|
237 | (1) |
|
|
238 | (1) |
|
Content Script Restrictions |
|
|
239 | (4) |
|
|
243 | (2) |
|
Chapter 9 Content Scripts |
|
|
245 | (24) |
|
Introduction to Content Scripts |
|
|
245 | (10) |
|
|
246 | (1) |
|
|
247 | (3) |
|
|
250 | (4) |
|
|
254 | (1) |
|
|
255 | (1) |
|
Modules and Code Splitting |
|
|
256 | (1) |
|
|
256 | (5) |
|
|
257 | (3) |
|
|
260 | (1) |
|
Specialized Content Script Properties |
|
|
261 | (1) |
|
|
262 | (6) |
|
|
268 | (1) |
|
Chapter 10 Devtools Pages |
|
|
269 | (32) |
|
Introduction to Devtools Pages |
|
|
270 | (12) |
|
|
271 | (1) |
|
Adding panels and sidebars |
|
|
272 | (10) |
|
|
282 | (1) |
|
|
283 | (6) |
|
|
289 | (7) |
|
Content Scripts and Devtools Messaging |
|
|
296 | (2) |
|
Other Devtools API Features |
|
|
298 | (1) |
|
|
299 | (2) |
|
Chapter 11 Extension and Browser APIs |
|
|
301 | (44) |
|
|
301 | (1) |
|
|
302 | (1) |
|
|
303 | (1) |
|
|
303 | (1) |
|
|
304 | (2) |
|
|
304 | (2) |
|
|
306 | (1) |
|
WebExtensions API Quick Reference |
|
|
306 | (9) |
|
|
307 | (1) |
|
|
308 | (5) |
|
|
313 | (1) |
|
|
314 | (1) |
|
|
315 | (29) |
|
|
317 | (1) |
|
Browser and System Control |
|
|
318 | (6) |
|
|
324 | (2) |
|
|
326 | (1) |
|
|
327 | (6) |
|
|
333 | (2) |
|
|
335 | (1) |
|
|
335 | (1) |
|
|
336 | (1) |
|
|
336 | (2) |
|
|
338 | (1) |
|
|
338 | (1) |
|
|
338 | (1) |
|
|
339 | (1) |
|
|
339 | (1) |
|
|
340 | (1) |
|
|
341 | (1) |
|
|
341 | (1) |
|
|
342 | (1) |
|
|
342 | (1) |
|
|
343 | (1) |
|
|
344 | (1) |
|
|
344 | (1) |
|
|
345 | (40) |
|
|
345 | (3) |
|
|
348 | (2) |
|
Using Optional Permissions |
|
|
350 | (3) |
|
Granting Permissions Declaratively vs. Imperatively |
|
|
351 | (1) |
|
Permission Request Idempotence |
|
|
352 | (1) |
|
|
353 | (1) |
|
|
354 | (1) |
|
|
354 | (5) |
|
Testing Permissions Warnings |
|
|
356 | (3) |
|
Considerations for Published Extensions |
|
|
359 | (1) |
|
Triggering the Slow Review Queue |
|
|
359 | (1) |
|
|
360 | (1) |
|
|
361 | (23) |
|
|
361 | (2) |
|
|
363 | (1) |
|
|
363 | (1) |
|
|
363 | (1) |
|
|
364 | (1) |
|
|
364 | (1) |
|
|
364 | (1) |
|
|
364 | (1) |
|
|
365 | (1) |
|
|
365 | (1) |
|
|
365 | (1) |
|
|
366 | (1) |
|
|
366 | (1) |
|
|
366 | (1) |
|
|
366 | (1) |
|
|
367 | (1) |
|
|
367 | (1) |
|
Declarative Net Request Feed back |
|
|
367 | (1) |
|
|
367 | (1) |
|
|
368 | (1) |
|
|
368 | (1) |
|
|
368 | (1) |
|
|
368 | (1) |
|
|
369 | (1) |
|
|
369 | (1) |
|
Enterprise.deviceAttributes |
|
|
369 | (1) |
|
Enterprise.hardwarePlatform |
|
|
369 | (1) |
|
Enterprise.networkingAttributes |
|
|
370 | (1) |
|
|
370 | (1) |
|
|
370 | (1) |
|
|
370 | (1) |
|
|
370 | (1) |
|
|
371 | (1) |
|
|
371 | (1) |
|
|
371 | (1) |
|
|
371 | (1) |
|
|
372 | (1) |
|
|
372 | (2) |
|
|
374 | (1) |
|
|
374 | (1) |
|
|
374 | (1) |
|
|
374 | (1) |
|
|
375 | (1) |
|
|
375 | (1) |
|
|
375 | (1) |
|
|
376 | (1) |
|
|
376 | (1) |
|
|
376 | (1) |
|
|
377 | (1) |
|
|
377 | (1) |
|
|
377 | (1) |
|
|
377 | (1) |
|
|
378 | (1) |
|
|
378 | (1) |
|
|
378 | (1) |
|
|
378 | (1) |
|
|
379 | (1) |
|
|
379 | (1) |
|
|
379 | (1) |
|
|
379 | (1) |
|
|
379 | (1) |
|
|
380 | (1) |
|
|
380 | (1) |
|
|
380 | (1) |
|
|
380 | (1) |
|
|
380 | (1) |
|
|
381 | (1) |
|
|
381 | (1) |
|
|
381 | (1) |
|
|
382 | (1) |
|
|
382 | (1) |
|
|
382 | (1) |
|
|
382 | (1) |
|
|
383 | (1) |
|
|
383 | (1) |
|
|
383 | (1) |
|
|
383 | (1) |
|
|
384 | (1) |
|
|
384 | (1) |
|
|
384 | (1) |
|
|
385 | (44) |
|
Comparing Websites and Extensions |
|
|
385 | (2) |
|
|
387 | (2) |
|
|
387 | (1) |
|
|
387 | (1) |
|
|
388 | (1) |
|
|
389 | (1) |
|
|
389 | (3) |
|
|
392 | (3) |
|
|
392 | (1) |
|
|
393 | (1) |
|
|
393 | (1) |
|
Json Web Token Authentication |
|
|
394 | (1) |
|
|
394 | (1) |
|
OAuth, OpenID, and the Identity API |
|
|
395 | (8) |
|
|
396 | (1) |
|
|
396 | (1) |
|
Configuring the Authorization Platform |
|
|
397 | (6) |
|
|
403 | (1) |
|
OAuth and OpenID Examples |
|
|
403 | (9) |
|
Google OAuth with getAuthToken() |
|
|
404 | (2) |
|
Google OpenID with launchWebAuthFlow() |
|
|
406 | (3) |
|
Manual Github OAuth with launchWebAuthFlow() |
|
|
409 | (3) |
|
|
412 | (15) |
|
|
413 | (3) |
|
|
416 | (4) |
|
The declarative Net Request API |
|
|
420 | (7) |
|
|
427 | (2) |
|
Chapter 14 Extension Development and Deployment |
|
|
429 | (30) |
|
|
429 | (13) |
|
Inspecting Your Extension |
|
|
430 | (8) |
|
|
438 | (1) |
|
|
439 | (2) |
|
|
441 | (1) |
|
Automated Extension Tests |
|
|
442 | (9) |
|
|
443 | (6) |
|
|
449 | (1) |
|
|
450 | (1) |
|
|
451 | (1) |
|
|
451 | (1) |
|
|
452 | (1) |
|
|
452 | (1) |
|
|
452 | (2) |
|
|
452 | (1) |
|
|
453 | (1) |
|
Automated Update Publishing |
|
|
454 | (1) |
|
|
454 | (4) |
|
|
455 | (1) |
|
|
455 | (1) |
|
Setting Up Google Analytics |
|
|
456 | (1) |
|
Install and Uninstall Events |
|
|
457 | (1) |
|
|
458 | (1) |
|
Chapter 15 Cross-Browser Extensions |
|
|
459 | (50) |
|
Introduction to Cross-Browser Support |
|
|
459 | (1) |
|
Browser Coverage Tradeoffs |
|
|
460 | (2) |
|
|
460 | (1) |
|
Chromium Browser Extension Sharing |
|
|
461 | (1) |
|
|
462 | (2) |
|
|
462 | (1) |
|
|
463 | (1) |
|
|
463 | (1) |
|
|
464 | (6) |
|
|
464 | (1) |
|
|
465 | (1) |
|
|
465 | (1) |
|
|
466 | (1) |
|
|
467 | (1) |
|
Safari Extensions App Store |
|
|
468 | (1) |
|
|
469 | (1) |
|
|
470 | (6) |
|
Mobile Extension User Interfaces |
|
|
470 | (1) |
|
|
471 | (1) |
|
|
472 | (2) |
|
|
474 | (2) |
|
|
476 | (1) |
|
WebExtensions API Support |
|
|
477 | (1) |
|
Safari Extension Development |
|
|
478 | (27) |
|
|
478 | (1) |
|
|
479 | (1) |
|
Creating an Extension Project |
|
|
479 | (3) |
|
|
482 | (6) |
|
|
488 | (6) |
|
|
494 | (8) |
|
Deploying to the App Store |
|
|
502 | (2) |
|
Converting an Existing Extension |
|
|
504 | (1) |
|
|
505 | (3) |
|
|
505 | (1) |
|
|
506 | (1) |
|
|
507 | (1) |
|
|
508 | (1) |
|
Chapter 16 Tooling and Frameworks |
|
|
509 | (24) |
|
Building Extensions with React |
|
|
509 | (8) |
|
Single Entrypoint React Extensions |
|
|
510 | (3) |
|
Multiple Entrypoint React Extensions |
|
|
513 | (1) |
|
Reactive State Management |
|
|
514 | (1) |
|
|
515 | (2) |
|
|
517 | (1) |
|
|
517 | (1) |
|
|
518 | (1) |
|
|
518 | (3) |
|
|
519 | (1) |
|
|
520 | (1) |
|
|
521 | (10) |
|
|
522 | (1) |
|
|
523 | (1) |
|
Documentation and Examples |
|
|
523 | (1) |
|
Differential Build Outputs |
|
|
524 | (1) |
|
Automatic Manifest Generation |
|
|
524 | (1) |
|
|
525 | (1) |
|
|
526 | (1) |
|
|
526 | (1) |
|
|
527 | (2) |
|
Extension-friendly Hot Module Replacement |
|
|
529 | (1) |
|
Automated Deployment with Browser Platform Publish |
|
|
530 | (1) |
|
|
531 | (1) |
|
|
532 | (1) |
Index |
|
533 | |