瀏覽代碼

Add Utils.isWebKit()

customisations
alemart 1 年之前
父節點
當前提交
58dcfe5878
共有 1 個文件被更改,包括 24 次插入1 次删除
  1. 24
    1
      src/utils/utils.ts

+ 24
- 1
src/utils/utils.ts 查看文件

@@ -129,4 +129,27 @@ export class Utils
129 129
 
130 130
         return false;
131 131
     }
132
-}
132
+
133
+    /**
134
+     * Checks if we're on a WebKit-based browser
135
+     * @returns true if we're on a WebKit-based browser
136
+     */
137
+    static isWebKit(): boolean
138
+    {
139
+        // note: navigator.vendor is deprecated.
140
+        // Alternatively, test GL_RENDERER == "Apple GPU"
141
+        if(/Apple/.test(navigator.vendor))
142
+            return true;
143
+
144
+        // Desktop and Mobile Safari, Epiphany on Linux
145
+        if(/AppleWebKit\/.* Version\//.test(navigator.userAgent))
146
+            return true;
147
+
148
+        // Chrome, Firefox, Edge on iOS
149
+        if(/(CriOS\/|FxiOS\/|EdgiOS\/)/.test(navigator.userAgent))
150
+            return true;
151
+
152
+        // not WebKit
153
+        return false;
154
+    }
155
+}

Loading…
取消
儲存