Sign up | Lost password? | Help

My Opera news » Tweet using Opera's address bar

Tweet using Opera's address bar

Tweeting using Opera's address bar

Dustin Wilson (also known as "Khadgar") always enjoys a challenge. His latest project was to get Opera's custom search feature work with the update form on Twitter, so he could do all his Tweeter updates using the address bar. Well, that would work as long as there's an active auth session, so it's not usable unless you've already logged in.

After many hours trying out different solutions how to send data, he falled back on using a data URI (please read his own excellent blog post if you want all the juice). It's somewhat long and messy, but it does the trick:

data:text/html,%3C%21DOCTYPE%20html%3E%3Chtml%20lang%3D%22en%22%3E%3Chead%3E%3Cmeta%20charset%3D%22UTF-8%22%3E%3Ctitle%3ETweet%3C%2Ftitle%3E%3Cstyle%20type%3D%22text%2Fcss%22%3Eobject%7Bvisibility%3Ahidden%3B%7D%3C%2Fstyle%3E%3C%2Fhead%3E%3Cbody%3E%3Cscript%20type%3D%22text%2Fjavascript%22%3Efunction%20enc%28text%29%7Breturn%20encodeURI%28text%29.replace%28%2F%5C%2B%2Fg%2C%27%2520%27%29%3B%7D%20var%20tweet%3Denc%28%27%s%27%29%3Bvar%20username%3Denc%28%27opera%27%29%3Bvar%20password%3Denc%28%27software%27%29%3Bdocument.write%28%27%3Cobject%20data%3D%22data%3Atext%2Fhtml%2C%253C%2521DOCTYPE%2520html%253E%253Chtml%2520lang%253D%2522en%2522%253E%253Chead%253E%253Cmeta%2520charset%253D%2522UTF-8%2522%253E%253Ctitle%253ETweet%2521%2520Tweet%2521%253C%252Ftitle%253E%253C%252Fhead%253E%253Cbody%253E%253Cform%2520method%253D%2522POST%2522%2520action%253D%2522http%253A%252F%252F%27%2Busername%2B%27%253A%27%2Bpassword%2B%27%2540twitter.com%252Fstatuses%252Fupdate.xml%2522%2520name%253D%2522tweet%2522%253E%253Ctextarea%2520name%253D%2522status%2522%253E%27%2Btweet%2B%27%253C%252Ftextarea%253E%253Cinput%2520type%253D%2522submit%2522%253E%253C%252Fform%253E%253Cscript%2520type%253D%2522text%252Fjavascript%2522%253Edocument.tweet.submit%2528%2529%253B%253C%252Fscript%253E%253C%252Fbody%253E%253C%252Fhtml%253E%22%3E%3C%2Fobject%3E%27%29%3B%20window.location%3D%27http%3A%2F%2Ftwitter.com%2F%27%2Busername%3B%3C%2Fscript%3E%3C%2Fbody%3E%3C%2Fhtml%3E

To use it follow these directions:

  1. Copy the long data URI into a text editor and do a text replacement for "opera" then replace it with your twitter username.
  2. Do a text replacement for "software" and replace it with your password.
  3. Go to Tools → Preferences (or Opera → Preferences on Mac OS X).
  4. Click on the Search tab then click the Add… button.
  5. In the input box labeled Name type in Twitter.
  6. Type in a suitable keyword in the Keyword field. For example tw.
  7. Paste in the data URI from your text editor into the Address field and click OK.

Now you should be able to type tw Tweet! and update your status on Twitter with "Tweet!". As this is just a proof-of-concept it can be expanded to do more such as display an error if you’ve typed in more than 140 characters among other things. We're super happy Dustin thought he'd challenge himself to see if it could be done. :cool:

Imagery from Dustin Wilson's Web site: http://dustinwilson.com/

Comments

zetorres 18. September 2008, 08:32

:up:

VanessaMk 18. September 2008, 08:38

Thanks a lot. :smile:

DesertDawg 18. September 2008, 08:47

...he fell back to ...

SteveD 18. September 2008, 09:10

whoa. nice job dustin!

