Add bookmark command to Keysnail
This commit is contained in:
parent
80edf526d3
commit
0f5e07d009
1 changed files with 62 additions and 1 deletions
|
@ -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");
|
||||
|
|
Loading…
Reference in a new issue