aboutsummaryrefslogtreecommitdiffstats
path: root/autoIgnoreKey.js
diff options
context:
space:
mode:
authordrry2008-04-08 01:18:59 +0000
committerdrry2008-04-08 01:18:59 +0000
commitefba180e6004413ae2724d298366da2a30dd82a8 (patch)
treef086be311e5280cae16a39ca77061346cb335871 /autoIgnoreKey.js
parent231fbdaab8a83f39c2b1b224349ba23af4774c5e (diff)
downloadvimperator-plugins-efba180e6004413ae2724d298366da2a30dd82a8.tar.bz2
lang/javascript/vimperator-plugins/trunk/autoIgnoreKey.js:
* added a wild-card feature to ignore pages list. * et cetera... git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@9110 d0d07461-0603-4401-acd4-de1884942a52
Diffstat (limited to 'autoIgnoreKey.js')
-rw-r--r--autoIgnoreKey.js50
1 files changed, 23 insertions, 27 deletions
diff --git a/autoIgnoreKey.js b/autoIgnoreKey.js
index 400740b..de3713d 100644
--- a/autoIgnoreKey.js
+++ b/autoIgnoreKey.js
@@ -1,50 +1,46 @@
/**
- * Auto switch vimperator key navigation
+ * Auto switch Vimperator key navigation
*
* @author teramako teramako@gmail.com
* @author halt feits <halt.feit at gmail.com>
- * @version 0.6.0
+ * @version 0.6pre
*/
(function(){
-/*
+/**
* String or RegExp
* e.g)
* * /^https?:\/\/mail\.google\.com\//
* * 'http://reader.livedoor.com/reader/'
*/
-var ignorePageList = [
+const ignorePagesList = [
/^https?:\/\/mail\.google\.com\//,
- 'http://reader.livedoor.com/reader/'
-];
+ 'http://reader.livedoor.com/reader/*',
+ 'http://reader.livedoor.com/public/*',
+ 'http://fastladder.com/reader/*',
+ 'http://fastladder.com/public/*'
+].map(function(i)
+ i instanceof RegExp ? i :
+ i instanceof Array ? new RegExp(String(i[0]), String(i[1])) :
+ new RegExp("^" + String(i).replace(/\s+/g, "")
+ .replace(/[\\^$.+?|(){}\[\]]/g, "\\$&")
+ .replace(/(?=\*)/g, ".")
+ + "$", "i"));
document.getElementById('appcontent').addEventListener('DOMContentLoaded',function(event){
- if ( isMatch(event.target.documentURI) ){
- liberator.modes.passAllKeys = true;
- } else {
- liberator.modes.passAllKeys = false;
- }
+ var uri = event.target.documentURI;
+ liberator.modes.passAllKeys = isMatch(uri);
//liberator.log('load page: ' + gBrowser.selectedBrowser.contentDocument.URL);
},false);
getBrowser().mTabBox.addEventListener('TabSelect',function(event){
var uri = this.parentNode.currentURI.spec;
- if ( isMatch(uri) ){
- liberator.modes.passAllKeys = true;
- } else {
- liberator.modes.passAllKeys = false;
- }
+ liberator.modes.passAllKeys = isMatch(uri);
//liberator.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);
- }
- });
-}
-})();
+},false);
+function isMatch(uri) ignorePagesList.some(function(e) e.test(uri))
+
+})();
+// vim:sw=4 ts=4 et: