Bookmark a webpage to Inbox, with page description

The Capture to DEVONthink browser plugin does not save the page’s description into DEVONthink, which is a missing feature that basically all bookmark managers provide. And the browser keeps asking me if I want to open DEVONthink. So I wrote this script to get things done :slight_smile:

This script is made for Arc browser. The Arc in the script can be changed to other chrome based browser name. Then the script can be run from applications like Alfred and BetterTouchTool.

try
	
	tell application "Arc"
		set theHref to execute front window's active tab javascript "window.location.href"
		set theTitle to execute front window's active tab javascript "document.title"
		set theDesc to execute front window's active tab javascript "document.querySelector('meta[name$=description]')?.content"
		
		set theHref to text 2 thru -2 of theHref
		set theTitle to text 2 thru -2 of theTitle
		if theDesc = "null" then
			set theDesc to ""
		else
			set theDesc to text 2 thru -2 of theDesc
		end if
	end tell
	
	
	tell application id "DNtp"
		create record with {name:theTitle, type:bookmark, URL:theHref, comment:theDesc}
	end tell
	
	display notification "Bookmark Saved to Inbox"
	
on error the error_message number the error_number
	display dialog "Error: " & the error_number & ". " & the error_message buttons {"Cancel"} default button 1
end try

Welcome @liu233w
Thanks for sharing your idea with the group.

However, note the Description does come through with a bookmark from Safari…

As well as Orion and Firefox. :slight_smile:

2 Likes

Description also comes through the same on Chrome

Yep, but is that saved into DEVONthink and searchable?


Edit:
I just did an experiment with this webpage (Bookmark a webpage to Inbox, with page description - #2 by BLUEFROG).

The description of it is your reply content. And I tried to search the sentence sharing your idea with description, but found nothing:

CleanShot 2024-06-02 at 17.34.02@2x

Then after I putting the description into the finder comment, it is searchable:

So I would assume that the description is not indexed.

Interesting - I think it should be searchable if you specifically search in Metadata (or more specifically in Description) - but neither works.

A similar “problem” arises with the annotations. This was solved by the fact that annotations are separate files that can be searched. If this file is deleted, the annotation is retained, but it can no longer be found. If a word is in a Finder comment, it will be found. But these comments cannot be searched. So if you have long Finder comments, you are out of luck. It’s all a bit confusing. I think it has to do with the “desing”. Other apps have a separate search window. You could also use it to search in the inspector … but I don’t know exactly…

If that’s what you want to do (put it in the Finder Comment), a smart rule would suffice.

2 Likes

Yep, but is that saved into DEVONthink and searchable?

Yes, of course.

Also, as has been discussed often, you should be specific in your searches. If you’re looking for the description text, use the Description search prefix. You should also quote that phrase if you’re looking for it specifically.

Thanks for your reply. Although I am afraid that this does not fit my workflow. Because when I look for a bookmark, I usually do not remember whether the keyword is in the title, description or tags (that is the reason why I need everything searchable because I do not have to remember the exact location).

By the way, I realized that DEVONthink to Go put the description into finder comments when I share the web page into it. Why does the desktop version not do the same?


Edit: it seems like that my result is different from yours because I still can find nothing when specify the field to Description:

Why does my search turn up empty?

When the clip I just made to the Inbox has this:

Instead of “matches”, give “contains” a try.

Still blank

My example was using a formatted note :grimacing: :slight_smile:
Bookmarks don’t contain text, etc. The description is dynamically loaded, just like in a browser. Development would have to assess a change in behavior.

4 Likes

That distinction between bookmark vs formatted note is interesting

Trying to understand that a bit more - I converted the same bookmark both to a Formatted Note and to Rich Text

If I search for metadata they both appear:

But if I search for Description only the Formatted Note appears. Why?

A bookmark contains limited metadata, e.g., the name and URL. This is no different than the limitations of an item link.

1 Like

But why is it that when I convert a bookmark to both a Formatted Note and Rich Text, I get difference query responses as above?

1 Like

Look more closely at this. You’re making an assumption in the scenario…

Rich text doesn’t have a Description property. It has a Subject property.

1 Like

OK that makes sense - thank you

You’re welcome.

In case of bookmarks the information is actually grabbed live from the currently previewed web page but it’s not stored/indexed information.

1 Like