Exporting selected text from Safari page to DEVONthink To Go

I would like to do this in one step:

  • select text on a Safari web page on my iPhone
  • export selected text and name and/or URL of the web page to DEVONthink To Go

Any ideas?

1 Like

Perhaps a shortcut? By “name” of the web document, you mean its title, I suppose?

yes, I mean the title. I tried it with Shortcuts but could not even get the selected text:

These were my very first steps with Shortcuts. So maybe my approach is completely wrong.

Here’s what I came up with (in German, I’m afraid)

The DTTG action uses the name and the URL from the Shortcut input. The text is taken from the current selection via JavaScript. That works apparently ok here.

But shortcuts is still a mess.

Thanks a lot, you pointed me in the right direction. I reworked my shortcut and simplified it:

Also no need for JavaScript :wink:

BUT: Script runs fine on iPad but returns only the name of the document and not URL and selection on iPhone. You’re right: Shortcuts is a mess.

BTW: I wonder why DEVONthink is available in Apple Shortcuts only on iPhone and iPad but not in MacOS…

1 Like

I think that’s because you can easily script DT on macOS. No need for a crutch like Shortcuts if you have The Good Stuff™

4 Likes

Btw: are you using Page URL at all?

yes, to create a hyperlink in the markdown doc

But not to set the record’s URL?

No. That document is only a note and I may later add quotes from other sources. I use the record‘s URL only for reference docs like bookmarks, PDFs etc.

I may have misunderstood what you’re saying here, but you can end up with different results depending on how you invoke the Shortcut:

  1. If you select some text and use the ‘Share’ option in the popup context menu, it will only share the text, so you won’t be able to extract any of the other page details.
  2. Selecting some text and then invoking the Shortcut via the upward-pointing arrow in the Safari menu bar will allow you to extract all the required info.

Your Shortcut looks correct to me. Here’s my version, slightly simplified by selecting the variables inline rather than defining them separately (you can insert the ‘Shortcut Input’ variable multiple times, then just tap on it to select which data you want to use in each instance).

2 Likes

That’s a good idea to select the variables inline. I tried exactly your script but I’m not able to get the selected text. Here it returns:

<blockquote>

</blockquote>

with no selected text in between.

On the iPad I get Page Selection, Name, Page Content and Page URL without problem, on the iPhone I get only Name. It’s driving me nuts!

Thanks.

I tried this out. Worked as advertised on both my ipad (OS 16.2) and iphone (iOS 16.1.1)!

Finally fixed: my iOS language was German, on the iPad it was English. When I changed the language on the iPhone to English the shortcut worked as expected. Thank you all for your helpful input!

2 Likes

Seriously – the shortcuts are language dependent? This thing is even worse than I thought.

1 Like

Yes, and it even wasn‘t enough to set Shortcuts app and Safari to the same language. I had to change the OS language!

Well, English is of course far superior to German, so you’re better off with that anyway :stuck_out_tongue_winking_eye:

:partying_face::+1:

I’m curious why you’re using the HTML <blockquote> element in your Markdown document.

I’m not a Markdown purist by any stretch of the imagination but I’m surprised @chrillek had no comment on that :stuck_out_tongue:

PS: Shortcuts

2 Likes

I’m getting lazy, I guess.

But it’s a good question: why not simply use > as is standard in MD? Yes, I know that HTML elements are allowed in MD.