2017-10-02 23:30:40 +02:00
|
|
|
var _bd_usebrowser = "firefox";
|
|
|
|
|
2018-08-07 23:31:28 +02:00
|
|
|
var _bd_isFirefox = true;
|
2018-01-17 20:57:24 +01:00
|
|
|
var _bd_isChrome = false;
|
2018-05-26 23:08:49 +02:00
|
|
|
var _bd_isEdge = false; // we'll see if FF
|
2018-01-17 20:57:24 +01:00
|
|
|
|
|
|
|
try{
|
2018-08-07 23:31:28 +02:00
|
|
|
// todo: find something that works in firefox but not in edge (or vice-versa)
|
|
|
|
// note that this function returns a promise! and is broken for some reason
|
2018-07-16 22:30:52 +02:00
|
|
|
var browserinfo = browser.runtime.getBrowserInfo();
|
|
|
|
|
|
|
|
// we don't need to actually check because only firefox supports that.
|
|
|
|
// if we're not on firefox, the above call will probably throw an exception anyway.
|
|
|
|
// if browsers other than firefox start supporting that, well ... we'll also need to actually await for promise
|
|
|
|
// that getBrowserInfo() returns to resolve.
|
|
|
|
|
|
|
|
// if (Browser.name.toLowerCase().indexOf(firefox) !== -1 || Browser.vendor.toLowerCase().indexOf(mozilla) !== -1) {
|
|
|
|
_bd_isFirefox = true;
|
|
|
|
_bd_isEdge = false;
|
|
|
|
// }
|
|
|
|
|
2018-01-17 20:57:24 +01:00
|
|
|
}
|
2018-07-16 22:30:52 +02:00
|
|
|
catch (e) {
|
|
|
|
if(Debug.debug) {
|
|
|
|
console.info("[BrowserDetect] browser.runtime.getBrowserInfo() probably failed. This means we're probably not using firefox.", e)
|
|
|
|
}
|
|
|
|
};
|
2018-01-17 20:57:24 +01:00
|
|
|
|
|
|
|
if(typeof browser === "undefined"){ // This is a good sign we're in chrome or chromium-based browsers
|
2017-10-02 23:30:40 +02:00
|
|
|
if(chrome){
|
|
|
|
browser = chrome;
|
2018-01-18 00:11:03 +01:00
|
|
|
_bd_usebrowser = "chrome";
|
2018-01-17 20:57:24 +01:00
|
|
|
_bd_isChrome = true;
|
|
|
|
_bd_isEdge = false;
|
2018-07-16 22:30:52 +02:00
|
|
|
_bd_isFirefox = false;
|
2017-10-02 23:30:40 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var BrowserDetect = {
|
2018-01-17 20:57:24 +01:00
|
|
|
usebrowser: _bd_usebrowser,
|
|
|
|
firefox: _bd_isFirefox,
|
|
|
|
chrome: _bd_isChrome,
|
|
|
|
edge: _bd_isEdge
|
2017-10-02 23:30:40 +02:00
|
|
|
}
|
2018-05-26 23:08:49 +02:00
|
|
|
|
|
|
|
if(Debug.debug){
|
|
|
|
console.log("BrowserDetect loaded! Here's BrowserDetect object:", BrowserDetect)
|
|
|
|
}
|