Skip to content

Instantly share code, notes, and snippets.

@hayajo
Created August 19, 2011 04:07
Show Gist options
  • Save hayajo/1156016 to your computer and use it in GitHub Desktop.
Save hayajo/1156016 to your computer and use it in GitHub Desktop.
autoIgnoreKey.js - vimperator
(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