The logic behind creating bookmark checksum in Google Chrome

How can I add a new bookmark entry to a chrome bookmarkfile ?. My requirement: I need to add a bookmark through my application. Specify the logic for creating the checksum (MD5).

+4
source share
3 answers

Regardless of the security / hacking of this case, here's how:

  • Make sure Chrome is closed.
  • Delete (or rename) Bookmarks.bak
  • Delete Whole Checksum Record from Bookmarks
  • Edit Bookmarks JSON in your heart.
  • Reopen Chrome

If there are no backups and checksum, Chrome will use the new JSON and create a new checksum.

If you want to do this more smoothly / less aggressively, you can just watch how they generate the checksum in the source code and implement the same algorithm (see here , line 57).

Of course, keep in mind that Google may change something that may violate compatibility. However, this does work, I just did it in the Java application that I wrote.

+6
source

My advice: do not do this. This is hacking behavior. Chrome does not include the bookmark file in its "API", and it is subject to change without notice. We donโ€™t know what will happen if you modify the file while Chrome is running. Does Chrome check this file every time before recording? Or is it read only once at startup? What about profiles and bookmark sync?

I recommend using the bookmarks object in the Chrome Extensions API.

+1
source

Obviously, this is hacking and is intended only for people who know what they are doing, but since Chrome Mobile does not allow the user to export / import their bookmarks (which are not very convenient for the user!), Sometimes there is no choice - imagine you need to clear your bookmark file with thousands of entries manually.

Anyway, here's a working Python implementation:

 roots = ['bookmark_bar', 'other', 'synced'] def checksum_bookmarks(bookmarks): md5 = hashlib.md5() def checksum_node(node): md5.update(node['id'].encode()) md5.update(node['name'].encode('utf-16le')) if node['type'] == 'url': md5.update(b'url') md5.update(node['url'].encode()) else: md5.update(b'folder') if 'children' in node: for c in node['children']: checksum_node(c) for root in roots: checksum_node(bookmarks['roots'][root]) return md5.hexdigest() 

While you only add bookmarks, you are probably fine, but for something more complicated (for example, performing basic cleanups, editing and deleting bookmarks, especially when several devices are involved), you must reset โ€œChrome Syncโ€, or it will return everything to you deleted materials and an additional copy of each changed bookmark: Settings โ†’ Synchronization โ†’ Manage synchronized data โ†’ reset Synchronization

0
source

All Articles