ifree's Blog - it's my way

豆瓣fm的全局快捷键

最近用上了pentadacty, 感觉不错,高效强大. 个人有一个习惯,只要不是思考密集的时间都会抽时间来听会歌,同时也有开大量tabs的习惯,所以在听豆瓣电台的时候免不了频繁的切换,于是就有了下面的代码:

"eval script in tabs 
js <<EOF
function execScriptInTabs(filter,domjs){
	 tabs.allTabs.forEach(function(itm){
	var ctab=gBrowser.getBrowserForTab(itm);
	if(filter(ctab)){
		var s=ctab.contentDocument.createElement('script')
		s.textContent=domjs;
		ctab.contentDocument.body.appendChild(s);
	}
	 })
}
EOF

"douban.fm utilities

js <<EOF
group.mappings.add(
[modes.NORMAL],
[",ds"],"skip",
function(){
execScriptInTabs(function(ctab){
return ctab.contentDocument.location.host.match("douban\.fm");
},"DBR.act('skip')");//skip,pause,love
}
);
group.mappings.add(
[modes.NORMAL],
[",dd"],"ban",
function(){
execScriptInTabs(function(ctab){
return ctab.contentDocument.location.host.match("douban\.fm");
},"DBnnR.act('ban')");//skip,pause,love
}
);
group.mappings.add(
[modes.NORMAL],
[",dl"],"like",
function(){
execScriptInTabs(function(ctab){
return ctab.contentDocument.location.host.match("douban\.fm");
},"DBR.act('love')");//skip,pause,love
}
);
group.mappings.add(
[modes.NORMAL],
[",dp"],"pause",
function(){
execScriptInTabs(function(ctab){
return ctab.contentDocument.location.host.match("douban\.fm");
},"DBR.act('pause')");//skip,pause,love
}
);
EOF