Reading list as Pocket replacement

As some may have read, Pocket is closing down. This was a service where you would click one button in your browser and then put the current page on a reading list which you can subscribe to by RSS.

I wonder If I can replicate the same thing with DEVONthink. Currently what I do is:

  1. Use DEVONthink Browser Plugin to store bookmark in DT Inbox
  2. Switch to DEVONthink, add bookmark to DT Reading list
  3. In DT move bookmark from Inbox to some dedicated group that stores all links that are on the reading list (or have been at some point).

This seems cumbersome. Can I make it ā€˜one click’ somehow?

You could probably write a script that you can trigger with a keyboard shortcut. Alternatively, set up a smart rule that runs on import and handles bookmarks arriving in a certain group the way you want. Save the bookmark from Sorter to that group.

Edit I think that the first approach might create less friction – provided that you use a scriptable browser, ie Safari or Chrome. In that case, something like this might work.

The code is only rudimentarily tested!

(() => {
  const browser = Application('Safari'); // change to 'Google Chrome' if necessary
  const tab = browser.windows[0].currentTab();
  const url = tab.url();
  const title = tab.name(); // use tab.title() for Chrome
  const DT = Application('DEVONthink'); // change to 'DEVONthink 3' if necessary
  const groupID = 'xxxxxxx'; // UUID of the group you want the bookmark moved to
  const newRecord = DT.createRecordWith({name: title, URL: url, record type: 'bookmark'}, 
    {in: getRecordWithUuid(groupID)});
    if (!newRecord) {
   // Handle error
    return;
  } 

  const added = DT.addReadingList({record: newRecord, url: url, title: title});
  if (!added) {
    // Handle Error
    return;
  }
})()
2 Likes

DEVONthink already includes a script for Safari that might satisfy you: Add current tab to DEVONthink’s reading list (found in ~/Library/Scripts/Applications/Safari)

This adds a link to DT’s reading list sidebar, without creating a database record. I like that – it lets you read before you decide if you want a more permanent record. If you also want an actual bookmark item, it should be easy to modify.


If you’re not aware of the browser scripts: To use them, you have to enable the global Script menu from the settings of Script Editor.app:

Scripts in ~/Library/Scripts always appear in this menu, but otherwise it depends on the active application. As you might have guessed, each one has it’s own folder in ~/Library/Scripts/Applications :wink:

From Safari:

Result:

6 Likes

There are probably no problems left to solve by scripting :sad_but_relieved_face:

I was about to say that you provided a solution for Chrome also :smiley: But I just checked, and DT includes the same (slightly modified) script for Chrome.

Don’t worry; I think there are still many things left to script :stuck_out_tongue:

If nothing else, your code is a nice instructive example of JXA to learn from :slight_smile:

If you prefer saving an offline version straight away, you could just keep using the sorter/clipper – but add a readlist tag, which you keep in the favorites section of the sidebar for easy access.

Or you could set up a smart rule that adds stuff to the reading list when you clip/import with a certain tag.
Sounds like you want a history even if you clear the tag or remove things from the list…? In that case you could set the rule to also move or replicate items to a dedicated group. Example:

3 Likes

I have just recently figured out a way of using DT as a read-it-later tool, that works for me and my specific needs.

I do most of my research in the blog reader Feedly. Feedly’s Pro account lets you create an automatic backup of the articles to Dropbox. So I just index those Dropbox folders into my DT Inbox. Luckily, Feedly saves articles as nice clutter-free web archives, which are easy to read and save.

For any articles outside of Feedly that x I want to save, I use my iPhone’s share command to save its bookmark to another folder in Dropbox, which is also indexing in my DT In box.

Then in Dropbox I use smart rules to scan those folders (on import, on launch), convert any bookmarks to a web archive, and move them to a ā€œRead and Fileā€ folder. I also created a new DT database for ā€œReferencesā€, where I categorize and save my favorite articles.,

I’ve been using this system for the past month, and it has been a game changer for me. Articles I used to lose or forget, are now being collected in my DT database.

3 Likes

Ha. That triggered my curiosity, and I came up with a single script that works with Safari, Chrome and Edge (and possibly others that are scriptable after minor additions)

