conkeror

conkeror 可以将你的firefox模拟为Emacs的操作方式,可以使你仅仅 用键盘就可以完成绝大部分操作.

top安装

Conkeror主页 安装完成以后重新启动在地址栏内输入 chrome://conkeror/content/help.html

进入帮助界面,表中列出了常用的快捷键,选择按钮"Set Chrome"将 conkeror设置为默认的chrome.想使用原来的firefox,可以选择Reset Chrome,或者在M-x firefox<RET>即可.

在"Set RC File"中填入"~/.conkeror.js",点击按钮设置配置文件的 路径.

top常用的函数

top改变数字标号的样式

nl_color = "black";
nl_image_backgroundColor = "pink";
nl_link_backgroundColor = "white";
nl_fontWeight = "normal";
nl_fontFamily = "sans-serif";
nl_fontSize = "small";
nl_borderWidth = "1px";
nl_borderColor = "gray";
nl_floater_opacity = "1.0";

top改变minibuffer样式

var conkeror_css;

function conkeror_css_add_rule (rule)
{
    function find_conkeror_css () {
        for (var i = 0; i < document.styleSheets.length; i++) {
            if (document.styleSheets[i].href == "chrome://conkeror/content/conkeror.css")
                return document.styleSheets[i];
        }
    }
    if (! conkeror_css)
        conkeror_css = find_conkeror_css();
    conkeror_css.insertRule (rule, conkeror_css.cssRules.length);
}

conkeror_css_add_rule ('.mode-line { font-size: 12pt; } ');
conkeror_css_add_rule ('#minibuffer-hbox { font-size: 12pt; } ');
conkeror_css_add_rule ('#minibuffer-hbox #input-prompt { color: red; font-weight: bold; } ');

topjavascript 控制台

function jsconsole(args)
{
   var prefix = args[0];
   open_url_in (prefix, "chrome://global/content/console.xul");
}
add_command("jsconsole", jsconsole, [["p"]]);

top重新读取配置文件

function reinit()
{
 var cfg="~/.conkeror.js"
 load_rc_file(cfg);
 message("load config file "+cfg);
}
add_command("reinit", reinit, []);

top读取firefox的设置

下面的几个函数会使用
function set_pref(type,key, value) {
   if (!gPrefService) { message("EEP: no gPrefService"); return 0;}
   if(type==0) gPrefService.setIntPref(key, value);
   else if(type==1) gPrefService.setCharPref(key, value);
   else if(type==2) gPrefService.setBoolPref(key, value);
   else { message("EEP: wrong type"); return 0;
   }
   message(key + " set to " + value);
 }
function clear_pref(key) {
   if (!gPrefService) { message("EEP: no gPrefService"); return 0;}
   gPrefService.clearUserPref(key);
   message(key + " cleared");
 }
function get_pref(type,key) {
   if (!gPrefService) { message("EEP: no gPrefService"); return 0; }
   if (!gPrefService.prefHasUserValue(key)) return null;
   else {
       if(type==0) return gPrefService.getIntPref(key);
       if(type==1) return gPrefService.getCharPref(key);
       if(type==2) return gPrefService.getBoolPref(key);
       return 0;
   }
}

top切换客户端标识

用于访问某些IE only网站
function toggle_agent() {
    var key="general.useragent.override";
    var value="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";
    //get from PreBar
    //Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.0.0) Gecko/20020530
    //Mozilla/4.78 (Macintosh; U; PPC)
    //Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.4) Gecko/20011022 Netscape6/6.2
    //Mozilla/4.0 (compatible; MSIE 5.0; Mac_PowerPC)
    if(get_pref(1,key)) clear_pref(key);
    else set_pref(1,key, value);

}
add_command("toggle-agent", toggle_agent, []);

top切换是否使用代理

function toggle_proxy()
 {
     var proxytype = get_pref(0,"network.proxy.type");
     set_pref(0,"network.proxy.type", proxytype == 1 ? 0 : 1);
 }
 add_command("toggle-proxy", toggle_proxy, []);

top设置代理

function set_proxy(http,port)
{
   set_pref(0,"network.proxy.http_port",port);
   set_pref(1,"network.proxy.http",http);
   message("http proxy "+http+":"+port);
}

function set_proxy_tor()
{
   set_proxy("localhost",8118);
}
add_command("set-proxy-tor", set_proxy_tor, []);

function set_proxy_squid()
{
   set_proxy("localhost",3127);
}
add_command("set-proxy-squid", set_proxy_squid, []);

top搜索引擎

add_webjump("b","http://www.baidu.com/s?wd=%s");
add_webjump("l","http://www.google.com/linux?newwindow=0&q=%s");
add_webjump("g","http://www.google.com/search?newwindow=0&q=%s");
add_webjump("gc","http://www.google.com/search?newwindow=0&hl=zh-CN&lr=lang_zh-CN%7Clang_zh-TW&q=%s");

top几个小问题

conkeror不能正常处理tab,在preferences中Tabs选项卡中选择"New pages should be opened in" " a new window"

conkeror中能使用的插件有:"拼写检查","chm reader"等几个.