error message when using "Save to..." script in Sa

When running the script below in Safari, I get an error msg that says “Safari got an error: Can’t make source of document 1 into type reference.” This despite that I created this script by opening another one that works fine, changing the destination location (to the existing group “/FRONT BURNER/VIOLENT BIOLOGY/”, and saving the file (via Save as…) to a new Applescript. Anyone know why this isn’t working and how to fix?

tell application “Safari”
activate
try
if not (exists document 1) then error “No document is open.”

	set this_url to the URL of document 1
	set this_source to the source of document 1
	set this_title to the name of window 1
	
	tell application "DEVONthink Pro"
		activate
		set incomingGroup to create location "/FRONT BURNER/VIOLENT BIOLOGY/"
		create record with {name:this_title, type:html, URL:this_url, source:this_source} in incomingGroup
		
	end tell
	
on error error_message number error_number
	if error_number is not -128 then
		display dialog error_message buttons {"OK"} default button 1
	else
		error number -128
	end if
end try

end tell :frowning:

The script works fine over here - which page/URL did you try to add to DEVONthink? E.g. the script fails if an image, a PDF document or a movie is visible in the frontmost Safari window.