function run(input, parameters) {
  const SE = Application("System Events")
  SE.includeStandardAdditions = true;
  const frontProc = SE.processes.whose({frontmost: true})[0];
  const procName = frontProc.displayedName();

  // Bail out if no supported browser is currently active
  if (! ['Safari', 'Google Chrome','Microsoft Edge'].includes(procName)) {
    SE.displayAlert('No browser selected');
    return;
  }

  // Get title and URL of currently active tab
  const app = Application(procName);
  const window = app.windows[0];
  const tab = procName === 'Safari' ? window.currentTab() : window.activeTab();
  const url = tab.url();
  const name = procName === 'Safari' ? tab.name() : tab.title();

  SE.displayAlert(`"${name}": ${url}`);
}

One can create a service using Automator with this script and assign a keyboard shortcode to it. It’ll grab the title and URL of the active tab of the frontmost browser and (as it stands now) display them. The modification to add a bookmark to DT with this information is trivial.

No need to decide which script to run :wink:

3 Likes

Christian, apologies for being a total js newbye - I copied the script and pasted it into Script Editor, pressed ā€œRunā€ - I get the message saying ā€˜No browser selected’. I suspect I should not defocus the browser(s) and focus Script Editor, right… how do I make this work?

You cannot run that script from script editor because then script editor would be the foremost program – and it is not a browser, as the script correctly deduces. The aim is to have it run while the browser is the frontmost app. The only way I know is to install it as a service via Automator (see above). There may be other ways, perhaps @bluefrog knows more.

2 Likes

Thanks! - I will implement your suggestion.

Christian, in script v2, where is the code for creating a new record - should I have joined your 2 scripts?

Not ā€œjoinedā€, just added the lines that create the record to the second script, and remove the alert.
These are the relevant lines:

  const DT = Application('DEVONthink'); // change to 'DEVONthink 3' if necessary
  const groupID = 'xxxxxxx'; // UUID of the group you want the bookmark moved to
  const newRecord = DT.createRecordWith({name: name, URL: url, record type: 'bookmark'}, 
    {in: getRecordWithUuid(groupID)});
    if (!newRecord) {
   // Handle error
    return;
  } 

  const added = DT.addReadingList({record: newRecord, url: url, title: title});
  if (!added) {
    // Handle Error
    return;
  }

hm, I’m trying but I’m getting quite lost… Learning js on the fly :wink:

Thanks for all replies. I’m using Firefox which apparently is not suited for these scripts.

Searching around I found this old link

And then I noticed 2 things:

  1. I don’t even know what the reading list is. Probably some sort of smart group or just list that exists in… well where? How does it sync? Does it sync with global inbox?
  2. I don’t need the reading list. It duplicates what is already there because I can just put all my ā€žPocket Linksā€œ in a dedicated group (or tag them)

So it seems my question is moot. I’m just a bit sad that I now have two apps to read stuff later: DT and my RSS Reader. Sure I could use DT as an RSS reader but it does not work well for that purpose… or well, maybe I should try that. Has anything improved with RSS and sync in the last years? Different topic, though.

Firefox is not suitable for any scripting at all. Unfortunately.

Windows > Sidebar: Reading List in the built-in Help and manual

I have RTFH! (read the fine handbook) but it says nothing about my questions: It is on page 136. It is non-technical and low information density: ā€œYou can put things to read later on the reading listā€. ā€œClick ā€˜remove item’ to remove an itemā€. My questions are unanswered: What is the reading list? Is it part of a database (which?) and how does it sync? What do I need to sync to sync the reading list? I assume it is the global inbox.

I don’t think so, since it didn’t appear in the list of databases I’d get from DT in a script.

As to syncing – no idea

If you look in ~/Library/Application Support/DEVONthink 3, you will see the file ReadingList.plist (and a bunch of other .plist files). I don’t know the technical details, but it’s global just like your custom metadata fields.

Select a sync location > Show info:

In DTTG you have to enable ā€œReading positionsā€ in the settings for a sync location. (I honestly found the labelling unclear without the above window fresh in mind.)


And yeah, no AppleScript with Firefox. If you want to use Firefox, the browser extension with a tag and/or smart rule is still an option.

Actually, if you want a one click solution, there is also the option of using bookmarklets. DEVONtech provides some here, and you can look at the URL commands in the manual for more ideas.

For example, adding a bookmark while specifying destination and tags:

javascript:window.location='x-devonthink://createBookmark?title='+encodeURIComponent(document.title)+'&location='+encodeURIComponent(window.location)+'&destination=<UUID>'+'&tags=<TAGS>';
3 Likes