Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ChromeUtils.import("resource://gre/modules/SyncedBookmarksMirror.jsm");
async function addBookmarks() {
let buf = await SyncedBookmarksMirror.open({
path: ":memory:",
recordTelemetryEvent() {},
});
let menu = {
id: "menu",
type: "folder",
title: "Bookmarks Menu",
children: [],
cleartextToString() {},
};
let records = [];
for (let i = 0; i < 3000; i++) {
let guid = PlacesUtils.history.makeGuid();
menu.children.push(guid);
records.push({
id: guid,
type: "bookmark",
title: `Bookmark ${i}`,
bmkUri: `http://example.com/${i}`,
cleartextToString() {},
});
}
records.push(menu);
console.log("Inserting records into mirror");
await buf.store(records);
console.log("Applying mirror to Places");
await buf.apply();
await buf.finalize();
console.log("done");
}
addBookmarks().catch(console.error);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment