nplanchon Posted December 22, 2015 Share Posted December 22, 2015 Hello everyone - I would like to learn how to create a keyboard shortcut which would make it possible for me, whilst in safari at a url, to send that url to Notes for future reading and reference. Thank you Neil Link to comment
deanishe Posted December 23, 2015 Share Posted December 23, 2015 This script gets the URL of the current Safari page and creates a new note in Notes.app containing the URL. Put it in a Run Script action with Language = /usr/bin/osascript (AS), the attach it to a Keyword/Hotkey of your choice. property accountName : "iCloud" property folderName : "Notes" on getSafariUrl() tell application "Safari" to return URL of front document end getSafariUrl on addNote(theText, theTitle) tell application "Notes" tell account accountName set theNote to make new note at folder folderName with properties {body:theText, name:theTitle} end tell end tell end addNote on run (argv) set theUrl to my getSafariUrl() my addNote(theUrl, "URL from Safari") end run Link to comment
OmarKN Posted December 31, 2015 Share Posted December 31, 2015 (edited) hi, Took the chance and expanded the above script a little, and probably it could be streamlighted: to get the title(or name) of the Safari page as Notes title: --- property accountName : "iCloud" property folderName : "Notes" on getSafariUrl() tell application "Safari" to return URL of front document end getSafariUrl on getSafariTitle() tell application "Safari" to return name of front window end getSafariTitle on addNote(theText, theTitle) tell application "Notes" tell account accountName set theNote to make new note at folder folderName with properties {body:theText, name:theTitle} end tell end tell end addNote on run (argv) set theUrl to my getSafariUrl() set theTitle to my getSafariTitle() my addNote(theUrl, theTitle, "URL from Safari") end run -------- / with best regards, Omar K N ( a beginner ) Edited December 31, 2015 by OmarKN Link to comment
OmarKN Posted January 1, 2016 Share Posted January 1, 2016 Let me add the following: The above tweak creates a new note in Notes app with the url in the note body and the title as the name of the note - which is fine! However, I'd prefer an additional line in the body: the title. To look like this in the note: ------ Stay at home dads are all right by me http://www.theguardian.com/lifeandstyle/2015/dec/27/stay-at-home-dads-are-all-right-by-me ------ & with the title as the name of the note. How would this be done? / with best regards, Omar K N Stockholm, Sweden Link to comment
deanishe Posted January 1, 2016 Share Posted January 1, 2016 (edited) property accountName : "iCloud" property folderName : "Notes" -- Return title and URL of current Safari page on getSafariPage() tell application "Safari" set theURL to URL of front document set theTitle to name of front document end tell return {link:theURL, title:theTitle} end getSafariPage -- Add note to Note.app -- the body of the note it theTitle + theText on addNote(theText, theTitle) set theBody to theTitle & return & theText tell application "Notes" tell account accountName set theNote to make new note at folder folderName with properties {body:theBody, name:theTitle} end tell end tell end addNote on run (argv) set pageInfo to my getSafariPage() my addNote(link of pageInfo, title of pageInfo) end run Edited January 1, 2016 by deanishe OmarKN 1 Link to comment
OmarKN Posted January 2, 2016 Share Posted January 2, 2016 Hi and good day Dean, So far - excellent! However, I wonder if the script can be tweaked just a little? Sometimes (~ 50%) in the body of the note (Apple Notes) the title and the url flow after each other like this: A Screenshot Is Worth a Thousand Words – MacStories https://www.macstories.net/roundups/a-screenshot-is-worth-a-thousand-words/ Would it not be more beautiful with a new line break of some sort, so it will always look like this: A Screenshot Is Worth a Thousand Words – MacStories https://www.macstories.net/roundups/a-screenshot-is-worth-a-thousand-words/ I thought stuffing in a linefeed somewhere, but - of course - no success :-) / okn (It's a new year 2016.) Link to comment
deanishe Posted January 8, 2016 Share Posted January 8, 2016 It's supposed to work like the latter case. That's why there's & return & between theTitle and theText. OmarKN 1 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now