Last active
April 16, 2018 16:36
-
-
Save thomcc/892265094c8e9d15817f52a65e89695a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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