get os info

获取系统名称,浏览器名称

Dieses Skript sollte nicht direkt installiert werden. Es handelt sich hier um eine Bibliothek für andere Skripte, welche über folgenden Befehl in den Metadaten eines Skriptes eingebunden wird // @require https://update.greasyfork.org/scripts/407021/826356/get%20os%20info.js

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         get os info
// @name:zh-CN   获取系统浏览器信息
// @namespace    https://github.com/jackdizhu
// @version      0.2.1
// @description:zh-CN  获取系统名称,浏览器名称
// @description:en     get os name, get browser name
// @author       jackdizhu
// @match        *
// @include      *
// @grant        none
// @run-at       document-start
// @updateURL    https://greasyfork.org/scripts/407021-get-os-info/code/get%20os%20info.user.js
// ==/UserScript==

(function() {
  'use strict';
  let platform = navigator.platform.toLowerCase()
  let os = {
    Mac: platform.indexOf('mac') !== -1,
    Windows: platform.indexOf('win') !== -1
  }
  
  let UserAgent = navigator.userAgent.toLowerCase();
  let isBrowserName = {
      IE: window.ActiveXObject || "ActiveXObject" in window,
      Chrome: UserAgent.indexOf('chrome') > -1 && UserAgent.indexOf('safari') > -1,
      Firefox: UserAgent.indexOf('firefox') > -1,
      Opera: UserAgent.indexOf('opera') > -1,
      Safari: UserAgent.indexOf('safari') > -1 && UserAgent.indexOf('chrome') == -1,
      Edge: UserAgent.indexOf('edge') > -1,
      QQBrowser: /qqbrowser/.test(UserAgent),
      WeixinBrowser: /MicroMessenger/i.test(UserAgent),
  }
  
  window.$os = os
  window.$isBrowserName = isBrowserName
})();