y,自从用了vim,该让机器做的都让机器做了。。
这个东东的原理是这样滴,firefox安装一个插件,起作用的就下面几行
var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile); file.initWithPath("/tmp/refresh.firefox"); //浏览器开启时启动一个定时器 var timer = setInterval(function() { //每隔0.1秒检测一下这个文件存在否 if ( file.exists() ) { //如果存在,删除之 file.remove(true); //获取当前标签的文档对象 var doc = gBrowser.selectedBrowser.contentDocument; //是否是在调试的东东 if ( /(xiaonei\.com|kaixin\.com)/.test( doc.location.href ) ) { //如果是,调用dnsFluher,刷新host,如果没有安装此插件就算了 dnsFluher.refreshdns(); //刷新页面 doc.location.reload(); } } },100 );
所以,只要在/tmp/目录生成一个refresh.firefox的文件,firefox便会刷新了
vim 里添加一行配置文件
"更改host文件时刷新 autocmd BufWritePost,FileWritePost /etc/hosts execute '!echo '' > /tmp/refresh.firefox' "更改调试文件时刷新 autocmd BufWritePost,FileWritePost */jspro/*.js execute '!echo '' > /tmp/refresh.firefox'
插件附上,根据情况自行修改。。
扩展名改成xpi拖到firefox就可以安装了

为解放前端生产力做了爆巨大的贡献!
2009年04月3日 @ 17:04
是个好主意。
能否修改一下,在修改一个文件时,把对应的host写进去/tmp/refresh.txt,firefox读取这个内容,只刷新这个host的内容。
如我在开发一个ror项目,我运行在localhost:3000上,我修改文件时,自动向/tmp/refresh.txt中写入localhost:3000,然后firefox就会自动刷新所有打开的localhost:3000页面。
2009年08月30日 @ 01:31
@crazycode, 恩,可以参考一下这篇文章http://hi.baidu.com/jimboybo/blog/item/707b0d17fe42cd0cc83d6de4.html,把if ( /(xiaonei\.com|kaixin\.com)/.test( doc.location.href ) )这句修改成从文件读取就可以实现了
2009年09月1日 @ 08:00
[...] 这位达人写了一个Firefox小扩展,用于修改js和host文件的时候用。 [...]
2010年02月28日 @ 23:44