My First Chrome Extension – “Post To Tumblr”

Mummy wow! Im a big boy now! I have just published my first Chrome extension.

It was really annoying me that when I found a funny cat or some other silly image I would have to go through a whole ball-ache process to get that image on my Tumblr account.

What I really wanted was some right-click-post action going on and wondered why no one had one it yet. So with an hour or so to spare I whipped this extension up really quick.

It uses the Chrome 6 Context Menu API so you obviously need to have Chrome 6 to be able to use it.

Currently it only posts images as that’s all I needed for now but if enough people want more then ill whip out the other data types.

The source couldn’t be any simpler really, infact this is it here:

  1. chrome.contextMenus.create({"title": "Post Image To Tumblr", "contexts":["image"], "onclick": postImage});
  2.  
  3. function postImage(info, tab)
  4. {
  5. var email = localStorage["tumblr_email"];
  6. var password = localStorage["tumblr_pass"];
  7.  
  8. if(!email || email=="" || !password || password=="")
  9. {
  10. alert("Need to set your Tumblr username and password in the options before posting!");
  11. }
  12. else
  13. {
  14. var o =
  15. {
  16. "email":email,
  17. "password":password,
  18. "type":"photo",
  19. "source":info.srcUrl
  20. };
  21.  
  22. var success = function(data,textStatus,request)
  23. {
  24. if(textStatus=="success"){ alert("Image posted to Tumblr. Image -> "+info.srcUrl); }
  25. else { alert("Bad email or password"); }
  26. }
  27.  
  28. $.post("http://www.tumblr.com/api/write",o, success);
  29. }
  30. }

Simples!

Theres even an option page where you put in your Tumblr details:

Oh, there is one issue.

No matter what I tried I couldn’t manage to get the Tumblr API to return an error. So if you enter your username or password incorrectly it still reports success, not entirely sure why, if someone knows I would love to hear why!

Interested? You can go grab it over on the chrome extensions gallery page -> HERE

11 Responses to My First Chrome Extension – “Post To Tumblr”
  1. Sergio Reply

    Is there anyway you can make this so it posts to the queue instead?

  2. mikecann Reply

    Im sure it should be possible ill take a look at it laters for you :)

    EDIT: It IS possible, ill do it and upload a new version laters :)

  3. [...] Just a quick update to my first chrome extension. [...]... mikecann.co.uk/personal-project/post-to-tumblr-v0-2
  4. [...] Like Mike Cann, the developer of this extension. Check this extension out, and say thanks to Mike if you... chromestory.com/2010/10/post-to-tumblr-with-a-right-click
  5. gav Reply

    hi thanks for the great app
    how do i post to different blogs on the same account?

  6. thank you Reply

    thank you thank you thank you thank you thank you

  7. Livia Popp Reply

    This is the best Tumblr posting add on there is ^.^

    • Anonymous Reply

      Thanks! Glad you like it:)

  8. noor Reply

    it says "There arent any options! If you would like to see something implemented then
    buy me a beer and tell me all about it:" but i want to put my account info so it can post. what should i do

Leave a Reply

Your email address will not be published. Please enter your name, email and a comment.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>