Chrome extension: DOMParser is not defined with Manifest v3

Viewed 1327

I have developped an extension to scrape some content from web page and up to now it was working fine but since I switched to manifest v3, the parsing doesn't work anymore.

I use the following script to read the source code:

chrome.scripting.executeScript( 
  {
    target: {tabId: tab.id, allFrames: true},
    files: ['GetSource.js'],
  }, async function(results) 
  {
    // GETTING HTML
    parser = new DOMParser();
    content = parser.parseFromString(results, "text/html");

... ETC ... This code used to work fine but now I get the following message in my console:

Uncaught (in promise) ReferenceError: DOMParser is not defined

The code is part of a promise but I don't think the promise is the problem here. I basically need to load the source code into a variable so that I can parse it afterwards.

I've checked the documentation but I haven't found something mentionned that DOMParser was not going to work with v3.

Any idea?

Thanks

0 Answers
Related