These are the TextExpander snippets I use to capture the URLs of pages I'm browsing and, in some cases, transform them. They use either AppleScript directly or Python with the appscript library and work with both Safari and Google Chrome.
The multibrowser logic works this way:
- If Safari is running, regardless of whether Chrome is running, get the URL from Safari.
- If Chrome is running, and Safari isn't, get the URL from Chrome.
This is an AppleScript snippet that prints the URL of the frontmost tab of the frontmost browser window ("furl" = "front URL"). I use the abbreviation ;furl
to invoke it.
The original version of this snippet (written for TypeIt4Me) is described here. I carried it along when I switched to TextExpander, then generalized it to handle both Chrome and Safari here.
These are AppleScript snippets that print the URL of the nth tab, counting from the left, of the frontmost browser window. I use the abbreviations ;1url
through ;6url
to invoke them.
These expansions of ;furl
were first described here and generalized to work with Chrome and Safari here.
This is an AppleScript snippet that prints the shortened URL of the frontmost tab of the frontmost browser window ("surl" = "shortened URL"). It uses the Metamark shortening API, which requires special characters in the input URL to be encoded. The escapeurl
script, included in the repository, is called by snippet to do the encoding. I use the abbreviation ;surl
to invoke it.
Like ;furl
this was first written for TypeIt4Me and described here, then generalized to work with Chrome and Safari here.
These are AppleScript snippets that print the shortened URLs of the nth tab, counting from the left, of the frontmost browser window. It uses the Metamark shortening API, which requires special characters in the input URL to be encoded. The escapeurl
script, included in the repository, is called by snippet to do the encoding. I use the abbreviations ;1surl
through ;6surl
to invoke them.
These snippets were first described here.
This is an AppleScript snippet that prints the shortened URL of the frontmost tab of the frontmost browser window in parentheses. It uses the Metamark shortening API, which requires special characters in the input URL to be encoded. The escapeurl
script, included in the repository, is called by snippet to do the encoding. I use the abbreviation (;surl
to invoke it.
This snippet was born out of frustration. I often put shortened URLs in parentheses in tweets, and I found myself—because TextExpander insisted on it—invoking ;surl
and then going back to put in the parentheses. This snippet made thing go much faster.
This snippet was first described here.
This is a shell script snippet written in Python/appscript. It prints the "flic.kr" shortened URL for the Flickr photo in the frontmost tab of the frontmost browser window. I use the abbreviation ;flickr
to invoke it.
This snippet was first described here.
This is a shell script snippet written in Python/appscript. It prints the URL of the smaller medium-sized version (the one that's 500 pixels wide if landscape) of the Flickr photo in frontmost tab of the frontmost browser window. I use the abbreviation ;500
to invoke it.
This snippet was first described here, then improved to handle more Flickr pages here.
Note: The appscript library isn't part of the standard distribution, and you won't be able to use the Flickr snippets unless you install it, which will also require (I think) the installation of Apple's developer tools.