aboutsummaryrefslogtreecommitdiffstats
path: root/autoIgnoreKey.js
blob: 07dd2185e25c0fb3a09d0bf7c892aebd5bfc8c53 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/**
 * Auto switch vimperator key navigation
 * For vimperator 0.5.3
 * @author teramako teramako@gmail.com
 * @version 0.3
 */

(function(){
/*
 * String or RegExp
 * e.g)
 *  * /^https?:\/\/mail\.google\.com\//
 *  * 'http://reader.livedoor.com/reader/'
 */
const ignorePageList = [
	/^https?:\/\/mail\.google\.com\//,
	/^http:\/\/reader\.livedoor\.com\/(?:reader|public)\//
];
document.getElementById('appcontent').addEventListener('DOMContentLoaded',function(event){
	if (event.target.documentURI != gBrowser.currentURI.spec) return;
	if ( isMatch(event.target.documentURI) ){
		vimperator.addMode(null, vimperator.modes.ESCAPE_ALL_KEYS);
	} else {
		vimperator.setMode(vimperator.modes.NORMAL);
	}
	//vimperator.log('load page: ' + gBrowser.selectedBrowser.contentDocument.URL);
},false);
getBrowser().mTabBox.addEventListener('TabSelect',function(event){
	var uri = this.parentNode.currentURI.spec;
	if ( isMatch(uri) ){
		vimperator.addMode(null, vimperator.modes.ESCAPE_ALL_KEYS);
	} else {
		vimperator.setMode(vimperator.modes.NORMAL);
	}
	//vimperator.log('select page: ' + gBrowser.selectedBrowser.contentDocument.URL);
},false);
function isMatch(uri){
	return ignorePageList.some(function(e,i,a){
		if (typeof e == 'string'){
			return uri.indexOf(e) != -1;
		} else if (e instanceof RegExp){
			return e.test(uri);
		}
	});
}
})();

// vim: set fdm=marker sw=4 ts=4 et: