自动安装 google chrome 扩展程序不起作用!

发布于 2024-11-05 06:13:13 字数 1626 浏览 1 评论 0原文

我正在从事与此页面相关的工作

我编写了一个 NSIS 脚本,尝试自动安装 chrome 扩展。 (为什么?因为我们的扩展可以通过复选框与另一个产品安装流程一起提供,那么如果用户选择要添加我们的扩展,它将使用 NSIS 静默安装自动安装在用户 chrome 浏览器上)

我尝试了很多场景并且我需要帮助,在谷歌网站上,他们说你可以这样做

  • 使用首选项 JSON 文件
  • 使用 Windows 注册表

他们还说“使用首选项文件”有一个错误(Windows 注意:在错误 41902 修复之前,你可能想要使用 Windows 注册表而不是首选项文件。)

提醒: 自动安装的扩展被称为外部扩展

  • 所以我尝试“使用 Windows 注册表”

要通过注册表添加 google chrome 扩展:

  • 添加此键:“HKEY_LOCAL_MACHINE\SOFTWARE\Google\Chrome\Extensions(我的扩展 id)”
  • 添加“路径”与 .crx 的路径
  • 添加“版本”与扩展版本

这是我尝试过的(使用 NSIS 脚本):

  • 如果我添加注册表项 它将安装扩展程序,但如果用户手动卸载,chrome 会打开黑名单标志,并且无法使用任何其他脚本重新安装扩展程序。剩下的唯一方法是用户手动安装。最糟糕的是,如果用户手动安装并手动卸载(它将关闭黑名单标志),并且当 chrome 重新启动时,它将自动重新安装扩展(无需任何用户操作),因为注册表项仍然存在。

  • 我在启动或关闭浏览器时通过一种奇怪的方式(使用 crx 中的 dll(NPAPI))删除注册表项,则 Chrome 会在浏览器重新启动时自动删除扩展目录。

  • 如果我在用户卸载扩展时设法删除注册表项。我们被列入黑名单,因此自动安装程序将不再工作,直到用户通过手动安装和卸载扩展来关闭黑名单标志。

  • 如果我在“C:\Users\(用户名)\AppData\Local\Google\Chrome\User Data\Default\Extensions\(extensionID)\(version)_0\(”中创建目录我的文件在这里)”,我遇到了很多麻烦,因为 chrome 会在重新启动浏览器后立即删除我的文件。

有没有人遇到过这个问题,需要做什么。 我将尝试使用 JSON 文件,但在错误未修复之前,注册表是唯一的方法。

感谢所有有时间阅读这一切的人! 任何帮助将不胜感激,谢谢!

I am working on a job in relation with this page

I wrote a NSIS script that is trying to auto install a chrome extensions.
(Why ? because our extension can be offered with another product installation flow through a checkbox, then if user select our extension to be added, it will auto-install on the user chrome browser using NSIS silent installation)

I tried a lot of scenario and I need help, on google website, they say you can do this

  • Using a preferences JSON file
  • Using the Windows registry

They also say that "Using a preferences file" has a bug (Windows note: Until bug 41902 is fixed, you might want to use the Windows registry instead of the preferences file.)

Reminder:
An extension that's installed automatically is known as an external extension

  • So I tried "Using the Windows registry"

To add a google chrome extensions through registry:

  • add this key: "HKEY_LOCAL_MACHINE\SOFTWARE\Google\Chrome\Extensions(my extension id)"
  • add "path" with the path to a .crx
  • add "version" with the version of the extension

This is what I tried (using NSIS script):

  • If I Add a registry key
    It will install the extension, BUT if user uninstall manually, chrome turns the blacklist flag on and the extension can't be reinstalled with any other script. The only way left is that user installs, manually. Worst, if user install manually and uninstall manually (it will turn the blacklist flag off), and when chrome will be restarted, it will reinstall the extensions automatically (without any user action) since the registry key is still there.

  • If I remove the registry key when we start or close the browser, through a freaky way (using a dll(NPAPI) within the crx), chrome will auto-delete the extensions directory when browser restarts.

  • If I manage to delete the registry key when user uninstall the extension. We get blacklisted, so the auto-installer won't work anymore until user turn blacklist flag off by manually installing&uninstalling the extension.

  • If I create the directory in "C:\Users\(username)\AppData\Local\Google\Chrome\User Data\Default\Extensions\(extensionID)\(version)_0\(my files here)", I run into a lot of trouble because chrome will delete my files as soon as it restarts the browser.

Does anyone have run into this problem, and what has to be done.
I will try with the JSON file but until bug isn't fixed, Registry is the only way.

