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ā ā¦
Iām probably one of those 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
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)
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
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 ā¦