简体   繁体   English

如何使用本地脚本编写用于chrome扩展的配置文件

[英]How to write a configuration file for chrome extension using a local script

I have a chrome extension (intended to be used by companies internally) that needs to have user specific configurations but I want to avoid the user having to do all that and have a sysadmin configure those things for them via a script. 我有一个chrome扩展程序(打算供公司内部使用),它需要具有用户特定的配置,但我想避免用户必须做所有这些事情,而要让sysadmin通过脚本为他们配置这些东西。

EDIT: Basically, I just need to read from a file that sysadmin can write. 编辑:基本上,我只需要从sysadmin可以写入的文件中读取。

Is this in any way possible? 这有可能吗?

Assuming you have an enterprise install, you can use chrome.storage.managed (which can be easily controlled from a central location) to hold those preferences. 假设您已安装企业版,则可以使用chrome.storage.managed (可从中央位置轻松控制)来保存这些首选项。

See Configuring Apps and Extensions by Policy for a detailed, per-OS explanation. 有关按操作系统的详细说明,请参阅按策略配置应用和扩展


If an enterprise managed storage is not an option, perhaps a better one would be to have a configuration file available somewhere on an internal web server. 如果不能选择企业托管存储,则可能更好的选择是在内部Web服务器上的某个位置提供配置文件。 The extension can then retrieve that pre-defined URL and configure itself accordingly. 然后,扩展可以检索该预定义的URL并进行相应的配置。

You can differentiate between computers automatically using IP/MAC address information accessible by the server processing the request, of you can pass some query parameters yourself. 您可以使用处理请求的服务器可访问的IP / MAC地址信息自动区分计算机,也可以自己传递一些查询参数。

You have two solutions. 您有两种解决方案。

First one is to ask your sysadmin to properly locate chrome's extension folder on all platforms, and edit a file in there. 第一个是要求您的系统管理员在所有平台上正确找到chrome的扩展文件夹,并在其中编辑文件。 It might be a bit complicated if all computers at your company are not the same or use different platforms. 如果公司中的所有计算机都不相同或使用不同的平台,可能会有些复杂。

See: Where to find extensions installed folder for Google Chrome on Mac? 请参阅: 在哪里可以找到Mac上Google Chrome浏览器的扩展程序安装文件夹?

The second one, is simply to ask for the file:///* permission when you install the extension. 第二个,只是在安装扩展时要求file:/// *许可。

It will allow your extension to read files on the whole hard drive, and load the configuration file on a predetermined place. 它将允许您的扩展程序读取整个硬盘上的文件,并将配置文件加载到预定位置。

Here is a related question: Chrome plugin reading text file on hard drive and replacing textbox content 这是一个相关的问题: Chrome插件读取硬盘上的文本文件并替换文本框内容

edit: for the second solution to work, you need your users to enable "Allow access to file URLs" in chrome's config (not sure you can do that automatically) 编辑:为使第二个解决方案起作用,您需要您的用户在chrome的配置中启用“允许访问文件URL”(不确定您可以自动执行此操作)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在控制台中编写脚本以扩展Chrome - How to write script in console in making chrome extension 如何在 Chrome 扩展中使用内容脚本文件注入 CSS? - How to inject CSS using content script file in Chrome extension? Chrome扩展程序:内容脚本无法将本地HTML文件加载到iframe中 - Chrome Extension: content script is unable to load local HTML file into iframe 如何使用脚本在chrome扩展中填充表格 - How to populate table in chrome extension using script 重定向到chrome扩展名中的本地文件 - Redirect to local file in chrome extension Chrome扩展程序 - 写入其他域的本地存储 - Chrome extension - Write to local storage of a different domain 使用iframe通过Chrome扩展程序将本地HTML文件注入网页? - Inject local HTML file into webpage via Chrome Extension using iframe? Chrome 扩展:如何将本地 HTML 文件转换为 URL 以显示? - Chrome Extension: How to convert a local HTML file into a URL to display? 我应该读写XML文件以将数据保存在本地Chrome扩展程序中吗? - Should I read/write a XML file to save data in a local Chrome extension? 如何从 chrome 扩展中的内容脚本中获取另一个文件内容 - How to get another file content from content script in chrome extension
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM