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).

1  
srecord ChromeBookmark(S url, S name, long dateAdded) {
2  
  toString {
3  
    ret name + appendRoundBracketed(url) + " " + timestamp();
4  
  }
5  
  
6  
  Timestamp timestamp() {
7  
    ret chromeTimestampToTimestamp(dateAdded);
8  
  }
9  
}
10  
11  
static L<ChromeBookmark> getChromeBookmarks(File bookmarksFile default chromeBookmarksFile()) {
12  
  assertTrue("No bookmarks dir", isFile(bookmarksFile));
13  
  S text = loadTextFile(bookmarksFile);
14  
  assertNotNull("No Bookmarks file: " + bookmarksFile.getAbsolutePath(), text);
15  
  O json = jsonDecode(text);
16  
  
17  
  new L<ChromeBookmark> list;
18  
  for (Map map : findAllMaps(json)) pcall {
19  
    O url = map.get("url");
20  
    if (url instanceof S) {
21  
      new ChromeBookmark b;
22  
      b.url = (S) url;
23  
      b.name = (S) map.get("name");
24  
      b.dateAdded = parseLong(map.get("date_added"));
25  
      list.add(b);
26  
    }
27  
  }
28  
  ret list;
29  
}

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: 718 / 793
Version history: 9 change(s)
Referenced in: [show references]