Tweet using Opera's address bar
Thursday, September 18, 2008 8:31:19 AM
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/







José Torreszetorres # Thursday, September 18, 2008 8:32:28 AM
DesertDawg # Thursday, September 18, 2008 8:47:08 AM
Steve DavisSteveD # Thursday, September 18, 2008 9:10:50 AM
not working for me. just takes me to my twitter profile. i'll double check.
Tamil # Thursday, September 18, 2008 9:51:47 AM
David Håsätherhzr # Thursday, September 18, 2008 10:27:22 AM
Or if you want a widget (shameless plug): http://widgets.opera.com/widget/7206/ (soon to be updated
Miladin MiladinoskiEagleMKD # Thursday, September 18, 2008 10:46:15 AM
Espen André ØverdahlEspenAO # Thursday, September 18, 2008 10:49:13 AM
Yeni Setiawansandalian # Thursday, September 18, 2008 11:18:12 AM
Rijk # Thursday, September 18, 2008 11:21:34 AM
Dustin WilsonKhadgar # Thursday, September 18, 2008 12:45:59 PM
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.MyOpera team, please fix this!fearphage # Thursday, September 18, 2008 1:17:42 PM
Alexodius PrimeAleksOD # Thursday, September 18, 2008 1:44:34 PM
Alexei Morozovmorav # Thursday, September 18, 2008 1:56:55 PM
FierceDeity # Thursday, September 18, 2008 2:08:51 PM
tbret # Thursday, September 18, 2008 3:40:34 PM
Mauriciomrmxo # Thursday, September 18, 2008 4:43:57 PM
thobi # Thursday, September 18, 2008 4:48:17 PM
nevertheless
Mağruf ÇolakoğluZAHEK # Thursday, September 18, 2008 6:49:09 PM
KarenNerak # Thursday, September 18, 2008 8:01:01 PM
Pattty # Thursday, September 18, 2008 8:03:51 PM
Okra # Thursday, September 18, 2008 9:24:45 PM
yeeliberto # Thursday, September 18, 2008 10:07:58 PM
Daniel Sitnikdanielcs # Friday, September 19, 2008 1:43:45 AM
Congrats!!
OscarWeibin # Friday, September 19, 2008 7:08:19 AM
AyushAyushJ # Friday, September 19, 2008 9:40:41 AM
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.)
Dustin WilsonKhadgar # Friday, September 19, 2008 2:10:17 PM
*goes off to make some more changes*
Pattty # Friday, September 19, 2008 4:38:05 PM
I prefer Khadgar method
.edDotEd # Friday, September 19, 2008 5:07:49 PM
AyushAyushJ # Friday, September 19, 2008 6:36:42 PM
Originally posted by Pattty:
Oh..
JimJimLou # Friday, September 19, 2008 10:15:29 PM
Soumitrasoumitram4u # Sunday, September 21, 2008 5:42:34 PM
AliAli09139279902 # Sunday, September 21, 2008 6:25:25 PM
deadcantdance # Monday, September 22, 2008 5:47:14 AM
Denis Edward Chesneyflotsam22 # Tuesday, September 23, 2008 6:56:39 AM
Tobbi # Wednesday, September 24, 2008 6:45:56 PM
Do anybody know a solution?
Greets
Tobbi
edit:
@AyushJ,
your first JS works fine for me. Thx
Pramod Ghugegeeneeyes # Friday, September 26, 2008 10:14:21 PM
I thought this is way simpler and much easier imho.
Is there any difference at all?
KaiThaiger # Friday, September 26, 2008 10:33:05 PM
Uriri, Chukwudi I.Ochidi # Tuesday, September 30, 2008 5:56:04 AM
EDWINrama12 # Thursday, October 2, 2008 7:10:02 AM
THATS UGLY.I SHOULD SUE THAT OWNER
Pattty # Thursday, October 2, 2008 5:49:03 PM
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
Leonp.vmynoel # Monday, October 6, 2008 6:04:22 AM
EDWINrama12 # Tuesday, October 7, 2008 9:20:12 AM
THATS CRAP
corny # Thursday, October 9, 2008 12:27:51 PM
JTornado # Friday, October 10, 2008 1:36:13 AM
BabsiPrivileg # Friday, October 24, 2008 7:25:29 AM
papasmurfrock # Saturday, January 3, 2009 4:22:29 AM
Péter Mihálypetermi # Wednesday, January 28, 2009 12:22:04 AM