Alternative to WebView() and loadHTML() on macOS?

On iOS I have a script to load HTML and run some JavaScript like this:

let fm = FileManager.iCloud();
let readability = fm.readString(fm.documentsDirectory() + "/Readability.js");
let wv = new WebView();
await wv.loadHTML(args.shortcutParameter.html);

let res = await wv.evaluateJavaScript(readability + "\narticle;");
if (res) { 
	res.url = args.shortcutParameter.url;
}
return res;

With Scriptable on macOS I used to be able to get this same behavior. But as Scriptable on macOS is no longer supported (or not yet…?) is there an alternative to get this same (background HTML + JS loading) behavior? I’ve got Keyboard Maestro, DEVONthink, Hammerspoon et al. but can’t find the same behavior yet.

Of course I can do this in Safari, but I’m looking for something that can do this in the background without bringing a window to the foreground / opening a window.

Any tips? Thanks!

Answering my own question, I completely overlooked I can ofcourse do this directly from Node:

const { JSDOM } = require("jsdom");
const { Readability } = require('@mozilla/readability');

JSDOM.fromURL("https://example.com").then(dom => {
  let article = new Readability(dom.window.document).parse();
  console.log(article);
});
1 Like