Batch capture multiple URLs

I’m not sure how to open a web browser page from within DevonTHINK itself.

Thanks for this, super helpful.

  1. Is it possible to have it save a clutter free paginated version? I don’t see a way to add “clutter free” to the smart rule.
  2. When I save to pdf, I keep getting a cookie prompt pop up for any article page on the site I’m trying to save from, even after navigating to the page manually within devonthink and making a choice in the hope it would be remembered by the clipping engine. I’ve tried making sure cookies are always accepted in the settings, and toggling nearly everything on the web settings page, but I still get the lousy popup embedded on every PDF with all the content dimmed. What am I missing?

Only via AppleScript/JXA and using the Execute Script smart rule action.

Thanks. Tried that. (Error -1708) with your script, however. What did I do wrong?

You can’t execute that kind of script in a smart rule, since the perform smart rule handler is missing. Please check out the manual re Automation.

Tried that. No more error, but also no PDF in the output. I must still be missing something?

Did you read the Automation > Smart Rule Scripts section or looked at other smart rule script examples?

  1. The parameter for your handler is wrong. It should be a variable, e.g., theRecords.

  2. You shouldn’t be processing the selection. The smart rule isn’t handling a selection. Strip out the if…then regarding the selection.

  3. It’s handling matched items not a selection, so the repeat loop should be referencing theRecords or whatever the handler parameter’s variable is.

Yes, but it’s entirely possible my limited familiarity with code, applescript, and scripting in general may mean I simply didn’t understand something. If I knew applescript, this would probably solve the problem. I’m not quite sure what to do with your instructions.

Edit: ChatGPT helped me figure it out, thanks!

As for my second question: Is there a way to deal with the cookie popup with your webclipper?

I would not rely on ChatGPT for something like this. It’s well known for producing pseudo-code. What did it suggest?

And no, we have no control over that.

I’m well aware, but it often works as long as one reads along and checks it.

-- Download URLs as clutter-free PDF documents (Paginated)
-- Adjusted for use with DEVONthink smart rule.
-- Original script by Christian Grunenberg.

on performSmartRule(BookmarktoPDF)
	tell application id "DNtp"
		if BookmarktoPDF is not {} then
			try
				show progress indicator "Downloading..." steps (count of BookmarktoPDF)
				repeat with BookmarktoPDF in BookmarktoPDF
					set theName to name of BookmarktoPDF
					set theURL to URL of BookmarktoPDF
					step progress indicator theName
					if theURL begins with "http:" or theURL begins with "https:" then
						set theParents to parents of BookmarktoPDF
						set theCopy to create PDF document from theURL name theName in (item 1 of theParents) with pagination and readability
						repeat with i from 2 to (count of theParents)
							replicate record theCopy to (item i of theParents)
						end repeat
						set creation date of theCopy to creation date of BookmarktoPDF
						set comment of theCopy to comment of BookmarktoPDF
						set rating of theCopy to rating of BookmarktoPDF
						set label of theCopy to label of BookmarktoPDF
						set state of theCopy to state of BookmarktoPDF
					end if
				end repeat
				hide progress indicator
			on error error_message number error_number
				hide progress indicator
				if the error_number is not -128 then display alert "DEVONthink" message error_message as warning
			end try
		end if
	end tell
end performSmartRule

It is not helpful to post code as screenshots. Just requires more work for the audience to read it (especially if it’s in dark mode). Please post code as such, namely included in three backticks
```
code goes here
```

As to your script: Please read the corresponding part of the manual thoroughly and check out sample code here in the forum (searching for ‘on performsmartrule’ should turn up enough hits).

Simply wrapping the script in a handler doesn’t cut it, as the script itself works with the selected records, while a smart rule script receives the records as a parameter of the handler. You wrote that part, but then you didn’t adjust the rest of the code, so it’s working with a selection which is non-existing. Consequently, you convert 0 records of an empty selection to nothing.

What was your query to ChatGTP and did you just paste the code into the request?

By the way, as I looked at this more closely, you’re not going to bypass those cookie or login issues. When you’re using the clutter-free option, there is no login or cookie information being passed through the clutter-free mechanism.

A bit long to paste here, so here’s the interaction.

Thanks for the assistance! It got me to the result I needed, even though I have to use the less desirable clutter-free option. It’s a bummer since clutter-free auto-removes the article publication dates for the ~800 pages saved.