function getPlatform() {
  let platforms = [
    [/CrOS Touch/, "chromeos touch"],
    [/CrOS/, "chromeos"],
    [/Linux/, "linux"],
    [/Mac/, "mac"],
    [/Win/, "win"],
  ];

  for (let i = 0; i < platforms.length; i++) {
    const regex = new RegExp(platforms[i][0]);
    if (regex.exec(navigator.userAgent)) {
      return platforms[i][1];
    }
  }
  return "unknown";
}
Get current platform.

@returns {"chromeos touch" | "chromeos" | "linux" | "mac" | "win" | "unknown"}