chrome-extensions-samples/functional-samples/cookbook.offscreen-dom
Oliver Dunk d2296fac85
Update dependencies (#1096)
Updates a nunber of dependencies in a single PR. These were
suggested by dependabot but updating them individually would
mean the reposistory would be in a broken state until everything
had merged.

I'm not personally a huge fan of lowercasing doctype, but
Prettier has taken an opinionated stance here and there is not a
way to disable it:

https://github.com/prettier/prettier/issues/15096
2024-02-20 12:53:23 +01:00
..
README.md Update description fields for all samples (#994) 2023-08-17 18:19:42 +01:00
background.js rearranged methods for better readability (#899) 2023-06-13 22:00:09 +02:00
manifest.json Update description fields for all samples (#994) 2023-08-17 18:19:42 +01:00
offscreen.html Update dependencies (#1096) 2024-02-20 12:53:23 +01:00
offscreen.js Add offscreen dom parsing sample (#835) 2023-03-03 14:06:43 +01:00

README.md

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.