从外部程序操作 Google Chrome 书签(并让 Chrome 感知)?
外部程序是否有任何记录的方法来操作 Google Chrome 书签?
书签存储在用户 data\default 目录中的“Bookmarks”文件中,看起来像 JSon 或其他东西(现在这并不重要)。
但是,有什么方法可以通知 Chrome 文件已更改吗?
注意:这是针对 Windows 的,我正在寻找一种以编程方式让 Chrome 意识到我的更改的方法。
我尝试了以下操作:
- 手动编辑文件
- 重新启动 Chrome
更改已经存在,但在我重新启动 Chrome 之前,Chrome 并不知道我的更改,并且我强烈认为,如果我在重新启动之前编辑 Chrome 内的书签,外部更改就会丢失。
那么,我有办法做到这一点吗?或者我是否必须通知用户不幸的是我必须关闭他的 Chrome 安装,编辑书签文件,然后重新启动 Chrome?
代码最终将用 C# 编写,但除非您拥有/知道执行此操作的代码,否则执行此操作的方法可能应该与语言/运行时无关。
另请注意,我当前想要自动化的操作列表是:
- 为某些特定书签创建一个文件夹
- 删除该文件夹中的现有书签 向该文件
- 夹添加新书签 该
程序的目的是自动设置 Web 应用程序的本地副本我们制作,支持/测试人员可以运行程序,选择要设置的程序版本以及将其连接到哪个数据库,然后程序会自动执行所有操作。我希望这个程序也能轻松访问应用程序。
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:
- Edit the file manually
- 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:
- Create a folder for some specific bookmarks
- Delete existing bookmarks in that folder
- 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
%LOCALAPPDATA%\Google\Chrome\User Data\Default\Bookmarks
文件受写入错误校验和保护。 Google Chrome 将此文件备份为Bookmarks.bak
。因此,如果Bookmarks
文件损坏,Google Chome 将使用备份文件来恢复书签。校验和操作有点棘手。您可以查看它的源(因为 Chromium 项目是开源的)。看来Chrome会对每个书签进行MD5计算:
id
title
folder
url
所以你可以看看此源代码以进行进一步调查。
但我不建议这样做。 Google 可能会更改此格式,恕不另行通知,并且您的软件会遇到不兼容问题。最好编写一个 Google Chrome 扩展并与您的桌面软件进行互操作。
%LOCALAPPDATA%\Google\Chrome\User Data\Default\Bookmarks
file is protected by a checksum for writing errors. Google Chrome make a backup of this file asBookmarks.bak
. So ifBookmarks
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.