Archive for 三月, 2009

iPhone OS 3.0 beta初体验

iPhone OS 3.0 beta发布后马上下载过来体验了一把,把自己的iPod Touch刷了3.0版firmware,也升级了XCode 3.1.3。这次大版本更新带来了非常多的新特性,iPhone离一台完美的手持设备已经非常非常近了。初步体验下来,3.0版OS的潜力还是要靠app来挖掘,系统的本来面目还没有特别大的区别,众多新特性需要有软件的支持才能用得到。普通用户一上手就能看到的改进主要是spotlight搜索,拷贝粘贴,还有开放的蓝牙(但是默认状态是什么蓝牙服务都没有的)。后台Push,in-app支付,turn-by-turn GPS等等重要特性都要等到众多新版应用出现以后才能体现出强大来。先上几张touch上的截图吧。

Running Greasemonkey scripts on Ubiquity

Mozilla Ubiquity is not only a wonderful command engine and launcher. It can also be used to do stuff what Greasemonkey is good at, manipulating page DOM dynamically, by utilizing the “pageLoad_” function hook. To demonstrate this case I’ve quickly migrated the recently popular Twitter search on Google monkey script onto Ubiquity. You can get the Ubiq version of Twitter+Google search from here.

I retained the original DOM building code, but replaced the Ajax call with a JQuery one along with a couple hacks explained below to get it working from Ubiquity.

First, while Greasemonkey has built-in mechanism for filtering page URLs for selective script invocation, you have to do that on your own with Ubiquity. Look at the first few lines in the Ubiq command for the regex job to filter out Google search addresses.

    var href = doc.location.href;
    var q = (/^https?:\/\/(?:www\.)?google\..*\/.*[&?]q=([^&]*)(?:&|$)/(href)||0)[1];

Secondly, before publishing the script, you have to put such a line of comment in the script in order for Ubiquity to consider it an installable command and trigger the install bar at the top of the page. (Kudos to satyr for pointing out this hack)

//function cmd_

In similar ways, most of the Greasemonkey scripts can be migrated to Ubiquity.

twtplus – The missing Twitter command for Ubiquity and Firefox

Earlier this year I spent some time to write the “twtplus” command for Ubiquity, the intriguing Quicksilver-like plugin for Firefox. I’ve been tweaking it intermittently and now I’m gonna put together a little handy reference for it. Twtplus has the following features:

  • Post message to your twitter account (of course)
  • Preview your friends timeline. Click avatar to reply.
  • @ and d message to friends with friends username autocompletion. Notice that “@” is a modifier keyword so you need to leave a space after it to get the friend name autocompletion working.
  • Use “#url” tag to substitute the URL of the currently viewing page
  • Automatically shorten all URLs found in a message using http://is.gd
  • “as” modifier for posting as multiple twitter accounts.

Most of the features are pretty straightforward. Take a look at the following screenshot. Notice the grey hints after the “twtplus” command when you type and you’ll be fine.

twtplus

twtplus

In order to get multi-account posting working, there are a couple things I’d like to mention. First, due to the way the browser works, if you have a logged in session for Twitter, the browser will ALWAYS post your tweet as the currently logged in user, regardless of the one you specifies with the “as” modifier keyword. Thus the solution is to avoid being logged in via the Twitter web interface, or when the stock “twitter” command prompts you a login dailog. If you visit twitter.com and find that you’ve already logged in, log out explicitly.

Secondly, twtplus looks for your stored usernames and passwords for Twitter in your Firefox password manager, for the login authentication to Twitter and provide multiple account autocompletion suggestions. So you need to store your Twitter accounts with Firefox if you haven’t already. This is also a more secure and convenient way than the stock “twitter” command since you don’t need to input your twitter login from time to time.

Now get twtplus from here.

Update: Here’s an awesome screencast from @neo4zion