Skip to content

Latest commit

 

History

History

cookbook.offscreen-dom

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

This recipe shows how to use DOMParser in an Extension Service Worker using the Offscreen document.

Context

Extension Service Workers don't have direct access to the DOM. This example demonstrates how to use an offscreen document for parsing and modifying DOM from an Extension Service Worker. Offscreen documents and Extension Service Workers exchange data using message passing.

Running this extension

  1. Clone this repository.
  2. Load this directory in Chrome as an unpacked extension.
  3. Open the Extension menu and click the extension named "Offscreen API - DOM Parsing".

If you inspect the Extension Service Worker in Chrome DevTools, you can see the result of the DOM transformation in the console view.