What's needed to get Devonthink recognized as Frontmost Browser?


I am trying to get Devonthink recognized as a browser so that I can use the %FrontBrowserURL% token to capture the URL open in frontmost window of Devonthink.

According to manual:Preferences [Keyboard Maestro Wiki] I did set the following and restarted my machine.

defaults write com.stairways.keyboardmaestro.engine AdditionalWebBrowserBundleIDs com.devon-technologies.think3

However it does not seem to be capturing the URL opened in Devonthink. What's missing?

Note: I hesitated between posting here or on the Devonthink forums. Decided to start here to understand what's needed from Devonthink, to then later asking for it from Devonthink team.

To quote from token:FrontBrowserURL [Keyboard Maestro Wiki]

The %FrontBrowserURL% token (v8+) returns the URL of the active tab of the front browser (the most recently front web browser of Safari or Google Chrome).

and similarly, to quote from actions:Browser Actions [Keyboard Maestro Wiki]

Keyboard Maestro provides a large set of web browser actions that work with Safari and Google Chrome

Safari has one osascript interface, and Chrome-derived browsers have another.

Firefox is largely out of reach.

DEVONthink is scriptable, but anything you do with it will need to use its own scripting interface.

(e.g. with Keyboard Maestro's Execute AppleScript or Execute JS for Automation actions)

Keyboard Maestro's Safari+Chrome tokens (and actions) won't be relevant.

This might be one approach to using DEVONthink's own scripting interface:

DEVONthink browser window URL.kmmacros (3.6 KB)

Expand disclosure triangle to view JS Source
(() => {
    "use strict";

        devonWindows = Application("DEVONthink 3")

    return 0 < devonWindows.length ? (() => {
        const tabs = devonWindows.at(0).tabs;

        return 0 < tabs.length ? (
        ) : "No tabs open in front DEVONthink window";
    })() : "No DEVONthink windows found";
1 Like

Thx a lot for the way you propose and for the script.

I will try it out, as a patch.

Keyboard Maestro's Safari+Chrome tokens (and actions) won't be relevant.

My question was actually : how could they be made relevant. What does it take. Do you happen to know or who in this forum would?


They can't.

DEVONthink implements neither the Safari scripting interface nor the Chrome scripting interface.

They can't be "made relevant" even for Firefox, let alone for DEVONthink.

The most relevant, detailed thread about this type of question is here:

If a browser is very popular, and if it uses a similar or identical dictionary to either Chrome or Safari, my prediction is that KM would add support for it. But look at this chart of browser popularity on MacOS:

If you are wondering why Firefox isn't supported in KM, when it has 11% of all OS X users, that's because "Firefox doesn't support AppleScript." This statement comes from PeterNLewis and it implies that if Firefox did support AppleScript, then KM would add actions for it. I infer that the threshold for support is somewhere below 11%.

The Brave Browser is very similar to Chrome, in terms of AppleScript support, so there are threads on this forum that give advice on how to make it work. But since Brave is under 0.3% of all MacOS browsers used by users, that's probably why it doesn't have actions in KM specifically to support it.