So, I wanted to be able to tweet items from Google Reader. I know things like twitterfeed exist, but I decided I wanted to be able to tweet items from Reader, or share items into my standard shared items, or both. I found http://userscripts.org/scripts/show/10169 which descibed how to to it using a Greasemonkey script.
However, the script used tiny.url to shorten URLs. I wanted to use bit.ly, so I rewrote the getTinyAndInsert function and added a function.
If you want to use this script, you’ll have to sign up for a bit.ly API key. After you sign up, you should get a bit.ly login and API key. Replace the getTinyAndInsert function in the Greasemonkey script with:
function getTinyAndInsert(event) {
var thelongurl = url;
var bitlyLogin = "BITLY_LOGIN";
var bitlyAPIKey = "BITLY_APIKEY";
var commandurl = "http://api.bit.ly/shorten?version=2.0.1&history=1&longUrl=" + thelongurl + "&longUrl=" + thelongurl + "&login=" + bitlyLogin + "&apiKey=" + bitlyAPIKey
urlinput.value = "making url tiny...";
GM_xmlhttpRequest({
method: 'GET',
url: commandurl,
onload: function(responseDetails) {
if (responseDetails.status == 200) {
var myFoundArray = responseDetails.responseText.match(/http://bit.ly/[a-zA-Z0-9]+/g);
if (myFoundArray != null) {
urlinput.value = myFoundArray[0];
countWord(event);
}
else {
urlinput.value = "error shortening";
alert(responseDetails.responseText);
}
}
}
});
}
Be sure to use your BITLY_LOGIN and BITLY_APIKEY. Save the google_reader_twitter.user.js and reload Google Reader.
The function can probably be improved, but it works for me. YMMV. Good luck.
P.S.
If you use this, please follow me.