forked from Happy-Ferret/weh
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweh.js
More file actions
39 lines (35 loc) · 1.08 KB
/
weh.js
File metadata and controls
39 lines (35 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
* weh - WebExtensions Helper
*
* @summary workflow and base code for developing WebExtensions browser add-ons
* @author Michel Gutierrez
* @link https://github.com/mi-g/weh
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
exports.browser = require('webextension-polyfill');
var browserType;
if(typeof browser == "undefined" && typeof chrome !== "undefined" && chrome.runtime) {
if(/\bOPR\//.test(navigator.userAgent))
browserType = "opera";
else
browserType = "chrome";
} else if(/\bEdge\//.test(navigator.userAgent))
browserType = "edge";
else
browserType = "firefox";
exports.browserType = browserType;
exports.isBrowser = (...args) => {
for(var i=0; i<args.length; i++)
if(args[i]==exports.browserType)
return true;
return false;
}
exports.error = (err) => {
console.groupCollapsed(err.message);
if(err.stack)
console.error(err.stack);
console.groupEnd();
}