Skip to content

Instantly share code, notes, and snippets.

@akrizs
Created October 31, 2018 21:14
Show Gist options
  • Save akrizs/c21885dddfaf58242ebfead4984f21c9 to your computer and use it in GitHub Desktop.
Save akrizs/c21885dddfaf58242ebfead4984f21c9 to your computer and use it in GitHub Desktop.
BrowserCheck => Hope to revisit this later...
helpers.bc = {
bx: document.createElement('div'),
st: document.createElement('div').style,
is() {
if (this.safari()) {
return 'Safari';
}
if (this.chrome()) {
return 'Chrome';
}
if (this.firefox()) {
return 'Firefox';
}
if (this.opera()) {
return 'Opera';
}
if (this.vivaldi()) {
return 'Vivaldi';
}
},
safari() {
if (!(window.safari == undefined) && window.navigator.userAgent.includes('Safari') && window.navigator.vendor.includes('Apple')) {
return true
} else {
return false
}
},
chrome() {
if (!(window.chrome.webstore === 'undefined') &&
window.navigator.userAgent.includes('Chrome') &&
!(window.navigator.userAgent.includes('Vivaldi')) &&
!(window.navigator.userAgent.includes('Opera')) &&
window.navigator.vendor.includes('Google') &&
(window.opr === undefined)) {
return true
} else {
return false
}
},
firefox() {
if (window.navigator.userAgent.includes('Firefox') &&
!(window.netscape === 'undefined') &&
!(window.mozPaintCount === 'undefined') && 'MozAppearance' in this.st) {
return true
} else {
return false
}
},
brave() {
},
opera() {
if (window.navigator.userAgent.includes('OPR') &&
!!window.opr.addons) {
return true
} else {
return false
}
},
vivaldi() {
if (window.navigator.userAgent.includes('Vivaldi')) {
return true
} else {
return false
}
},
msedge() {
if (window.style) {
}
},
layoutEngine: {
st: document.createElement('div').style,
is() {
},
webkit() {
if ('WebkitAppearance' in this.st && window.navigator.userAgent.includes('webkit')) {
return true
} else {
return false
}
},
gecko() {
if ('MozAppearance' in this.st && window.navigator.userAgent.includes('Gecko')) {
return true
} else {
return false;
}
},
khtml() {
if ('KhtmlUserInput' in this.st) {
return true
} else {
return false
}
},
edgeHtml() {
if ('msTextSizeAdjust' in this.st && !('msFlex' in this.st) && window.navigator.userAgent.includes('edge')) {
return true
} else {
return false
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment