-- Textexpander/YOURLS Integration -- -- You can find Textexpander at http://www.smileonmymac.com/TextExpander/ -- You can find YOURLS at http://yourls.org/ -- -- Script based on existing bit.ly script from Textexpander -- Adapted for YOURLS by Chris Marquardt Sep/2009 -- info@chrismarquardt.com -- www.chrismarquardt.com -- -- I did not write this, I only adapted it. The original script is part of the Textexpander -- distribution. I will NOT be able to provide you with any scripting support whatsoever -- -- Instructions to make it work: -- Replace YOURLS-SERVER, YOUR-USERNAME, YOUR-PASSWORD in the script with your respective values. -- Add this as an AppleScript snippet to Textexpander using a shortcut of your choice. -- -- Usage (shorten a URL): -- 1. copy long URL to clipboard -- 2. place cursor where you want to paste the yourls-shortened URL -- 3. type the assigned textexpander shortcut set the ClipURL to (the clipboard as string) ignoring case if ((characters 1 through 4 of ClipURL as string) is not "http") then return "Malformed URL." else set the EncodedClipURL to urlencode(ClipURL) of me set curlCMD to ¬ "curl --stderr /dev/null \"http://YOURLS-SERVER/yourls-api.php?action=shorturl&format=simple&username=YOUR-USERNAME&password=YOUR-PASSWORD&url=" & EncodedClipURL & "\"" -- Run the script and get the result: set tinyURL to (do shell script curlCMD) return tinyURL end if end ignoring on urlencode(theText) set theTextEnc to "" repeat with eachChar in characters of theText set useChar to eachChar set eachCharNum to ASCII number of eachChar if eachCharNum = 32 then set useChar to "+" else if (eachCharNum ≠ 42) and (eachCharNum ≠ 95) and (eachCharNum < 45 or eachCharNum > 46) and (eachCharNum < 48 or eachCharNum > 57) and (eachCharNum < 65 or eachCharNum > 90) and (eachCharNum < 97 or eachCharNum > 122) then set firstDig to round (eachCharNum / 16) rounding down set secondDig to eachCharNum mod 16 if firstDig > 9 then set aNum to firstDig + 55 set firstDig to ASCII character aNum end if if secondDig > 9 then set aNum to secondDig + 55 set secondDig to ASCII character aNum end if set numHex to ("%" & (firstDig as string) & (secondDig as string)) as string set useChar to numHex end if set theTextEnc to theTextEnc & useChar as string end repeat return theTextEnc end urlencode