HTML Agility Pack nodejs alternative jsdom

In the world of powershell and dotnet there is HtmlAgilityPack library which allows to perform all possible tricks around HTML

The same is true for nodejs world, there is jsdom

Here is a short example of how it looks like:

const { JSDOM } = require("jsdom")
const {readFileSync} = require('fs')

const dom = new JSDOM(readFileSync('index.html', 'utf-8'))
const document = dom.window.document

for(const s of Array.from(document.querySelectorAll('script'))) {
    console.log(s.getAttribute('src'))
}

const x = document.createElement('SCRIPT')
x.setAttribute('foo', 'bar')
x.innerHTML = "console.log('hello')"
document.body.appendChild(x)

console.log(dom.serialize())