Hi. Our company includes a JS share widget in the sidebar of a lot of the articles we publish. Clicking on "Share" opens a list of social media sites. Choosing Twitter pulls the article title and URL in and outputs it to Twitter. The problem becomes when an article has a really long title/URL. The user is forced to manually use bit.ly, or a similar service, to shorten the URL.

I am looking to modify the script so that it takes the URL, sends it to bit.ly & shortens it, and then sends the output to Twitter.

I did a quick search and couldn't find anything. Has anyone seen a script that does something like this? Thanks in advance.