Thank for anyone who had the time to read all this !
Any help will be appreciated, thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

春庭雪 2024-11-12 06:13:13

[2013-11-11]
[这个问题的答案即将过时,所以这里有一个更新的答案。]


根据 Chromium 博客上的最新帖子,在不久的将来,自动安装 Chrome 扩展程序将不再是一个选项:

从 [2014 年]1 月开始,在 Windows 稳定版和 Beta 版渠道上,我们将要求所有扩展程序都托管在 Chrome 网上应用店中。

作为替代方案,开发人员和供应商将能够使用内联安装功能:

如果您的扩展程序当前托管在 Chrome 网上应用店之外,您应该尽快迁移它们。这不会对您的用户产生影响,他们仍然可以使用您的扩展程序,就像没有发生任何变化一样。如果您愿意,您可以将扩展程序从 Web Store 列表中隐藏起来。如果您在自己的网站上有专用的安装流程,则可以利用现有的内联安装功能。


因此,基本上,您需要做的是:

  1. 在 Chrome Web Store 上托管您的扩展程序(可以选择将其从列表中隐藏)。
  2. 让安装人员打开指向您网站上网页的 Chrome 浏览器窗口。
  3. 该页面上包含用户启动扩展安装过程所需的所有信息和数据。 (这里的关键概念是用户必须启动安装过程,例如通过单击按钮。

内联安装如何工作:

您想要进行内联安装的站点上的 HTML 页面必须在引用用户可以安装的项目的部分中包含一个或多个标记。每个标签必须具有以下格式:

<link rel="chrome-webstore-item" href="https://chrome.google.com/webstore/detail/itemID">

要真正开始内联安装,必须调用 chrome.webstore.install(url, successCallback, failureCallback) 函数。 此函数只能在响应用户手势时调用,例如在单击事件处理程序中;如果不是,则会抛出异常。

(强调我的)

有关内联安装功能<的详细信息/强>。

[2013-11-11]
[The answers to this question are about to become outdated, so here is a more up-to-date answer.]


According to a recent post on the Chromium Blog, auto-installing a Chrome Extension won't be an option in the near future:

Starting in January [2014] on the Windows stable and beta channels, we’ll require all extensions to be hosted in the Chrome Web Store.

As an alternative, developers and vendors will be able to use the inline installation feature:

If your extensions are currently hosted outside the Chrome Web Store you should migrate them as soon as possible. There will be no impact to your users, who will still be able to use your extension as if nothing changed. You could keep the extensions hidden from the Web Store listings if you like. And if you have a dedicated installation flow from your own website, you can make use of the existing inline installs feature.


So, basically, what you need to do is:

  1. Host your extension on the Chrome Web Store (optionaly keeping it hidden from the listings).
  2. Have your installer open a Chrome browser window pointing to a webpage on your site.
  3. On that page have all necessary info and data for the user to initiate the extention's installation process. (The key concept here is that the user has to initiate the installation process, e.g. by clicking a button.

How does inline installation work:

The HTML page on your site from which you want inline installation to occur must contain one or more tags in the section referencing the items that the user can install. Each tag must have the following format:

<link rel="chrome-webstore-item" href="https://chrome.google.com/webstore/detail/itemID">

To actually begin inline installation, the chrome.webstore.install(url, successCallback, failureCallback) function must be called. This function can only be called in response to a user gesture, for example within a click event handler; an exception will be thrown if it is not.

(emphasis mine)

More info on the inline installs feature.

那伤。 2024-11-12 06:13:13

有一种更简单的方法...单击该复选框后,从后台页面运行此代码:

chrome.tabs.create({ url:"FILEPATH.crx" } );

您要安装的预期扩展(.crx 文件)可以托管在网络上,也可以托管在可以位于您的原始扩展文件夹中...您将需要 manifest 中的 tabs 权限

There is an easier way... When the checkbox is clicked, run this code from the background page:

chrome.tabs.create({ url:"FILEPATH.crx" } );

The intended extension you want to install, (.crx file) can either be hosted on the net or can be inside your original extension folder... You will need tabs permission in your manifest

过期情话 2024-11-12 06:13:13

“Windows 应用程序开发人员应要求用户从 Chrome 中安装 Chrome 扩展程序。允许用户安装与您的 Windows 应用程序相关的 Chrome 扩展程序的一个好方法是将用户链接到您的网站并使用 内联安装。"

另请参阅完整的博客文章

"Windows application developers should ask users to install Chrome extensions from within Chrome. A great way to allow users to install a Chrome extension related to your Windows application is to link users to your website and use inline installation."

also see full blog post

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文