Skip to content

Instantly share code, notes, and snippets.

@dce
Created May 3, 2010 03:33
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dce/387715 to your computer and use it in GitHub Desktop.
Save dce/387715 to your computer and use it in GitHub Desktop.
Simple Chrome extension
<html>
<script src="jquery-1.4.2.min.js"></script>
<script>
var bitly = {
login: "your_login",
api_key: "your_api_key"
};
chrome.browserAction.onClicked.addListener(function(tab) {
$.get("http://api.bit.ly/v3/shorten?login=" + bitly.login +
"&apiKey=" + bitly.api_key + "&longUrl=" + tab.url, function(response) {
chrome.tabs.create({ url: "http://twitter.com/home?status=" + response.data.url});
});
});
</script>
</html>
{
"name": "Tweet this page",
"version": "1.0",
"description": "Shorten the current URL and put it a tweet.",
"browser_action": {
"default_icon": "icon.png"
},
"background_page": "background.html",
"permissions": [
"http://api.bit.ly/",
"tabs"
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment