// ==VimperatorPlugin== // @name BookmarksToolbar-Hint // @description Feature the BookmarksToolbar-Hint // @description-ja ブックマークツールバーのヒント機能を提供 // @version 0.2c // ==/VimperatorPlugin== // // Usage: // // f -> open current tab // F -> open new tab // // Note: is `\' by default // // duaing BookmarksToolbar-Hint, numbering tooltip is appear. // the item of matched number will open when type the number // and remove pending number or backward to parent (at opening a folder) // liberator.plugins.bookmarkToolbarHints = (function(){ if (typeof plugins == 'undefined') plugins = liberator.plugins; // for 2.0 pre function createTooltip(){ var tooltip = document.createElement('tooltip'); tooltip.setAttribute('style','padding:0;margin:0;'); var label = document.createElement('label'); label.setAttribute('value',tooltipbox.childNodes.length+1); label.setAttribute('style','padding:0;margin:0 2px;'); tooltip.appendChild(label); tooltipbox.appendChild(tooltip); return tooltip; } function clearTooltips(){ while (tooltipbox.hasChildNodes()){ tooltipbox.firstChild.hidePopup(); tooltipbox.removeChild(tooltipbox.firstChild); } } function getToolbar() toolbar || (toolbar = document.getElementById('bookmarksBarContent')); function onKeyPress(event){ manager.onEvent(event); event.stopPropagation(); event.preventDefault(); } function updateSelector(){ for (let i=0; i": case "": closeMenus(current); liberator.modules.options.guioptions = this.go; break; case "": case "": if (toolbarOpen(hints[currentNum])) return; break; case "f": this.where = liberator.CURRENT_TAB; return; case "F": case "t": this.where = liberator.NEW_TAB; return; case "": case "j": case "": case "": case "k": case "": if (key == "j" || key == "" || key == ""){ currentNum = hints.length -1 == currentNum ? 0 : currentNum + 1; } else { currentNum = currentNum == 0 ? hints.length -1 : currentNum - 1; } useShift = true; updateSelector(); return; case "l": if (hints[currentNum].getAttribute("container") == "true"){ folderOpen(hints[currentNum]); } return; case "": if (key == "" && currentNum > 0){ currentNum = Math.floor(currentNum / 10); updateSelector(); return; } case "h": if (current == this.toolbar){ closeMenus(current); liberator.modules.options.guioptions = this.go; this.quit(); } else { current.hidePopup(); clearTooltips(); this.show(current.parentNode.parentNode); } return; default: if (/^[0-9]$/.test(key)){ let num = parseInt(key,10); if (!useShift && currentNum) num += currentNum * 10; if (hints.length >= num*10){ currentNum = num - 1; updateSelector(); return; } if (hints[num-1]){ if (toolbarOpen(hints[num-1])) return; } } } liberator.plugins.bookmarkToolbarHints.quit(); }, quit: function(){ currentNum = 0; useShift = false; window.removeEventListener('keypress',onKeyPress,true); liberator.modules.modes.reset(true); while (tooltipbox.hasChildNodes()){ tooltipbox.firstChild.hidePopup(); tooltipbox.remove
/**
 * Auto switch Vimperator key navigation
 *
 * @author teramako teramako@gmail.com
 * @author halt feits <halt.feit at gmail.com>
 * @version 0.6pre
 */

(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().mTabBox.addEventListener('TabSelect',passAllKeysIfTarget,false);

function passAllKeysIfTarget() {
    var uri = content.document.documentURI;
    liberator.modules.modes.passAllKeys = isMatch(uri);
    //liberator.log('load page: ' + gBrowser.selectedBrowser.contentDocument.URL);
}

function isMatch(uri) ignorePagesList.some(function(e) e.test(uri))

})();
// vim:sw=4 ts=4 et: