Tag Archives: javascript

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

Ubiquity叽歪命令火力加强版

Ubiquity jiwai命令现在变得更强了。首先,现在提供了强大的电影,音乐,书籍标签功能,可以通过指定名称关键字来自动在消息里扩展出媒体信息,通过和叽歪富媒体功能的结合,可以非常方便的在叽歪个人主页上显示丰富的媒体信息。另外,经过调试多帐号发消息功能基本可以正常使用了。

Click to continue reading “Ubiquity叽歪命令火力加强版”

Ubiquity叽歪命令加强版

Ubiquity刚出来时候写过个最简单的叽歪命令玩,现在写了个加强版的放出,比以前的好用多了,可以从这里安装。
加强版叽歪命令fork自2ii,做了大量修改重构,并且增加了一些有用的功能,除了预览好友时间线外,还能自动用is.gd服务缩短消息里的所有URL,用#url标签替换当前页面地址,支持@回复好友和d私信好友的名字自动完成。

Click to continue reading “Ubiquity叽歪命令加强版”

Ubiquity命令:收藏到Evernote和Friendfeed

Ubiquity太好玩了,又写了几个有用的命令(我为什么要说又呢),可以直接敲键盘来收藏当前选中的内容到Evernote,以及分享到Friendfeed。外加一个,在当前页面上调出Jash,一个Javascript命令行调试工具。从下面的地址就可以安装了。

Click to continue reading “Ubiquity命令:收藏到Evernote和Friendfeed”