Script: Add Safari tab to reading list

Hi there, this script creates a bookmark for the current Safari tab in DEVONthink 3 and adds this to the reading list.

If you use another browser or want to add other kinds of records I recommend using this script together with a shortcut for the DEVONthink 3 menu which adds to the reading list (you can set custom shortcuts in System Preferences). Run the script, hit your shortcut and you’re done.

-- Add bookmark for current Safari tab and add this new record to DEVONthink 3 reading list

property GroupUUID : "" -- set UUID of the group where bookmarks should live

tell application "Safari"
	tell window 1
		tell current tab
			set theURL to URL
			set theName to name
		end tell
	end tell
end tell

tell application id "DNtp"
	try
		set theGroup to (get record with uuid GroupUUID)
		set theBookmark to create record with {type:bookmark, URL:theURL, name:theName} in theGroup
		add reading list record theBookmark
		display notification theName with title "Added to reading list"
		
	on error error_message number error_number
		if the error_number is not -128 then display alert "DEVONthink 3" & space & error_number message error_message as warning
	end try
end tell
2 Likes

This script doesn’t add the current tab to the reading list.

It does over here?
It placed the tab-contents (as Browser file) in both the location I selected (as prompted when invoking the script), and over in the Reading List.

@pete31 >> many thanks for this!

1 Like

You are right , I mixed up a different script.

Thank you. And thank you pete31

2 Likes

BTW:
It’s not necessary to create a bookmark too, a slightly revised script could only add an item to the reading list:

-- Add current Safari tab to DEVONthink 3's reading list

tell application "Safari"
	tell current tab of window 1
		set theURL to URL
		set theName to name
	end tell
end tell

tell application id "DNtp"
	try
		add reading list URL theURL title theName
		display notification theName with title "Added to reading list"
	on error error_message number error_number
		if the error_number is not -128 then display alert "DEVONthink" message error_message as warning
	end try
end tell
1 Like

Nice, I didn’t try this in the first place. Much better as there are no bookmarks to delete.

However sometimes I also would like to link to a reading list item outside of DEVONthink 3. Any chance to get a Reference URL for your “virtual” reading list item?

Or perhaps you could add a hidden item in the context menu (like its done with the “delete all instances” one) which deletes the record (not just the entry in the reading list)? This could use an extra safe shortcut like shift + option to avoid any accidents…

There’s always a chance :slight_smile: But currently it’s not planned. You could either use boomarks for this scenario or maybe simply insert the destination URL outside of DEVONthink?

:slight_smile: Then please consider adding a (hidden) context menu option to delete the record. Currently it’s a bit complicated to remove records that are only temporarily used:

  • show the record in the database
  • delete the record
  • delete the reading list item

This is screaming for a shortcut

The first two steps should be sufficient and automatically remove the reading list item (at least after emptying the trash)

Yes but it doesn’t really help. Maybe it’s an option to make the “Show in database” item open in a new window when shift is pressed? Deleting is not the problem but losing the reading list window is. So it would help if “Go back” would go back to the reading list. It’s losing the reading list that makes it complicated

Beta 3 will include a new contextual menu command to trash the selected item. Emptying the trash afterwards deletes both the item and its reading list entry.

1 Like

Thanks a lot :smiley:

That’s what I was looking too, just the reading list. Nice to know I can use either one. Thanks for this.

Speaking of trash deletion, do you think in the future we will have an auto delete schedule of the trash?

Actually the first request of is kind as far as I remember. But a scheduled smart rule performing a small script should be able to do this too.