Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

29
LINES

< > BotCompany Repo | #1003291 // getChromeBookmarks (tested on Linux and Windows)

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (11138L/62K).

srecord ChromeBookmark(S url, S name, long dateAdded) {
  toString {
    ret name + appendRoundBracketed(url) + " " + timestamp();
  }
  
  Timestamp timestamp() {
    ret chromeTimestampToTimestamp(dateAdded);
  }
}

static L<ChromeBookmark> getChromeBookmarks(File bookmarksFile default chromeBookmarksFile()) {
  assertTrue("No bookmarks dir", isFile(bookmarksFile));
  S text = loadTextFile(bookmarksFile);
  assertNotNull("No Bookmarks file: " + bookmarksFile.getAbsolutePath(), text);
  O json = jsonDecode(text);
  
  new L<ChromeBookmark> list;
  for (Map map : findAllMaps(json)) pcall {
    O url = map.get("url");
    if (url instanceof S) {
      new ChromeBookmark b;
      b.url = (S) url;
      b.name = (S) map.get("name");
      b.dateAdded = parseLong(map.get("date_added"));
      list.add(b);
    }
  }
  ret list;
}

Author comment

Began life as a copy of #1003288

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mowyntqkapby, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1003291
Snippet name: getChromeBookmarks (tested on Linux and Windows)
Eternal ID of this version: #1003291/10
Text MD5: fea088416496068cee119823bf7dbb9a
Transpilation MD5: bb9fb9d168b49cd9c95011029121ece1
Author: stefan
Category: javax / native
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2023-06-02 23:36:02
Source code size: 864 bytes / 29 lines
Pitched / IR pitched: No / No
Views / Downloads: 719 / 794
Version history: 9 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1026341 - chromeBookmarksFile (tested on Linux and Windows)
#1033604 - filteredChromeBookmarks