FireFox应用二例

一、添加自定义搜索引擎

firefox-searchplugins.png

在Firefox\searchplugins文件夹处建立xml文档,内容如下:

<SearchPlugin xmlns=”http://www.mozilla.org/2006/browser/search/”>

<ShortName>名称</ShortName>

<Description>描述</Description>

<InputEncoding>编码</InputEncoding>

<Image width=”16″ height=”16″>data:text/html;charset=utf-8;base64,图标数据</Image>

<Url type=”text/html” method=”POST” template=”搜索页“>

<Param name=”参数名” value=”参数“/>

……

</Url>

<SearchForm>站点地址</SearchForm>

</SearchPlugin>

如豆瓣搜索,({searchTerms}代表用户输入的内容):

<SearchPlugin xmlns=”http://www.mozilla.org/2006/browser/search/”>

<ShortName>Douban</ShortName>

<Description>Douban</Description>

<InputEncoding>UTF-8</InputEncoding>

<Image width=”16″ height=”16″>data:text/html;charset=utf-8;base64,AAABAAEAEBAQAAEABAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAAAAAAAAABMLAAATCwAAEAAAAAAAAAAAZgAAEXARACJ6IgAzhTMAUJZQAGajZgB3rXcAiLiIAJnCmQCqzKoAu9a7AMzgzADd690A7vXuAP///wAAAAAAXu7MuIhlUyAIzO7u7u7u6wACM2qWi8y2AI7aIDeEIQAAioigACntQAAAAVUwAH6gAABt7uynRCAAAK287u7lAAAJ6AAkjeYAAC7tuGQk3kAAC+7u7u3uoAACu2i87u0wABIIpCEiIQAAvreKy2EAAACc3u7u7clgAAAUaIiLymAAAL3IAAC9+AAAAB8AAAAKAAAAAQAAAAEAAL3gAAAAAAAAACcAAAABAAAACgAAAAEAAM8bAAAAAAAA+mAAAAAM</Image>

<Url type=”text/html” method=”POST” template=”http://www.douban.com/subject_search“>

<Param name=”search_text” value=”{searchTerms}“/>

</Url>

<SearchForm>http://www.douban.com</SearchForm>

</SearchPlugin>

其中firefox官网给的图标数据转化程序似乎不起作用,我另外找了一个,地址是:http://www.scalora.org/projects/uriencoder/,选择 html项并转换就是了。

附件内另有VeryCD的搜索引擎。

searchplugins.zip

二、利用GreaseMonkey插件修改The New Yorker线上文章地址

new-yorker-url.png

我经常上《纽约客》网站阅读其线上文章,最近想把每期杂志转成单个纯文本文档并放在我的电子书阅读器上看。由于一期杂志内容很多,如果每篇都点击、编辑、保存,估计够呛,所以必须用FlashGet之类的工具批量下载。不过麻烦的是,这样下载来的文档不是打印版,里面有很多不相关的东西,转成纯文本后每看一篇都要辨认很久。我注意到它的打印版文章都是在URL后面添加一个标志:?printable=true,所以祭出油猴,动手改之。

步骤:首先安装油猴插件,然后在Firefox中启动它,写以下文件(其中用2007为匹配符是偷懒的作法,如果杂志是2008年的,就要改成2008):

// ==UserScript==

// @name new_yorker

// @namespace new_yorker

// @include http://www.newyorker.com/magazine/toc/*

// ==/UserScript==

//获得杂志内所有链接

var divIssue = document.getElementById(’inthisissue’);

var articleLinks = divIssue.getElementsByTagName(’a');

//匹配每个链接并更改地址

for (var i=0;i<articleLinks.length;i++){

var singleLink = articleLinks.item(i);

if (singleLink.href.match(/2007/i)){

singleLink.href= singleLink.href + ‘?printable=true’;

}

}

保存、刷新页面就可以了,发现地址都被篡改了吧?接下来就用批量下载工具疯狂下载,然后再用TextForever之类的文本工具编辑一下,全程两分钟就搞定!

附件内是2007年12月17日的杂志内容。

ny1217.zip

One Response to “FireFox应用二例”

  1. 觋 » Blog Archive » 利用FireFox+GreaseMonkey插件实现VeryCD站与豆瓣站信息快速检索 Says:

    […] VeryCD站与豆瓣站是我经常查询信息的两个网站,使用频率很高,因此我曾经把这两个站点加入了FireFox的自定义搜索引擎中(参见日志《FireFox应用二例》),用下来效果很不错,但还是略显麻烦。记得以前见过有个FireFox插件能够实现选中一个词语后再按某键可以显示一个层(而不是打开一个新标签)打开google搜索该词,于是在网上找寻了一番,没想到找出一个更强大的GreaseMonkey的脚本LookItUp2,它的功能描述正合我意——“Select a word, and immidiately see it looked up in your wikipedia, a dictionary or whatever you like (it can be customized!)”于是安装并定制了一下。 […]

Leave a Reply

  • 最新日志

  • Recent Comments

    • aluja: http://cache.tianya.cn/publicforum/content/no11/1/390244.sht...
    • aluja: http://xuewei.blog.sohu.com/94636876.html...
    • aluja: “我觉得自己就是阿里萨。”笑翻,原来大叔也年轻过啊。...
    • bigbing: 是吗?我还是包法利夫人呢……...
    • 阿烂: 我记得大饼当初是用文曲星看完这部小说的,并且以文艺青年特有的腔调跟我说:我觉得自己就是阿里萨。瞧瞧现在发福的大饼,难道真...
  • Blackish

    This theme is built with clean and validated XHTML and CSS, fully support widget on both sidebar, also adsense ready.

    The theme is free to use but the links at the footer must remain in tact.

Theme Brought to you by Directory Journal and Elegant Directory