Tweet using Opera's address bar
Thursday, 18. September 2008, 08:31:19
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:
- Copy the long data URI into a text editor and do a text replacement for "opera" then replace it with your twitter username.
- Do a text replacement for "software" and replace it with your password.
- Go to Tools → Preferences (or Opera → Preferences on Mac OS X).
- Click on the Search tab then click the Add… button.
- In the input box labeled Name type in Twitter.
- Type in a suitable keyword in the Keyword field. For example tw.
- 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. ![]()
Imagery from Dustin Wilson's Web site: http://dustinwilson.com/








zetorres # 18. September 2008, 08:32
VanessaMk # 18. September 2008, 08:38
DesertDawg # 18. September 2008, 08:47
SteveD # 18. September 2008, 09:10
not working for me. just takes me to my twitter profile. i'll double check.
Tamil # 18. September 2008, 09:51
hzr # 18. September 2008, 10:27
Or if you want a widget (shameless plug): http://widgets.opera.com/widget/7206/ (soon to be updated
EagleMKD # 18. September 2008, 10:46
EspenAO # 18. September 2008, 10:49
sandalian # 18. September 2008, 11:18
Rijk # 18. September 2008, 11:21
lilmoder # 18. September 2008, 12:32
Khadgar # 18. September 2008, 12:45
dataURI (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 ajavascriptURI 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
sourceargument 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
AleksOD # 18. September 2008, 13:44
morav # 18. September 2008, 13:56
FierceDeity # 18. September 2008, 14:08
tbret # 18. September 2008, 15:40
mrmxo # 18. September 2008, 16:43
thobi # 18. September 2008, 16:48
nevertheless
ZAHEK # 18. September 2008, 18:49
Nerak # 18. September 2008, 20:01
Pattty # 18. September 2008, 20:03
Okra # 18. September 2008, 21:24
yeeliberto # 18. September 2008, 22:07
danielcs # 19. September 2008, 01:43
Congrats!!
Weibin # 19. September 2008, 07:08
AyushJ # 19. September 2008, 09:40
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 OKThese 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
*goes off to make some more changes*
Pattty # 19. September 2008, 16:38
I prefer Khadgar method
DotEd # 19. September 2008, 17:07
AyushJ # 19. September 2008, 18:36
Originally posted by Pattty:
Oh..
JimLou # 19. September 2008, 22:15
soumitram4u # 21. September 2008, 17:42
Ali09139279902 # 21. September 2008, 18:25
deadcantdance # 22. September 2008, 05:47
flotsam22 # 23. September 2008, 06:56
Tobbi # 24. September 2008, 18:45
Do anybody know a solution?
Greets
Tobbi
edit:
@AyushJ,
your first JS works fine for me. Thx
geeneeyes # 26. September 2008, 22:14
I thought this is way simpler and much easier imho.
Is there any difference at all?
Thaiger # 26. September 2008, 22:33
Ochidi # 30. September 2008, 05:56
rama12 # 2. October 2008, 07:10
THATS UGLY.I SHOULD SUE THAT OWNER
Pattty # 2. October 2008, 17:49
Twitter is a social site (or tool) and it's really easy to use. Visit Twitter site at: and you'll find what, why, how, and all info about twitter
mynoel # 6. October 2008, 06:04
rama12 # 7. October 2008, 09:20
THATS CRAP
corny # 9. October 2008, 12:27
JTornado # 10. October 2008, 01:36
Privileg # 24. October 2008, 07:25
papasmurfrock # 3. January 2009, 04:22
petermi # 28. January 2009, 00:22