This particular API is exclusively accessible within the confines of a DevTools page:
https://i.sstatic.net/NkPQF.png
It's worth noting that in order to utilize this API, you must integrate a page into DevTools via manifest:
"devtools_page": "devtools.html"
Subsequently, this designated page will be initiated (along with its scripts being executed) every time DevTools is launched.
A unique instance of the extension's DevTools page is generated whenever a new DevTools window opens. This DevTools page remains active for as long as the DevTools window is open, thereby granting access to the DevTools APIs and a restricted selection of extension APIs.
To delve deeper into this topic, consult the official documentation.
If you seek similar functionality offered by the DevTools API but prefer to circumvent actually opening DevTools, consider exploring the debugger
API. Nevertheless, exercise caution as it possesses substantial power. Imagine it more as a hefty yet intricate tool rather than a mere hammer.
Alternatively, to interact with the content of a page, you might need to inject a Content Script or monitor traffic using the webRequest
API.