从外部程序操作Google Chrome书签(并使Chrome可识别)? [英] Manipulating Google Chrome bookmarks from external program (and make Chrome aware)?

查看:357
本文介绍了从外部程序操作Google Chrome书签(并使Chrome可识别)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



书签存储在用户数据的书签文件中默认目录,看起来像JSon或我的东西(现在不重要)。

然而,有什么方法可以告诉Chrome浏览器文件已更改吗?



注意:这是针对Windows的,我正在寻找一种以编程方式让Chrome了解我的更改的方法。 b
$ b

我尝试了以下操作:


  1. 手动编辑文件

  2. 重新启动Chrome

所做的更改都存在,但在重新启动Chrome之前,Chrome并未意识到我所做的更改,如果我在重新启动之前编辑Chrome内部的书签,则外部更改将丢失。

所以,我有没有办法做到这一点?或者我必须通知用户,不幸的是我必须关闭他的Chrome安装,编辑书签文件,然后重新启动Chrome?



代码最终会用C#编写,但除非你知道这样做的代码,否则它的方式应该是语言/运行时不可知的。

另外请注意,我的当前我想要自动化的事物清单如下:


  1. 为某些特定书签创建文件夹

  2. 删除该文件夹中的现有书签

  3. 向该文件夹添加新书签



  4. 这个程序将自动设置我们制作的Web应用程序的本地副本,其中支持/测试人员可以运行程序,选择要设置的程序版本以及将其连接到哪个数据库,然后该程序将自动化所有内容。我希望这个程序能够轻松访问应用程序。

    解决方案

    %LOCALAPPDATA %\Google\Chrome\UserData\Default\Bookmarks 文件受写入错误的校验和保护。 Google Chrome会将此文件备份为 Bookmarks.bak 。因此,如果书签文件损坏,Google Chome会使用备份文件恢复书签。

    校验和操作有点棘手。你可以看看它是(因为Chromium项目是开源的)。看起来,Chrome对每个书签都进行了MD5计算: >

  5. title

  6. 文件夹

  7. url



  8. a href =https://src.chromium.org/viewvc/chrome/trunk/src/components/bookmarks/browser/bookmark_codec.cc =noreferrer>此源代码以供进一步调查。



    但我不建议这样做。 Google可能会在没有任何通知的情况下更改此格式,并且您的软件会遇到不兼容问题。最好是编写Google Chrome浏览器扩展程序,并与桌面软件进行互操作。

    Is there any documented way for an external program to manipulate the Google Chrome bookmarks?

    The bookmarks are stored in a "Bookmarks" file in the user data\default directory, looks like JSon or something to me (that's not important right now.)

    However, is there any way I can inform Chrome that the file has changed?

    Note: This is for Windows, and I'm looking for a way to programmatically make Chrome aware of my changes.

    I tried the following:

    1. Edit the file manually
    2. Restart Chrome

    The changes were present, but until I restarted Chrome, Chrome was not aware of my changes, and I assume strongly that if I edit the bookmarks inside Chrome before restarting, the external changes are lost.

    So, is there a way for me to do this? Or do I have to just inform the user that unfortunately I have to close his Chrome installation, edit the bookmark file, and then restart Chrome?

    The code is ultimately going to be written in C#, but unless you have/know of code that does this, the way to go about it should probably be language/runtime agnostic.

    Also note that my current list of things that I want to automate are:

    1. Create a folder for some specific bookmarks
    2. Delete existing bookmarks in that folder
    3. Add new bookmarks to that folder

    The purpose of this program is to automate setting up local copies of a web application we make, where support/testers can just run the program, pick the version of the program to set up and which database to connect it to, and then the program automates everything. I'd like for this program to add easy access to the applications as well.

    解决方案

    %LOCALAPPDATA%\Google\Chrome\User Data\Default\Bookmarks file is protected by a checksum for writing errors. Google Chrome make a backup of this file as Bookmarks.bak. So if Bookmarks file is corrupt, Google Chome uses backup file for restoring bookmarks.

    Checksum operation is a bit tricky. You can look at it's source (as Chromium project is open source). It seems that Chrome does MD5 calculation on every bookmark's:

    • id
    • title
    • folder
    • url

    So you can look this source code for investigate further.

    But i do not recommend to do this. Google may change this format without any notice and your software suffers incompatibility problems. It would be better to write an Google Chrome extension and interoperate with your desktop software.

    这篇关于从外部程序操作Google Chrome书签(并使Chrome可识别)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