damien.h

twtplus updated for Ubiquity 0.5+

I’ve updated the “twtplus” command for Ubiquity 0.5+. Since Github Gist sucks right now, (it’s very slow and cuts off the last lines of the code randomly without any prompt) I’m publishing the script here on my blog. Note that this is only compatible with Ubiq 0.5+ now.
twtplus.ubiq.js

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

媒体标签扩展功能

jiwai命令现在支持#movie/…/,#music/…/和#book/…/三种媒体标签。在编写消息的时候可以通过媒体标签定义搜索关键字,jiwai命令脚本会自动从豆瓣找到关键字匹配的物品内容,并把媒体信息直接补充到消息里。

举个例子,比如我刚看了1080p的变形金刚觉得非常爽,需要发一条叽歪告诉朋友们,最好在消息里还加上关于变形金刚电影的额外信息。如果不用jiwai命令,那么我首先从浏览器里访问豆瓣,然后搜索变形金刚电影,然后找到电影地址,复制下来,贴到消息里,专业点的话再加上个[电影]的前缀,最后终于可以发送了。麻烦吧!

现在用jiwai命令,这一切都可以变得超级简单,过程是这样的:

  1. 在firefox上唤出Ubiquity窗口
  2. 输入”jiwai 刚看了1080p的#movie/变形金刚/ 太爽了!”,看到的就是这个样子:
    Ubiquity
  3. 其实没有第三步了,如果想要指定发消息的帐号的话,再输入”as 用户名”,回车发送就搞定了!

最后发送的消息格式可以从”Preview”处看到。jiwai脚本会用标准的名称替换#movie/…/,然后在消息开头专业的加上[电影],[读书],或者[音乐]标签。外加一个好处,叽歪在个人主页上支持扩展豆瓣媒体内容,如果消息里包含了豆瓣媒体链接的话叽歪会自动把媒体信息显示出来,就像这样:

叽歪

多帐号发消息

有些用户需要不时地切换不同帐号来发消息,目前还没有好的工具支持这种需求。通过jiwai命令的as关键字,用马甲发消息一下子变得前所未有的简单了!

要使用这个功能,首先请确保浏览器处于未登录叽歪的状态。也就是说,打开http://jiwai.de以后显示的是未登录状态。浏览器在登录状态下时,通过as关键字指定的马甲帐号会无效,而总是使用当前登录的帐号作为发消息的帐号了。

jiwai命令通过firefox密码管理器中记录的jiwai帐号来实现多帐号切换,所以正常使用的前提还包括需要把多个帐号的用户名密码都已经保存在firefox密码管理器中。要知道jiwai命令是不是拿到帐号登录信息,还可以通过as关键字的自动完成提示来判断。如果找到了帐号信息,那么在打了用户名的前几个字母以后就可以看到提示并通过tab来自动完成了。

其他功能

jiwai命令的其他主要功能还包括:

  • 自动用http://is.gd缩短消息里的所有URL(除了自动替换的媒体链接以外)
  • 使用#url标签来指定替代当前页面的地址(注意#url标签前后需要有空格)
  • @, d关键字自动完成好友用户名

补充

推荐使用Ubiquity的Ubiquity Evolved皮肤,有足够的空间显示更多内容。在Simpliquity皮肤下显示媒体预览时候有时候会有问题。

Ubiquity叽歪命令加强版

Ubiquity刚出来时候写过个最简单的叽歪命令玩,现在写了个加强版的放出,比以前的好用多了,可以从这里安装
加强版叽歪命令fork自2ii,做了大量修改重构,并且增加了一些有用的功能,除了预览好友时间线外,还能自动用is.gd服务缩短消息里的所有URL,用#url标签替换当前页面地址,[email protected]
目前版本本来打算支持多帐号,会检测已经在firefox保存了帐号的叽歪帐号,在发送消息的时候会通过“as”关键字指定的帐号来提供http basic auth的信息。但是看来叽歪api在第一次basic auth登录以后就不认http请求里的basic auth信息了,所以”as”关键字现在没作用,用来发送消息的帐号只能是第一次登录的帐号。为了避免混淆建议使用前先从web页面登录叽歪并选择记住登录帐号。
下一版本打算针对叽歪支持多种媒体嵌入的功能,提供自动从豆瓣搜索电影,书籍和音乐并嵌入豆瓣链接的功能。这样可以直接在消息里谈论一部电影的时候自动添加电影的豆瓣链接发送到叽歪,从而在叽歪页面上得到自动嵌入的电影海报和名字等信息。对书籍和音乐也同样如此。计划通过#movie{}, #book{}, #music{}这样的标签把需要嵌入的电影、书籍、音乐名字包起来这样使用。在开发的时候发现在Ubiquity预览豆瓣信息的时候,Ubiq界面有时候会莫名缩回去,不知道是不是Ubiq的bug。你要是有什么建议请告诉我。

Ubiquity Jiwai

Ubiquity命令:收藏到Evernote和Friendfeed

Ubiquity太好玩了,又写了几个有用的命令(我为什么要说又呢),可以直接敲键盘来收藏当前选中的内容到Evernote,以及分享到Friendfeed。外加一个,在当前页面上调出Jash,一个Javascript命令行调试工具。从下面的地址就可以安装了。
“clip-to-evernote”命令
“share-on-friendfeed”命令
“jash”命令
当然,首先需要安装Ubiquity插件噢!

Browse Happy logo

My tweets

2016年五月
« 八    
 1
2345678
9101112131415
16171819202122
23242526272829
3031  

分类目录

Articles

Fancy Stats