Skip to content

Instantly share code, notes, and snippets.

@mmertsock
Last active September 24, 2020 20:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mmertsock/7118c4015de294ee8af8f99d9963c16a to your computer and use it in GitHub Desktop.
Save mmertsock/7118c4015de294ee8af8f99d9963c16a to your computer and use it in GitHub Desktop.
AppleScript: get GitHub title and URL
-- For copying/pasting the title and URL of something from GitHub into an email or whatever.
-- output: places text into clipboard, e.g. "TitleOfPullRequest https://github.com/x/y/pull/123"
tell application "Safari"
set my_n to name of current tab of front window
set my_u to URL of current tab of front window
set my_script to "((document.title.match(/^(.*)( · Issue #| by [^ ]+ · Pull Request)/) || [])[1] || document.title)+ ' ' + document.location.href;"
set my_t to (do JavaScript my_script in current tab of front window)
set the clipboard to my_t
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment