Skip to content

Instantly share code, notes, and snippets.

@thomcc
Last active April 16, 2018 16:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thomcc/892265094c8e9d15817f52a65e89695a to your computer and use it in GitHub Desktop.
Save thomcc/892265094c8e9d15817f52a65e89695a to your computer and use it in GitHub Desktop.
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