If you really want all “links” (and you probably mean a
elements, if you say that – or do you also want link
elements?), you could use fairly simple JavaScript code and send that to the tab with do JavaScript
:
const aElements = document.querySelectorAll("a");
JSON.stringify([...aElements].map(a => a.href));
Note that this returns a JSON string, as you can’t return lists or anything more complicated than string, number or boolean to a do JavaScript
call.
As shown in an older thread, a complete JavaScript script could look like this:
(() => {
const app = Application("DEVONthink 3")
app.includeStandardAdditions = true;
const record = app.selectedRecords[0];
const tw = app.openWindowFor({record: record});
const script = `const aElements = document.querySelectorAll("a");
JSON.stringify([...aElements].map(a => a.href))`;
const result = app.doJavaScript(script, {in: tw});
console.log(result);
})()
I don’t bother doing that in AppleScript, since the list of href
values is a JSON string, which is probably a PITA to convert to a list in AS. In JS, you’d use
const arrayOfHrefs = JSON.parse(result);
And then you can do whatever you want with the list of URIs.