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

25
LINES

< > BotCompany Repo | #1027118 - generateChromeBookmarksChecksum [seems to work with Chrome 80]

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

Libraryless. Click here for Pure Java version (4960L/28K).

// Try to calculate a checksum that allows to modify Chrome's bookmarks
sS generateChromeBookmarksChecksum(S json) {
  Map bookmarks = jsonDecodeMap(json);
  MessageDigest md5 = md5encoder();
  
  embedded void checksum_node(O node) {
    if (node cast Map) {
      md5_updateUtf8(md5, (S) node.get("id"));
      md5.update(toUTF16LE((S) node.get("name")));
      if (eq(node.get("type"), "url")) {
        md5_updateUtf8(md5, "url");
        md5_updateUtf8(md5, (S) node.get("url"));
      } else {
        md5_updateUtf8(md5, "folder");
        fOr (O c : (L) node.get("children"))
          checksum_node(c);
      }
    }
  }

  for (S root : splitAtSpace("bookmark_bar other synced"))
    checksum_node(mapGetMapGet(bookmarks, "roots", root));
    
  ret md5_finish(md5);
}

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1027118
Snippet name: generateChromeBookmarksChecksum [seems to work with Chrome 80]
Eternal ID of this version: #1027118/7
Text MD5: 12c87075eedd76e7c211a765c78c8672
Transpilation MD5: 62183852f98a5567bb06fe0b58f58094
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-11-14 19:30:21
Source code size: 802 bytes / 25 lines
Pitched / IR pitched: No / No
Views / Downloads: 89 / 160
Version history: 6 change(s)
Referenced in: [show references]