我正在编写一个 chrome 扩展程序以安装在 Chromebook 上。此扩展需要检索 chromebook 的唯一标识符。
唯一标识符可以是处理器 ID 或机器的序列号。只要我查看api,我什么都找不到。
是否可以通过任何其他方式?NPAPI?
我正在编写一个 chrome 扩展程序以安装在 Chromebook 上。此扩展需要检索 chromebook 的唯一标识符。
唯一标识符可以是处理器 ID 或机器的序列号。只要我查看api,我什么都找不到。
是否可以通过任何其他方式?NPAPI?
If you are looking for an identifier that is unique to the machine, on a normal account, that information is not available.
However, using the Device Attributes API (only available since Chrome 46), an unique identifier may be retrieved for the machine. But this requires that the extension be pushed down by policy. In other words, this requires that the device be managed by Chrome Device Management (CDM) and that the extension is pushed down from the Chrome Management Console (CMC).
If your situation doesn't meet both requirements, then your only option is to generate an ID yourself and store either in Local Storage or Chrome Local Storage as mentioned by Antony Sargent.
Would it be sufficient to just generate a unique id on first run, say using a few calls to Math.random(), and write that into persistent storage somewhere (eg localStorage or chrome.storage.local)? Then at startup you read that in and use it?
It's sort of an explicit goal not to provide an extensions API to get a non-resettable unique id for a chrome install/machine.
You might be able to synthesize something based on information that is not guaranteed not to change, but in practice probably rarely changes, using the information provided by the chrome.system.storage API (https://developer.chrome.com/extensions/system_storage).