Last active
February 26, 2024 07:13
-
-
Save alejandrocoding/5f3e9852da8b2487ee83bdf03ccc1d0b to your computer and use it in GitHub Desktop.
Functions for adding bookmark folders and links by Observables
This file contains hidden or 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
function addBookMarkFolder(): Observable<chrome.bookmarks.BookmarkTreeNode> { | |
return new Observable((observer) => | |
chrome.bookmarks.create(BOOKMARK_FOLDER, (bookMarkFolder) => | |
observer.next(bookMarkFolder) | |
) | |
); | |
} | |
function addBookMarkLink(bookMarkFolder: chrome.bookmarks.BookmarkTreeNode): Observable<string> { | |
return new Observable((observer) => | |
chrome.bookmarks.create( | |
{ ...BOOKMARK_LINK, parentId: bookMarkFolder.id }, // parentId takes the folder id created from addBookMarkFolder | |
(bookMark) => observer.next(`Added folder ${bookMarkFolder.title} & link ${bookMark.title}`) | |
) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment