In my Google Chrome Extension I need to copy text onto the Clipboard, and I need to know if my extension is installed on Windows OS or not. Is it possible?
PS. If it is Windows, then I will replace end-lines with "\r\n"
, which makes multi-line text look better on Windows.
Two ways, at least
You can simply rely on
navigator.platform
Better option is to use Chrome API:
chrome.runtime.getPlatformInfo()
:chrome.runtime.getPlatformInfo(function callback)
Returns information about the current platform.
In the form of a PlatformInfo object.
chrome.runtime.getPlatformInfo( function(info) { if(info.os == "win") { /* do stuff */ } });
来源:https://stackoverflow.com/questions/25617688/can-i-tell-if-my-chrome-extension-is-running-on-windows