Created
April 18, 2011 02:58
-
-
Save 958/924735 to your computer and use it in GitHub Desktop.
[keysnail]"Opera の Go to nickname をパクル" を KeySnail の Prompt で (要 bmany)
This file contains 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
ext.add('go-nickname', function(ev, arg) { | |
//Opera の Go to nickname をパクル - Griever | |
//http://d.hatena.ne.jp/Griever/20090625/1245933515 | |
//を KeySnail + bmany plugin で | |
const openMode = "tab"; | |
let bmsvc = Cc['@mozilla.org/browser/nav-bookmarks-service;1'].getService(Ci.nsINavBookmarksService); | |
let keywords = function () { | |
let ios = Cc['@mozilla.org/network/io-service;1'].getService(Ci.nsIIOService); | |
return function (aItemId) { | |
let ret = []; | |
let parentNode = PlacesUtils.getFolderContents(aItemId).root; | |
for (let i = 0; i < parentNode.childCount; i++) { | |
let childNode = parentNode.getChild(i); | |
if (PlacesUtils.nodeIsBookmark(childNode)) { | |
let uri = ios.newURI(childNode.uri, null, null); | |
let keyword = bmsvc.getKeywordForURI(uri); | |
if (keyword) {ret.push(keyword);} | |
} else if (PlacesUtils.nodeIsFolder(childNode) && !PlacesUtils.nodeIsLivemarkContainer(childNode)) { | |
ret = ret.concat(arguments.callee(childNode.itemId)); | |
} | |
} | |
return ret; | |
}(1).filter(function (elem, index, array) array.indexOf(elem) == index); | |
}(); | |
prompt.reader({ | |
message: "Go Nickname:", | |
completer: function (str) { | |
let completionList = keywords.filter(function(i) i.indexOf(str) === 0).map(function(i) { | |
return [i, bmsvc.getURIForKeyword(i).spec]; | |
}); | |
return {collection: completionList, origin: 0, query: str}; | |
}, | |
onChange: function (arg) { | |
if (arg.event.keyCode === KeyEvent.DOM_VK_SHIFT || | |
arg.event.keyCode === KeyEvent.DOM_VK_TAB) | |
return; | |
var value = arg.textbox.value; | |
var matchKeywords = keywords.filter(function (elem) elem.indexOf(value) === 0); | |
if (matchKeywords.length === 1) { | |
plugins.bmany.go(bmsvc.getURIForKeyword(matchKeywords[0]).spec, openMode); | |
prompt.finish(true); | |
} | |
}, | |
callback: function (value) plugins.bmany.go(bmsvc.getURIForKeyword(value).spec, openMode) | |
}); | |
}, M({ja:'ブックマークのキーワードから即座に開く', en:'Open keyword bookmark'})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
↑を修正してエクステ化