Add bookmark command to Keysnail

This commit is contained in:
Tom Willemse 2015-11-18 00:23:21 +01:00
parent 80edf526d3
commit 0f5e07d009

View file

@ -3,7 +3,8 @@
* KeySnail KeyEvent userscript ext openHelpLink
* BrowserCloseTabOrWindow closeWindow undoCloseTab OpenBrowserWindow
* getBrowser goQuitApplication saveDocument toJavaScriptConsole
* display shell BrowserReload BrowserBack BrowserForward content*/
* display shell BrowserReload BrowserBack BrowserForward content M
* Components*/
// You can preserve your code in this area when generating the init
// file using GUI. Put all your code except special key, set*key,
// hook, blacklist.
@ -541,3 +542,63 @@ key.setViewKey([':', 'k'], function (ev, arg) {
key.setViewKey([':', 't'], function (ev, arg) {
ext.exec("bmany-list-bookmarks-with-tag", arg, ev);
}, "bmany - List bookmarks with tag");
var oni =
(function() {
function _saveBookmark(tags, bookmark) {
var bmsvc = Components.classes["@mozilla.org/browser/nav-bookmarks-service;1"]
.getService(Components.interfaces.nsINavBookmarksService);
var ios = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
var taggingSvc = Components.classes["@mozilla.org/browser/tagging-service;1"]
.getService(Components.interfaces.nsITaggingService);
var uri = ios.newURI(bookmark.url, null, null);
bmsvc.insertBookmark(bmsvc.bookmarksMenuFolder, uri,
bmsvc.DEFAULT_INDEX, bookmark.title);
taggingSvc.tagURI(uri, tags.split(',').map(String.trim));
}
function _readTags(url, bookmark) {
bookmark.url = url;
prompt.read(
"tags (comma-separated):",
_saveBookmark,
bookmark, null
);
}
function _readURL(title) {
prompt.read(
"url:",
_readTags,
{title: title}, null,
window.content.location.href
);
}
function _readTitle() {
prompt.read(
"title:",
_readURL,
null, null,
window.content.document.title
);
}
var self = {
addBookmark: function(arg) {
_readTitle();
}
};
return self;
})();
ext.add('oni-add-bookmark', function(ev, arg) { oni.addBookmark(arg); },
M({en: "oni - Add bookmark"}));
key.setViewKey([':', 'a'], function (ev, arg) {
ext.exec("oni-add-bookmark", arg, ev);
}, "Bookmark this page");