There’s some information on how this could be done to be found here
Which led me to this sample script:
(() => {
const app = Application("DEVONthink 3");
const window = app.thinkWindows()[0];
window.url = "https://bru6.de/jxa"; // replace with your URL
const title = app.doJavaScript("document.title", {in: window.currentTab()});
console.log(title);
})()
It’s trivial stuff, of course. But as you can see, you can run JavaScript code on any URL you’re interested in: DT loads it in its thinkWindow where it’s available to all DOM methods.
I’d probably try to return some kind of JSON from the JavaScript run on the web page and then post-process this before adding anything to DT. But that’s of course a matter of taste. The important thing to note here is that doJavaScript returns a string. I doubt that any other data type would work here, and since you have no access to the DOM outside of doJavaScript, you can’t retrieve DOM subtrees or anything like that to work with in DT.
@cgrunenberg: According to the function library, doJavaScript expects a thinkWindow with in. At least over here, that didn’t work, I had to pass in the window’s tab. I’m not sure if that’s a glitch in my mind, in the documentation or in the underlying scripting support.