Created
August 19, 2011 04:07
-
-
Save hayajo/1156016 to your computer and use it in GitHub Desktop.
autoIgnoreKey.js - vimperator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
/** | |
* String or RegExp | |
* e.g) | |
* * /^https?:\/\/mail\.google\.com\// | |
* * 'http://reader.livedoor.com/reader/' | |
* | |
* The autoignorekey_pages is a string variable which can set on | |
* vimperatorrc as following. | |
* | |
* let autoignorekey_pages = "['http://example.com/*', 'http://example.org/*']" | |
* | |
* or your can set it using inline JavaScript. | |
* | |
* javascript <<EOM | |
* liberator.globalVariables.autoignorekey_pages = uneval([ | |
* /^https?:\/\/mail\.google\.com\//, | |
* /^https?:\/\/www\.google\.com\/reader\//, | |
* ]); | |
* EOM | |
*/ | |
const ignorePagesList = window.eval(liberator.globalVariables.autoignorekey_pages) || [ | |
/^https?:\/\/mail\.google\.com\//, | |
/^http:\/\/(?:reader\.livedoor|fastladder)\.com\/(?:reader|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',passAllKeysIfTarget,false); | |
getBrowser().mTabContainer.addEventListener('TabSelect',passAllKeysIfTarget,false); | |
function passAllKeysIfTarget() { | |
var uri = content.document.documentURI; | |
liberator.modules.modes.passAllKeys = isMatch(uri); | |
} | |
function isMatch(uri) ignorePagesList.some(function(e) e.test(uri)) | |
})(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment