# OnExtraction Hook

The OnExtraction Hook allows you to retrieve information from the HTML of a given page and pass it to a Provider. The function receives Document (opens new window) and Window (opens new window) objects which you can use to operate on the page and return an object. Both of these objects are readonly.

TIP

The OnExtraction Hook is a replacement for Metadata Providers and is the preferred way to extract values from HTML.

# Helper functions

Third-party JavaScript is not executed by default when loading the target page. To overcome this, Middleware comes with a powerful mock system that can be used to interact with third-party JavaScript. These functions can be used to set up the environment needed for the scripts to execute and to interact with the resulting data.

These functions are available to the OnExtraction Hook via the helpers property on the ExtractionArguments object which is passed as an argument to the hook.

TIP

Learn how to use this functions in the Middleware Helper functions article.

# Implementation

This video follows along the detailed implementation guide, which uses a Widget Provider.

In addition to the implementation itself, every Middleware needs a test. Learn how to create a test for OnExtraction Middleware.

Find an additional example with the Youtube-Playlist Widget provider Middleware implementation guide.