How do I get the anchorNode from a Selection object now?

25 views Asked by At

For at least a year, I've been running JavaScript as part of a Mac Automator routine to look up right-clicked links. The URL is then passed to the next automator step to process.

The JavaScript to retrieve the URI was:

function run(input, parameters) {
    var app = Application("Safari");
    app.includeStandardAdditions = true;

    var url = app.doJavaScript('window.getSelection().anchorNode.parentNode.href',{
       in: app.windows[0].currentTab
    });

In the last few weeks, this stopped working, in both Safari and Orion. It looks like I'm still getting back a selection object from getSection(), but that the anchorNode (and the focusNode) are always null. Did something change in WebKit recently? Is there some other way I should be doing this?

0

There are 0 answers