not working for me. just takes me to my twitter profile. i'll double check.

Tamil 18. September 2008, 09:51

:up:

hzr 18. September 2008, 10:27

Here is a similar solution: http://my.opera.com/edvakf/blog/2008/07/24/update-twitter-status-from-opera-address-bar (I know p01 have done the same in the past too).

Or if you want a widget (shameless plug): http://widgets.opera.com/widget/7206/ (soon to be updated :smile:)

EagleMKD 18. September 2008, 10:46

Woot thanks! I'll try it now!

EspenAO 18. September 2008, 10:49

hzr: Thanks for sharing those links! I also like edvakf's approach to it. :smile:

sandalian 18. September 2008, 11:18

Excelent! :up:

Rijk 18. September 2008, 11:21

I want Khadgar's solution with the 'from OperaAddressBar' source attribute from edvakf :smile:

Khadgar 18. September 2008, 12:45

Thanks guys. Haha. Surprised to find this here! This method does use the API like edvakf. The data URI (along with the other stuff that's described in my log post) is used instead of defaulting to mobile twitter (or using an external webapp like many other methods) to get rid of the XML output. Now if Opera's blank document and Speed Dial were markup then a javascript URI could be used, making it appear less ugly (and be much easier to modify).

@SteveD: If your profile page has already been cached it won't show the tweet. Refreshing should display it. Like I said it could use some refinement. Haha.

@Rijk: Yeah I'd like to do that myself, but adding the source argument doesn't appear to add it. I'd probably have to call it something else and submit it through their form, but I'd like to find out how edvakf submitted his as the form requires a URI.

fearphage 18. September 2008, 13:17

We should consolidate into a single group and then change the source to be the same for all the "clients". Just a thought. my.opera.com/twitter (which i conveniently just registered). If anyone is interested I would be more than happy to turn over control of it to you.... free of charge :wink:

AleksOD 18. September 2008, 13:44

Amazing! Thank you for your efforts, Khadgar! :up:

morav 18. September 2008, 13:56

Cool, i like twitter => http://www.twitter.com/morav :D

FierceDeity 18. September 2008, 14:08

this is PERFECT! just what i was looking for. genious!

tbret 18. September 2008, 15:40

very clever:idea:!

mrmxo 18. September 2008, 16:43

exelent!!is very good!

thobi 18. September 2008, 16:48

tweet? twitter? :confused:
nevertheless :up: :wink:

ZAHEK 18. September 2008, 18:49

good job.thanks.

Nerak 18. September 2008, 20:01

That's flippin' sweet! :yes:

Pattty 18. September 2008, 20:03

Wow! :up: I have to try it!

Okra 18. September 2008, 21:24

I wonder if it would be possible to have it ask for username and password the first time and store it in cookies?

yeeliberto 18. September 2008, 22:07

Very nice approach, it should be included in the next Opera version.

danielcs 19. September 2008, 01:43

I'm not a Tweeter user but this is just great Dustin.
Congrats!! :hat:

Weibin 19. September 2008, 07:08

:smile: nice work :up:

AyushJ 19. September 2008, 09:40

btw, here is a pure javascript address (use in prefs>search like the data uri):
javascript:(function(u,p){var d=document,t,i,f=d.createElement('form');f.method='post';f.action='http://'+u+':'+p+'@twitter.com/statuses/update.xml';t=f.appendChild(d.createElement('textarea'));t.name='status';t.value='%s'.replace(/\+/g,' ');i=d.createElement('iframe');f.target=i.name='tweet_target';i.setAttribute('style','visibility:hidden;position:absolute;width:0;height:0;border:0');(document.body||document.documentElement).appendChild(i);i.onload=i.onerror=function(e){window.status=e.type=='load'?'Status Updated!':'Error updating status!';e.target.parentNode.removeChild(e.target)};f.submit();window.status='Updating status....'})('USERNAME','PASSWORD')
(replace USERNAME and PASSWORD at the end...)

OR

javascript:(function(u,p){var d=document,t,i,f=d.createElement('form');f.method='post';f.action='http://twitter.com/statuses/update.xml';t=f.appendChild(d.createElement('textarea'));t.name='status';t.value='%s'.replace(/\+/g,' ');i=d.createElement('iframe');f.target=i.name='tweet_target';i.setAttribute('style','visibility:hidden;position:absolute;width:0;height:0;border:0');(document.body||document.documentElement).appendChild(i);i.onload=i.onerror=function(e){window.status=e.type=='load'?'Status Updated!':'Error updating status!';e.target.parentNode.removeChild(e.target)};f.submit();window.status='Updating status....'})()
Opera will show dialog for username/password - enter the login details and optionally check "Remember password" then OK

These don't redirect you to another page - just silently update the status and show "Status Updated!" in status bar after done (and work on any page.. speed dial etc.)

Khadgar 19. September 2008, 14:10

@AyushJ: I think I should club myself in the head for that. I NEVER thought of creating a new document so that it would work on blank documents and Speed Dial. I hate how stuff that that never enters my mind.

*goes off to make some more changes*

Pattty 19. September 2008, 16:38

That last javascript thing didn't work for me :frown: I tried it, but my status was updated with "+" signs between each word... :ko:

I prefer Khadgar method :yes: speacially because it redirects me to twitter's site and I can check the updated status :up:

DotEd 19. September 2008, 17:07

dW, you never cease to delight. I'm glad we're buddies.

AyushJ 19. September 2008, 18:36

Originally posted by Pattty:

That last javascript thing didn't work for me I tried it, but my status was updated with "+" signs between each word...


Oh.. :ko: fixed in the comment above

JimLou 19. September 2008, 22:15

Wicked! Man thats dedication.

soumitram4u 21. September 2008, 17:42

:up:

Ali09139279902 21. September 2008, 18:25

"/tmp/upload/6ce592c90c32364f36ff309681bd8f10ae19b643c1e6b8b65bd51fc078f9c7251/P00457_800X600_9.jpg"

deadcantdance 22. September 2008, 05:47

This is awesome, thx!

flotsam22 23. September 2008, 06:56

Thanks guys. Those were really helpful tips :star: :star: :star:

Tobbi 24. September 2008, 18:45

In my case it doesn't work because i get a security warning?!
Do anybody know a solution?

Greets
Tobbi

edit:
@AyushJ,
your first JS works fine for me. Thx

geeneeyes 26. September 2008, 22:14

http://my.opera.com/community/forums/findpost.pl?id=2190840
I thought this is way simpler and much easier imho.
Is there any difference at all?

Thaiger 26. September 2008, 22:33

Thank you...

Ochidi 30. September 2008, 05:56

For people who do not know anything about this "tweet" thing and are eager to learn. What do we do? WILL SOME ONE PLEASE TELL ME WHAT ITS ABOUT!

rama12 2. October 2008, 07:10

WHAT THE F**K .SORRY GUYS BUT I AINT FEELING THAT SHIT

THATS UGLY.I SHOULD SUE THAT OWNER


Pattty 2. October 2008, 17:49

Originally posted by Ochidi:

WILL SOME ONE PLEASE TELL ME WHAT ITS ABOUT!



Twitter is a social site (or tool) and it's really easy to use. Visit Twitter site at:
www.twitter.com
and you'll find what, why, how, and all info about twitter :up:

mynoel 6. October 2008, 06:04

HELLO GUYS!!! nice :up:

rama12 7. October 2008, 09:20

NAAAAAAAH.IT DOES NT WORK 4 ME.


THATS CRAP

corny 9. October 2008, 12:27

Marvellous work, the original idea has improved so much even in just a week, anyone reck it could be expanded to encompass other/multiple sites?

JTornado 10. October 2008, 01:36

It probably would be hard, but can you do this with Facebook status?

Privileg 24. October 2008, 07:25

This would not work :-(

papasmurfrock 3. January 2009, 04:22

i must be an idiot but i don't see the word "opera" in there anywhere. where is it?

petermi 28. January 2009, 00:22

én is itt vagyok!

Write a comment

You must be logged in to write a comment. If you're not a registered member, please sign up.