使用 Firefox 扩展以编程方式在书签工具栏中为页面添加书签
Programmatically bookmark pages in bookmark toolbar using firefox extension
我正在尝试制作一个 firefox 扩展,为当前页面添加书签并在书签工具栏中添加一个条目。使用找到的文档中的示例 here 我只能为 link 添加书签,但不能使其出现在书签工具栏中。我无法在文档或与此相关的 google 上找到任何有用的信息。
这是我的代码:
let { Bookmark, save } = require("sdk/places/bookmarks");
// Create a new bookmark instance, unsaved
let bookmark = Bookmark({ title: "Test", url: "http://mozilla.org" });
// Attempt to save the bookmark instance to the Bookmarks database
// and store the emitter
let emitter = save(bookmark);
这是不可能的,还是我忽略了文档中的某些内容?
尝试将 group
设置为 TOOLBAR
,如下所示:
let { Bookmark, TOOLBAR, save } = require("sdk/places/bookmarks");
// Create a new bookmark instance, unsaved
let bookmark = Bookmark({
title: "Test",
url: "http://mozilla.org",
group: TOOLBAR,
});
// Attempt to save the bookmark instance to the Bookmarks database
// and store the emitter
let emitter = save(bookmark);
在 MDN
页面的 this part 上有更多信息
显然是这样做的:
let { Bookmark, TOOLBAR, save } = require("sdk/places/bookmarks");
// Create a new bookmark instance, unsaved
let bookmark = Bookmark({
title: "Test",
url: "http://mozilla.org",
group: TOOLBAR
});
// Attempt to save the bookmark instance to the Bookmarks database
// and store the emitter
let emitter = save(bookmark);
我正在尝试制作一个 firefox 扩展,为当前页面添加书签并在书签工具栏中添加一个条目。使用找到的文档中的示例 here 我只能为 link 添加书签,但不能使其出现在书签工具栏中。我无法在文档或与此相关的 google 上找到任何有用的信息。
这是我的代码:
let { Bookmark, save } = require("sdk/places/bookmarks");
// Create a new bookmark instance, unsaved
let bookmark = Bookmark({ title: "Test", url: "http://mozilla.org" });
// Attempt to save the bookmark instance to the Bookmarks database
// and store the emitter
let emitter = save(bookmark);
这是不可能的,还是我忽略了文档中的某些内容?
尝试将 group
设置为 TOOLBAR
,如下所示:
let { Bookmark, TOOLBAR, save } = require("sdk/places/bookmarks");
// Create a new bookmark instance, unsaved
let bookmark = Bookmark({
title: "Test",
url: "http://mozilla.org",
group: TOOLBAR,
});
// Attempt to save the bookmark instance to the Bookmarks database
// and store the emitter
let emitter = save(bookmark);
在 MDN
页面的 this part 上有更多信息显然是这样做的:
let { Bookmark, TOOLBAR, save } = require("sdk/places/bookmarks");
// Create a new bookmark instance, unsaved
let bookmark = Bookmark({
title: "Test",
url: "http://mozilla.org",
group: TOOLBAR
});
// Attempt to save the bookmark instance to the Bookmarks database
// and store the emitter
let emitter = save(bookmark);