Using an existing implementation is a lot easier than writing your own. The DOM is huge.
In fact, I'd go as far as saying: to interact with a website, you don't want just a JavaScript engine (like V8) with a few additions. You most probably want a full web renderer. I don't have any specific suggestions (1) because I don't know that space very well and (2) because you haven't described what exactly you want to do. It could be that Selenium or Puppeteer are your best options; or maybe the Chromium Embedded Framework; or maybe the Qt WebEngine; etc.
V8 is just a JavaScript engine [1]. It doesn't know anything about HTML, or the DOM, or CSS, etc. var html = "<button onclick=...>click me</button>";
is just a meaningless string to V8. It doesn't know what a button is, or an onclick handler. You can't use it to draw a button onto the screen. If you tried e.g. eval(html)
, you'd get a SyntaxError
, because that string isn't valid JavaScript, and V8 only deals with JavaScript.
[1] or more accurately: an ECMAScript engine. Defining colloquial terms is a bit tricky; some people say that "JavaScript" and "ECMAScript" are synonyms, others say that "JavaScript" == "ECMAScript language core + DOM bindings and other common browser stuff".