Clip to DEVONthink

How do you execute that while browsing? As a JavaScript bookmark of some sort?

You execute the JavaScript by inserting it into a window (works for a DT window, as well as Safari windows). In DT:

set captureWindow to open window for record theRecord
do JavaScript "document.head.appendChild(document.createElement('style')).innerHTML='body, p, h1, h2, h3, h4, h5, h6 { font-family: sans-serif !important; hyphens: manual !important; -webkit-hyphens: manual !important; }'" in captureWindow

I actually like that. Makes the main code a lot easier to read and understand.

Why not using a@media print rule? And if itā€™s about printing to PDF, Helvetica can be used instead of sans-serif. Thatā€™s guaranteed to be available on all PDF devices.

Agreed - itā€™s not common in Applescript but it indeed makes it more readable.

@media print does not apply to capturing PDF - but using Helvetica sounds like a good tip - thanks for that!

Bummer. Indeed, it doesnā€™t. Well, I think it should. Thatā€™s what @media print is all about, isnā€™t it? Also, if a website does already provide a print style sheet, that will not take effect either. Weird.

It would if you would use the option ā€œPrint to PDFā€ - but capturing basically just uses the screen layout and saves that to PDF.

I got that. I just donā€™t think that itā€™s reasonable to do that. Given that the screen layout probably contains navigation and a lot of other things that just do not make sense in a PDF.

But then there are always those users who insist that the PDF ā€œmust look exactly like the web documentā€ ā€¦

1 Like

Iā€™m probably one of those :slight_smile: Not religiously, but it is why Iā€™m using PDF to capture resource material. All the links, comments etc. provide context when I visit something later (e.g. when the website have disappeared). So for me itā€™s especially the reason why I donā€™t capture clutter-free or ā€œReaderā€-type PDFs. Itā€™s basically a screen capture with the added benefit of searchable text :slight_smile:

Are you doing this by attaching that as a script to the Group that contains your clipped items? Or some other way?

The identifier might indeed change and the order is undefined. Therefore this kind of usage is actually discouraged.

No, Iā€™m using it in my script to capture PDF from webpages here: Automatically capture and annotate items (to use with Obsidian)

1 Like

Could you suggest an alternative? My quick idea now would be that youā€™d have to use the Foundation framework to compare dates (or some ugly string-based workaround of that)

To solve which problem actually? I just had a quick look at the updateUrl function and itā€™sā€¦ wellā€¦ doing things I would never do like that :slight_smile:

Find the last added record in a database

Sounds like the addition date should be sufficient.

Are results of search "additionDate:Today" always sorted based on addition date? A small test suggests they are, but arenā€™t that the same non-guarantees as earlier?

The order isnā€™t defined in this case but a loop could be easily used to find the latest record in the results.

OK - thanks. Unfortunately comparing dates in AppleScript is non trivial so some way of comparing e.g. through NSDate or comparing date strings should be used then.

Itā€™s easy elsewhere: if (date1 < date2) ā€¦. Just saying ā€¦

1 Like