How to trigger smart rule only when sorter used?

The approach relies on a combination of mechanisms:

  1. A Smart Rule in DEVONthink that is triggered when a new web page bookmark is created if the bookmark contains a certain tag. In my use, this Smart Rule then runs an AppleScript program, but obviously it could do other things.
  2. A custom bookmarklet that can be used from Safari that, when invoked, sends a URL to DEVONthink with the required tag.

Here is the bookmarklet code:

javascript:window.location='x-devonthink://createBookmark?title='+encodeURIComponent(document.title)+'&location='+encodeURIComponent(window.location)+'&referrer='+encodeURIComponent(document.referrer)+'&tags=convert-to-pdf';

And here is a screenshot showing the Smart Rule configuration:

If one wanted to change the name of the tag, it would need to be changed in the bookmarklet (it’s at the very end of the bookmarklet code, following tags=) and also in the Smart Rule.

Some further explanation may be warranged about what the Smart Rule does. This particular Smart Rule is something I use to create PDFs from web pages in a way that tries to delay with possible dynamically-generated content in the page. (C.f. this discussion.) Note that the rule removes the tag before creating the PDF, because the PDF file will inherit any tags on the bookmark when DEVONthink creates it, and you don’t want the tag to be put on the resulting PDF file. The rule also moves the original bookmark to the trash because for my purposes, it’s no longer needed after the PDF conversion is done.

FWIW, I put everything up in a GitHub repo.