Faster embedding of YouTube videos

I don’t capture entire webpages really. I usually only need the link since many times I am just capturing YouTube urls with a note of what I learned from the video. Also, saving web articles seems to me a better fit for apps like Evernote which is more suited as a filing cabinet. Here’s my script for capturing a url from Safari and making a markdown link from it. It also gets rid of numbers like (21) which Youtube places in the title.

-- In Safari, this copies the Title and URL of the current tab to the clipboard.  
-- Save the script in ~/Library/Scripts/Applications/Safari
-- Using QuickSilver, I assign a trigger to this script using the hotkey ⌥-C (option c), with the scope of the trigger limited to Safari.
-- Inspired by CopyURL + (http://copyurlplus.mozdev.org/)
-- Christopher R. Murphy 
-- Modified by Rishi Talreja to get markdown link and remove YouTube (nn) notification number from title

tell application "Safari"
	set theURL to URL of front document
	set theTitle to name of front document
	--check for (nn) in the title
	if character 1 of theTitle is "(" then
		set brackets to offset of ")" in theTitle
		set sanitisedTitle to characters (brackets + 2) thru -1 of theTitle as string
		set theTitle to sanitisedTitle
	end if
	
	set the clipboard to "[" & theTitle & "]" & "(" & theURL & ")" as string
end tell
2 Likes