2016-03-20 6 views
0

Ich versuche, eine Firefox-Erweiterung, die die aktuelle Seite Lesezeichen und fügt einen Eintrag in der Lesezeichen-Symbolleiste. Mit dem Beispiel in der gefundenen Dokumentation here konnte ich nur einen Link markieren, aber nicht in der Lesezeichen-Symbolleiste erscheinen lassen. Ich konnte nichts hilfreiches in der Dokumentation oder bei Google dazu finden.Programmatisch Lesezeichen Seiten in Lesezeichen-Symbolleiste mit Firefox-Erweiterung

Hier ist mein Code:

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); 

Ist dies einfach nicht möglich, oder gibt es etwas in der Dokumentation, die ich übersehen habe?

Antwort

1

Try group-TOOLBAR, wie so einstellen:

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); 

Es gibt mehr Informationen über this part der Seite, auf MDN

+0

Offenbar ist es TOOLBAR ohne Apostrophe und Sie müssen es mit der Anweisung require initialisieren. Ich habe eine Antwort geschrieben, um es klarer zu machen. Vielen Dank für Ihre Vorschläge. – conectionist

+0

@cononectionist Danke, ich habe meine Antwort aktualisiert – Druzion

0

Offenbar ist dies, wie es gemacht wird:

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); 
Verwandte Themen