├── README.md ├── backup_bookmarks ├── GetBookmarks.pdf ├── GetBookmarks.scpt └── README.md ├── backup_messages ├── GetMessages.applescript ├── README.md └── actions │ ├── ConvertDB.py │ ├── CreateDB.applescript │ ├── ExtractDB.applescript │ ├── ImportDB.applescript │ └── InsertData.applescript ├── iTunes_to_twitter ├── README.md ├── Tweet via Chrome.applescript ├── Tweet via Firefox.applescript ├── Tweet via Safari.applescript ├── Tweet via Twitter Scripter.applescript └── scpt files │ ├── Tweet via Chrome.scpt │ ├── Tweet via Firefox.scpt │ ├── Tweet via Safari.scpt │ └── Tweet via Twitter Scripter.scpt └── shorten_URL ├── Goo.gl URL Shortener ├── Goo.gl URL Shortener.applescript ├── README.md └── scpt file │ └── Goo.gl URL Shortener.scpt └── Shorten Github URL ├── README.md ├── Shorten Github URL.applescript └── scpt file └── Shorten Github URL.scpt /README.md: -------------------------------------------------------------------------------- 1 | ### Collection of Applescript files 2 | 3 | This repository contains a couple of Applescript file, which you might find useful. 4 | 5 | * [backup_messages](https://github.com/nrollr/applescript/tree/master/backup_messages/) - a script which retrieves your text messages from your iPhone backup directory and copies only the relevant content to a brand new database file (.sqlite format) 6 | 7 | * [backup_bookmarks](https://github.com/nrollr/applescript/tree/master/backup_bookmarks/) - a script which allows you to backup your Firefox bookmarks to a separate database file (.sqlite format) 8 | 9 | * [iTunes_to_twitter](https://github.com/nrollr/applescript/tree/master/iTunes_to_twitter/) - a script which fetches the name and artist of the song currently playing in iTunes, composes a tweet with these values and sends it to Twitter 10 | 11 | * [shorten_URL](https://github.com/nrollr/applescript/tree/master/shorten_URL/) directory, contains to scripts related to URL shortening: 12 | > - a script requesting a **GitHub URL** as input and returns **the shortened git.io URL**. The short URL is directly copied to the clipboard, when completed the user receives an additional notification via the OSX notification center. 13 | > - a script requesting **any URL** as input and returns **the shortened goo.gl URL**. The short URL is directly copied to the clipboard, when completed the user receives an additional notification via the OSX notification center. 14 | -------------------------------------------------------------------------------- /backup_bookmarks/GetBookmarks.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nrollr/Applescript/ae421493e080fe06da741da62b4ac542e0e15792/backup_bookmarks/GetBookmarks.pdf -------------------------------------------------------------------------------- /backup_bookmarks/GetBookmarks.scpt: -------------------------------------------------------------------------------- 1 | 2 | -- Path to Places.sqlite file: ~/Library/Application Support/Firefox/Profiles// 3 | -- All steps mentioned beneath are compiled in GetBookmarks.app (ref. GetBookmarks.scpt) 4 | -- Define variables; ProfileFolder corresponds to the 5 | property ProfileFolder : "" -- change/edit to your own 6 | property dbName : "places.sqlite" 7 | 8 | on run 9 | -- Set up different directory definitions 10 | set DefaultFolder to ((path to home folder) as text) & "Library:Application Support:Firefox:Profiles" 11 | set BackupFile to DefaultFolder & ":" & ProfileFolder & ":" & dbName 12 | set TempFolder to ((path to home folder) as text) & "Temp" 13 | 14 | -- Copy the Messages database to your Home directory and rename 15 | tell application "Finder" 16 | copy file BackupFile to folder TempFolder 17 | 18 | set dbCopy to TempFolder & ":" & dbName 19 | set dbFile to "PlacesDB.sqlite" 20 | set name of file dbCopy to dbFile 21 | end tell 22 | 23 | -- Variable: sourceDB = PlacesDB.sqlite 24 | -- Variable: destinationDB = BookmarksDB.sqlite 25 | 26 | -- Place this script in the same directory as the PlacesDB.sqlite file 27 | tell application "Finder" to get folder of (path to me) as Unicode text 28 | set workingDir to POSIX path of result 29 | 30 | -- Create a new database called BookmarksDB.sqlite and add tables 31 | set destinationDB to space & workingDir & "BookmarksDB.sqlite" & space 32 | set start to "sqlite3" & destinationDB & quote 33 | set tableA to "CREATE TABLE _bookmarks (type INTEGER, fk INTEGER DEFAULT NULL, parent INTEGER, title LONGVARCHAR);" 34 | set tableB to "CREATE TABLE _places (id INTEGER PRIMARY KEY, url LONGVARCHAR);" 35 | do shell script start & tableA & tableB & quote 36 | 37 | -- Copy data from PlacesDB.sqlite to BookmarksDB.sqlite 38 | set sourceDB to space & workingDir & "PlacesDB.sqlite" & space 39 | set begin to "sqlite3" & sourceDB & quote 40 | set destinationDB to workingDir & "BookmarksDB.sqlite" 41 | 42 | set addDB to "ATTACH DATABASE '" & destinationDB & "' AS new;" 43 | set copyA to "INSERT INTO new._bookmarks SELECT type,fk,parent,title FROM moz_bookmarks;" 44 | set copyB to "INSERT INTO new._places SELECT id,url FROM moz_places;" 45 | set remDB to "DETACH new;" 46 | do shell script begin & addDB & copyA & copyB & remDB & quote 47 | 48 | -- Sanitize data in BookmarksDB.sqlite 49 | set destinationDB to space & workingDir & "BookmarksDB.sqlite" & space 50 | set start to "sqlite3" & destinationDB & quote 51 | 52 | set join to "CREATE TABLE bookmarks AS SELECT * FROM _bookmarks LEFT OUTER JOIN _places ON _bookmarks.fk = _places.id;" 53 | set dropA to "DROP TABLE _bookmarks;" 54 | set dropB to "DROP TABLE _places;" 55 | set final to "CREATE TABLE data AS SELECT type,parent,title,url FROM bookmarks;" 56 | set dropC to "DROP TABLE bookmarks;" 57 | do shell script start & join & dropA & dropB & final & dropC & quote 58 | 59 | -- Cleanup rule 60 | do shell script "cd " & workingDir & "; rm *.sqlite-*" 61 | 62 | end run -------------------------------------------------------------------------------- /backup_bookmarks/README.md: -------------------------------------------------------------------------------- 1 | ##Extract your bookmarks from Firefox 2 | 3 | The script allows you to backup your Firefox bookmarks to a separate database file (.sqlite format) 4 | 5 | > Script tested on **OSX 10.8.4** and **Firefox version 22.0** 6 | 7 | 8 | ###GetBookmarks script 9 | 10 | `GetBookmarks.scpt` consists of a couple of actions: 11 | 12 | * Copies the `places.sqlite` file from your Firefox profile directory and renames it as `PlacesDB.sqlite` 13 | * Creates a new database called `BookmarksDB.sqlite`, including a simplified table structure 14 | * Extracts relevant content from `PlacesDB.sqlite` and injects it in `BookmarksDB.sqlite` 15 | * Executes a sanitization process 16 | 17 | ###Running the script 18 | 19 | First create a new directory called **/Temp** in your home folder and copy the `GetBookmarks.scpt` file to the new directory. Next open the script with Applescript Editor and replace`` with your own _(see remark in the **Additional info** section)_. Finally execute the script. _(takes a couple fo seconds to complete)_ 20 | 21 | > **Important:** In order to execute this script, make sure /Applications/Firefox.app is not running 22 | 23 | After execution of the script, you'll end up with two files `PlacesDB.sqlite` and `BookmarksDB.sqlite` in your **/Temp** directory. An easy way to consult the contents of the produced .sqlite files is using a Firefox add-on called [SQLite Manager](https://code.google.com/p/sqlite-manager) (_currently version 0.8.0_) 24 | 25 | ####Additonal info 26 | * Path to **places.sqlite** file: `~/Library/Application Support/Firefox/Profiles/` 27 | * The repository also contains [GetBookmarks.pdf](https://github.com/nrollr/applescript/tree/master/backup_bookmarks/GetBookmarks.pdf) which is a visual representation of all manipulations within the script. 28 | -------------------------------------------------------------------------------- /backup_messages/GetMessages.applescript: -------------------------------------------------------------------------------- 1 | -- GetMessages.applescript combines all individual scipts listed in the actions directory 2 | 3 | -- From AppleScript ExtractDB 4 | -- Step {1}: Define variables 5 | display dialog "Enter the UDID of your iPhone" default answer "" 6 | set BackupFolder to text returned of result 7 | property dbName : "3d0d7e5fb2ce288813306e4d4636395e047a3d28" 8 | 9 | -- Step {2}: Directory and File name definitions 10 | set DefaultFolder to ((path to home folder) as text) & "Library:Application Support:MobileSync:Backup" 11 | set BackupFile to DefaultFolder & ":" & BackupFolder & ":" & dbName 12 | set TempFolder to ((path to home folder) as text) & "Temp" 13 | 14 | -- Step {3}: Copy the Messages database to your Home directory and rename 15 | tell application "Finder" 16 | copy file BackupFile to folder TempFolder 17 | set dbCopy to TempFolder & ":" & dbName 18 | set dbFile to "MessagesDB.sqlite" 19 | set name of file dbCopy to dbFile 20 | end tell 21 | 22 | -- From AppleScript CreateDB 23 | -- Place this script in the same directory as the MessagesDB file 24 | tell application "Finder" to get folder of (path to me) as Unicode text 25 | set workingDir to POSIX path of result 26 | 27 | -- Step {4}: Create a new database called NewDB.sqlite and add table structure 28 | set targetDB to space & workingDir & "NewDB.sqlite" & space 29 | set start to "sqlite3" & targetDB & quote 30 | 31 | -- Step {5}: Add table structure in NewDB.sqlite 32 | set messagesTbl to "BEGIN TRANSACTION; CREATE TABLE messages (identifier INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE, handle_id INTEGER DEFAULT 0, service TEXT, date INTEGER, from_me INTEGER DEFAULT 0, text TEXT); COMMIT;" 33 | do shell script start & messagesTbl & quote 34 | set handleTbl to "BEGIN TRANSACTION; CREATE TABLE contacts (handle INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE, contact TEXT NOT NULL); COMMIT;" 35 | do shell script start & handleTbl & quote 36 | 37 | -- From AppleScript InsertData 38 | -- Step{6}: Copy relevant fields from MessagesDB.sqlite to NewDB.sqlite 39 | set workingDB to space & workingDir & "MessagesDB.sqlite" & space 40 | set begin to "sqlite3" & workingDB & quote 41 | set targetDB to workingDir & "NewDB.sqlite" 42 | set loadCmd to "ATTACH DATABASE '" & targetDB & "' AS target;" 43 | -- Copy contents of messages table 44 | set copyMessages to "INSERT INTO target.messages SELECT ROWID,handle_id,service,date,is_from_me,text FROM main.message ORDER BY date ASC;" 45 | do shell script begin & loadCmd & copyMessages & quote 46 | -- Copy contents of contacts table 47 | set copyContacts to "INSERT INTO target.contacts SELECT ROWID,id FROM main.handle;" 48 | do shell script begin & loadCmd & copyContacts & quote 49 | 50 | -- Cleanup rule 51 | do shell script "cd " & workingDir & "; rm *.sqlite-*" 52 | 53 | -- From AppleScript ImportDB 54 | -- Step{7}: Create a dump of NewDB.sqlite 55 | do shell script "cd " & workingDir & "; sqlite3 NewDB.sqlite .dump > sqlite_dump.sql" 56 | 57 | -- Step{8}: Convert SQLite to MySQL using ConvertDB.py 58 | -- Make sure the Python script ConvertDB.py exists in /Users/{username}/Temp 59 | do shell script "cd " & workingDir & "; cat sqlite_dump.sql | python ConvertDB.py > mysql_dump.sql" 60 | 61 | -- Step{9}: Import mysql_dump.sql into MySQL 62 | -- Make sure the "Messages" database exists and change -ppassword to your own 63 | -- Depending on your MySQL configuration, check and change the path to mysql if necessary 64 | do shell script "/usr/local/Cellar/mysql/5.6.27/bin/mysql -u root -ppassword Messages < " & workingDir & "mysql_dump.sql" 65 | -------------------------------------------------------------------------------- /backup_messages/README.md: -------------------------------------------------------------------------------- 1 | ##Extract your text messages from your iPhone backup 2 | 3 | This script retrieves your text messages from your iPhone backup directory and copies the relevant content to a brand new database file (.sqlite format) 4 | 5 | > Script tested on **OSX 10.10.1**, **iTunes version 12.3.1.23**, with a backup of an iPhone 6S running **iOS 9.1** 6 | 7 | 8 | ###GetMessages script 9 | 10 | `GetMessages.applescript` consolidates four individual actions/scripts located in the [actions](https://github.com/nrollr/applescript/tree/master/backup_messages/actions) directory: 11 | 12 | * **ExtractDB**.applescript : extracts the sqlite file from your iPhone backup and stores it as `MessagesDB.sqlite` 13 | * **CreateDB**.applescript : creates a clean sqlite file called `NewDB.sqlite` and populates the database with table a structure optimized for iOS9 content 14 | * **InsertData**.applescript : only extracts relevant content from `MessagesDB.sqlite` and injects it in `NewDB.sqlite` 15 | * **ImportDB**.applescript : converts and imports the .sqlite DB in to a MySQL server 16 | 17 | ###Running the script 18 | 19 | First create a new directory called **/Temp** in your home folder and copy the `GetMessages`script into the new directory. Next open Applescript Editor and run it. 20 | 21 | When you run the `GetMessages`script, you will be prompted to enter your UDID 22 | > If you don't know your UDID, open iTunes, connect your iPhone, on the **Summary** page click on **Serial Number** and you'll notice it switches to **Identifier (UDID)** automatically. Next right click the UDID number and select **Copy Identifier (UDID)** and paste in the prompt of the `GetMessages`script. 23 | 24 | After executing the script, you'll end up with two .sqlite files in your directory. An easy way to consult the contents of the produced `NewDB.sqlite`-file is using a Firefox add-on called [SQLite Manager](https://code.google.com/p/sqlite-manager) - *currently version 0.8.3.1* 25 | 26 | ####Additonal info 27 | * Path to backup file: `/Users/username/Library/Application Support/MobileSync/Backup/` 28 | * File containing text messages: `3d0d7e5fb2ce288813306e4d4636395e047a3d28` 29 | * Text messages are stored in the `messages` table. Required columns are _ROWID; text; handle_id; service; date; is_from_me_ 30 | -------------------------------------------------------------------------------- /backup_messages/actions/ConvertDB.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | 3 | import sys 4 | 5 | def main(): 6 | print "SET sql_mode='NO_BACKSLASH_ESCAPES';" 7 | lines = sys.stdin.read().splitlines() 8 | for line in lines: 9 | processLine(line) 10 | 11 | def processLine(line): 12 | if ( 13 | line.startswith("PRAGMA") or 14 | line.startswith("BEGIN TRANSACTION;") or 15 | line.startswith("COMMIT;") or 16 | line.startswith("DELETE FROM sqlite_sequence;") or 17 | line.startswith("INSERT INTO \"sqlite_sequence\"") 18 | ): 19 | return 20 | line = line.replace("AUTOINCREMENT", "AUTO_INCREMENT") 21 | line = line.replace("DEFAULT 't'", "DEFAULT '1'") 22 | line = line.replace("DEFAULT 'f'", "DEFAULT '0'") 23 | line = line.replace(",'t'", ",'1'") 24 | line = line.replace(",'f'", ",'0'") 25 | in_string = False 26 | newLine = '' 27 | for c in line: 28 | if not in_string: 29 | if c == "'": 30 | in_string = True 31 | elif c == '"': 32 | newLine = newLine + '`' 33 | continue 34 | elif c == "'": 35 | in_string = False 36 | newLine = newLine + c 37 | print newLine 38 | 39 | if __name__ == "__main__": 40 | main() 41 | -------------------------------------------------------------------------------- /backup_messages/actions/CreateDB.applescript: -------------------------------------------------------------------------------- 1 | -- Save this script to /Users/{username}/Temp 2 | tell application "Finder" to get folder of (path to me) as Unicode text 3 | set workingDir to POSIX path of result 4 | 5 | -- Create a new database called NewDB.sqlite and add table structure 6 | set targetDB to space & workingDir & "NewDB.sqlite" & space 7 | set start to "sqlite3" & targetDB & quote 8 | 9 | -- Add table structure in NewDB.sqlite 10 | set messagesTbl to "BEGIN TRANSACTION; CREATE TABLE messages (identifier INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE, handle_id INTEGER DEFAULT 0, service TEXT, date INTEGER, from_me INTEGER DEFAULT 0, text TEXT); COMMIT;" 11 | do shell script start & messagesTbl & quote 12 | set handleTbl to "BEGIN TRANSACTION; CREATE TABLE contacts (handle INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE, contact TEXT NOT NULL); COMMIT;" 13 | do shell script start & handleTbl & quote -------------------------------------------------------------------------------- /backup_messages/actions/ExtractDB.applescript: -------------------------------------------------------------------------------- 1 | -- Define variables 2 | display dialog "Enter the UDID of your iPhone" default answer "" 3 | set BackupFolder to text returned of result 4 | property dbName : "3d0d7e5fb2ce288813306e4d4636395e047a3d28" 5 | 6 | -- Directory and File name definitions 7 | set DefaultFolder to ((path to home folder) as text) & "Library:Application Support:MobileSync:Backup" 8 | set BackupFile to DefaultFolder & ":" & BackupFolder & ":" & dbName 9 | set TempFolder to ((path to home folder) as text) & "Temp" 10 | 11 | -- Copy the database file and rename to MessagesDB.sqlite 12 | tell application "Finder" 13 | copy file BackupFile to folder TempFolder 14 | set dbCopy to TempFolder & ":" & dbName 15 | set dbFile to "MessagesDB.sqlite" 16 | set name of file dbCopy to dbFile 17 | end tell 18 | -------------------------------------------------------------------------------- /backup_messages/actions/ImportDB.applescript: -------------------------------------------------------------------------------- 1 | -- Save this script to /Users/{username}/Temp 2 | tell application "Finder" to get folder of (path to me) as Unicode text 3 | set workingDir to POSIX path of result 4 | 5 | -- Create a dump of NewDB.sqlite 6 | do shell script "cd " & workingDir & "; sqlite3 NewDB.sqlite .dump > sqlite_dump.sql" 7 | 8 | -- Make sure the Python script ConvertDB.py exists in /Users/{username}/Temp 9 | -- Convert SQLite to MySQL using ConvertDB.py 10 | do shell script "cd " & workingDir & "; cat sqlite_dump.sql | python ConvertDB.py > mysql_dump.sql" 11 | 12 | -- Import mysql_dump.sql into MySQL 13 | -- Make sure the "Messages" database exists and change -ppassword to your own 14 | -- Depending on your MySQL configuration, check and change the path to mysql if necessary 15 | do shell script "/usr/local/Cellar/mysql/5.6.27/bin/mysql -u root -ppassword Messages < " & workingDir & "mysql_dump.sql" -------------------------------------------------------------------------------- /backup_messages/actions/InsertData.applescript: -------------------------------------------------------------------------------- 1 | -- Save this script to /Users/{username}/Temp 2 | tell application "Finder" to get folder of (path to me) as Unicode text 3 | set workingDir to POSIX path of result 4 | 5 | -- Copy relevant fields from MessagesDB.sqlite to NewDB.sqlite 6 | set workingDB to space & workingDir & "MessagesDB.sqlite" & space 7 | set begin to "sqlite3" & workingDB & quote 8 | set targetDB to workingDir & "NewDB.sqlite" 9 | set loadCmd to "ATTACH DATABASE '" & targetDB & "' AS target;" 10 | 11 | -- Copy contents to messages table 12 | set copyMessages to "INSERT INTO target.messages SELECT ROWID,handle_id,service,date,is_from_me,text FROM main.message ORDER BY date ASC;" 13 | do shell script begin & loadCmd & copyMessages & quote 14 | 15 | -- Copy contents to contacts table 16 | set copyContacts to "INSERT INTO target.contacts SELECT ROWID,id FROM main.handle;" 17 | do shell script begin & loadCmd & copyContacts & quote 18 | 19 | -- Cleanup rule 20 | do shell script "cd " & workingDir & "; rm *.sqlite-*" -------------------------------------------------------------------------------- /iTunes_to_twitter/README.md: -------------------------------------------------------------------------------- 1 | ##iTunes to Twitter 2 | 3 | This script fetches the name and artist of the song currently playing in iTunes, compose a tweet with these values and sends it to Twitter using two methods (depending on the script you choose) : 4 | 5 | 1. Passing a formatted URL to the browser of your choice. There are custom scripts for [Safari]() and/or [Chrome]() 6 | 2. Using the [Twitter Scripter](http://itunes.apple.com/us/app/twitter-scripter/id645249778?mt=12) an agent that provides simplified access to the Twitter API directly from AppleScript. 7 | 8 | 9 | ###How it works 10 | 11 | First we fetch the **name** and the **artist** value from iTunes, which are used to compose the tweet in a format: "#NowPlaying : ♫ _`trackName` - `trackArtist`_ ♫ " 12 | 13 | If you choose to post it to Twitter using a browser the tweet is appended to an URL `http://twitter.com/intent/tweet?text=` and then passed on to your browser of choice (which still requires you to sign in and hit the tweet button manually). Or you may use the Twitter Scripter agent to post it directly to Twitter, with no further user interaction required. 14 | 15 | ####Formatted URL for browsers 16 | 17 | * `Tweet via Safari.applescript` for Safari 18 | * `Tweet via Chrome.applescript` for Google Chrome 19 | 20 | The compiled versions can be found in the [scpt files](https://github.com/nrollr/applescript/tree/master/iTunes_to_twitter/scpt%20files) directory 21 | 22 | 23 | ####Using the Twitter Scripter 24 | 25 | * `Tweet via Twitter Scripter.applescript` - Do not forget to adapt the `"your_twitter_useraccount"` field in the script to your own 26 | 27 | > **Important notice**: After installing the Twitter Scripter agent, there is some configuration required. For more information and script examples go to [mousedown.net](http://mousedown.net/mouseware/TwitterScripter_Examples.html) 28 | 29 | > 1. You will need at least one Twitter account in the "Mail, Contacts & Calendars" System preference in 10.8 (or "Internet Accounts" in 10.9) 30 | > 31 | > 2. You will need to give Twitter Scripter permission to access Twitter via the "Security & Privacy" System preference, Privacy tab. 32 | 33 | 34 | 35 | 36 | ###Additonal info 37 | * Script tested on **OSX 10.9** and **iTunes version 11.1.1** 38 | * All compiled scripts can be found in the [scpt files](https://github.com/nrollr/applescript/tree/master/iTunes_to_twitter/scpt%20files) directory 39 | * [Twitter Scripter](http://itunes.apple.com/us/app/twitter-scripter/id645249778?mt=12) is free agent and can be downloaded from the Mac Apple Store. 40 | 41 | 42 | 43 | > You will notice there is a script for Firefox as well, though currently there is an issue, as the Unicode character U+266B in the composed tweet are is passed on correctly to the Firefox address field. -------------------------------------------------------------------------------- /iTunes_to_twitter/Tweet via Chrome.applescript: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nrollr/Applescript/ae421493e080fe06da741da62b4ac542e0e15792/iTunes_to_twitter/Tweet via Chrome.applescript -------------------------------------------------------------------------------- /iTunes_to_twitter/Tweet via Firefox.applescript: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nrollr/Applescript/ae421493e080fe06da741da62b4ac542e0e15792/iTunes_to_twitter/Tweet via Firefox.applescript -------------------------------------------------------------------------------- /iTunes_to_twitter/Tweet via Safari.applescript: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nrollr/Applescript/ae421493e080fe06da741da62b4ac542e0e15792/iTunes_to_twitter/Tweet via Safari.applescript -------------------------------------------------------------------------------- /iTunes_to_twitter/Tweet via Twitter Scripter.applescript: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nrollr/Applescript/ae421493e080fe06da741da62b4ac542e0e15792/iTunes_to_twitter/Tweet via Twitter Scripter.applescript -------------------------------------------------------------------------------- /iTunes_to_twitter/scpt files/Tweet via Chrome.scpt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nrollr/Applescript/ae421493e080fe06da741da62b4ac542e0e15792/iTunes_to_twitter/scpt files/Tweet via Chrome.scpt -------------------------------------------------------------------------------- /iTunes_to_twitter/scpt files/Tweet via Firefox.scpt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nrollr/Applescript/ae421493e080fe06da741da62b4ac542e0e15792/iTunes_to_twitter/scpt files/Tweet via Firefox.scpt -------------------------------------------------------------------------------- /iTunes_to_twitter/scpt files/Tweet via Safari.scpt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nrollr/Applescript/ae421493e080fe06da741da62b4ac542e0e15792/iTunes_to_twitter/scpt files/Tweet via Safari.scpt -------------------------------------------------------------------------------- /iTunes_to_twitter/scpt files/Tweet via Twitter Scripter.scpt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nrollr/Applescript/ae421493e080fe06da741da62b4ac542e0e15792/iTunes_to_twitter/scpt files/Tweet via Twitter Scripter.scpt -------------------------------------------------------------------------------- /shorten_URL/Goo.gl URL Shortener/Goo.gl URL Shortener.applescript: -------------------------------------------------------------------------------- 1 | -- Use the Goo.gl URL Shortener service to shorten your URLs 2 | display dialog "Enter a long URL" default answer "" 3 | 4 | set longURL to text returned of result 5 | set shortURL to do shell script "curl -s https://www.googleapis.com/urlshortener/v1/url?key={YOUR_API_KEY} -H 'Content-Type: application/json' -d \"{\\\"longUrl\\\": \\\"" & longURL & "\\\"}\" | awk '/\"id\":/{print substr($2, 2, length($2)-3)}'" 6 | 7 | set the clipboard to shortURL as text 8 | -- Alternative: display dialog shortURL 9 | 10 | display notification "Short URL copied to clipboard" -------------------------------------------------------------------------------- /shorten_URL/Goo.gl URL Shortener/README.md: -------------------------------------------------------------------------------- 1 | ## Disclaimer 2 | 3 | On 30 March 2018, Google [announced](https://developers.googleblog.com/2018/03/transitioning-google-url-shortener.html) it will retire its goo.gl URL shortening service in favor of [Firebase Dynamic Links (FDL)](https://firebase.google.com/products/dynamic-links/). In a nutshell: 4 | 5 | * You won't be able to create new goo.gl short links after April 13th, 2018 6 | * Existing short links will continue to work, but you won't be able to access the console after March 30th, 2019 7 | 8 | 9 | ## Shorten URL's with Goo.gl 10 | 11 | A simple AppleScript requesting any type of URL as input and returns a shortened `goo.gl` URL. The short URL is directly copied to the clipboard, when completed the user receives an additional notification via the OSX notification center. 12 | 13 | #### Goo.gl 14 | 15 | If you are not familiar with the Google URL Shortener service, here is an example: 16 | `https://developers.google.com/url-shortener/v1` is shortened to [goo.gl/ll5bAa](http://goo.gl/ll5bAa) 17 | 18 | For more information about the Google URL Shortener API, please read the API documentation on [developers.google.com](https://developers.google.com/url-shortener/v1/getting_started). Also note: the use of a (personal) API key or auth token is highly recommended according to the documentation: 19 | > _"Requests to the Google URL Shortener API for public data must be accompanied by an identifier, which can be an API key or an auth token."_ 20 | 21 | The section _"**Acquiring and using an API key**"_ will guide your through this process. 22 | 23 | 24 | #### How it works 25 | 26 | As the prompted dialog box requests: _"Enter a long URL"_ and click OK. In the background a shell script requests the **Goo.gl** service to return the shortened version. 27 | The shortened URL returned by the **Goo.gl** service and copied to the clipboard. The enduser is informed about this via a notification, using the OSX notification center. (see [screenshot](http://cl.ly/VBKl) of the notification) 28 | 29 | **Note #1:** Since the API documentation recommends to include an identifier, make sure to modify the script to reflect your own personal API key: 30 | > In `https://www.googleapis.com/urlshortener/v1/url?key={YOUR_API_KEY}` 31 | where `YOUR_API_KEY` should be replaced with your actual personal API key provided by Google. 32 | 33 | **Note #2:** the use and integration of the Applescript with OSX notification center is only valid if you are running the script in the latest version of OSX, Mavericks. If you plan on using the script in earlier versions of OSX, you need to remove or change the last line in the script `display notification` 34 | 35 | The compiled version can be found in the [scpt file](https://github.com/nrollr/applescript/tree/master/shorten_URL/Goo.gl%20URL%20Shortener/scpt%20file) directory 36 | 37 | 38 | 39 | #### Additonal info 40 | Script was tested on **OSX 10.9.2** and **AppleScript 2.3.1** 41 | 42 | > More about the AppleScript `"display notification"` command can be found in: 43 | > 44 | * An article posted on the [Mac OS X Automation](http://macosxautomation.com/mavericks/notifications/01.html) website 45 | * The official [AppleScript Language Guide](https://developer.apple.com/library/mac/documentation/applescript/conceptual/applescriptlangguide/AppleScriptLanguageGuide.pdf) (.pdf file) 46 | -------------------------------------------------------------------------------- /shorten_URL/Goo.gl URL Shortener/scpt file/Goo.gl URL Shortener.scpt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nrollr/Applescript/ae421493e080fe06da741da62b4ac542e0e15792/shorten_URL/Goo.gl URL Shortener/scpt file/Goo.gl URL Shortener.scpt -------------------------------------------------------------------------------- /shorten_URL/Shorten Github URL/README.md: -------------------------------------------------------------------------------- 1 | ##Shorten GitHub URL's 2 | 3 | A simple AppleScript requesting a [GitHub](https://github.com) URL as input and returns the shortened `git.io` URL. The short URL is directly copied to the clipboard, when completed the user receives an additional notification via the OSX notification center. 4 | 5 | ###Git.io 6 | 7 | If you are not familiar with the **Git.io** URL shortening service, here are some examples: 8 | 9 | `https://github.com/philipwalton/solved-by-flexbox` is shortened to [git.io/rfNDMw](http://git.io/rfNDMw) 10 | `https://github.com/jordansinger/hook.js/` is shortened to [git.io/NPeLpw](http://git.io/NPeLpw) 11 | 12 | > **Important notice**: the `git.io` URL shortening service **only** works for GitHub URLs and thus serves another purpose as more common URL shortening services out there like [bit.ly](https://bitly.com/) 13 | 14 | 15 | ###How it works 16 | 17 | As the prompted dialog box requests: _"Enter the GitHub URL to shorten"_ and click OK. In the background a shell script requests the **Git.io** service to return the shortened version, like you would do via command line with `curl -i git.io -F "url=your.github.com"`. 18 | The actual shortened URL is extracted from the output returned by the **Git.io** service and copied to the clipboard. The enduser is informed about this via a notification, using the OSX notification center. (see [screenshot](http://cl.ly/T5rA) of the notification) 19 | 20 | **Note:** the use and integration of the Applescript with OSX notification center is only valid if you are running the script in the latest version of OSX, Mavericks. If you plan on using the script in earlier versions of OSX, you need to remove or change the last line in the script `display notification` 21 | 22 | The compiled version can be found in the [scpt file](https://github.com/nrollr/applescript/tree/master/shorten_URL/Shorten%20Github%20URL/scpt%20file) directory 23 | 24 | 25 | 26 | 27 | 28 | ###Additonal info 29 | Script was tested on **OSX 10.9.1** and **AppleScript 2.3** 30 | 31 | > More about the AppleScript `"display notification"` command can be found in: 32 | > 33 | * an article posted on the [Mac OS X Automation](http://macosxautomation.com/mavericks/notifications/01.html) website 34 | * the official [AppleScript Language Guide](https://developer.apple.com/library/mac/documentation/applescript/conceptual/applescriptlangguide/AppleScriptLanguageGuide.pdf) (.pdf file) 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /shorten_URL/Shorten Github URL/Shorten Github URL.applescript: -------------------------------------------------------------------------------- 1 | -- Use the Git.io online service to shorten your GitHub URls 2 | display dialog "Enter the GitHub URL to shorten" default answer "" 3 | 4 | set theURL to text returned of result 5 | set theResult to do shell script "curl -i git.io -F url=" & theURL & " | grep Location |cut -d' ' -f2" 6 | 7 | set the clipboard to theResult as text 8 | -- alternative: display dialog theResult 9 | 10 | display notification "Short URL copied to clipboard" -------------------------------------------------------------------------------- /shorten_URL/Shorten Github URL/scpt file/Shorten Github URL.scpt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nrollr/Applescript/ae421493e080fe06da741da62b4ac542e0e15792/shorten_URL/Shorten Github URL/scpt file/Shorten Github URL.scpt --------------------------------------------------------------------------------