Skip to content

Instantly share code, notes, and snippets.

@alastaircoote
Created February 17, 2015 19:44
Show Gist options
  • Save alastaircoote/f3a77d946e7e5df2ebaf to your computer and use it in GitHub Desktop.
Save alastaircoote/f3a77d946e7e5df2ebaf to your computer and use it in GitHub Desktop.
var webviewProvider = (function() {
if (/\/FBIOS/i.test(navigator.userAgent) === true) {
return 'facebook';
}
if (/Twitter for/i.test(navigator.userAgent) === true) {
return 'twitter';
}
if (/Pinterest\//.test(navigator.userAgent) === true) {
return 'pinterest';
}
if (/\/\/t.co\//i.test(document.referrer) === true && /Safari\//.test(navigator.userAgent) === false) {
return 'twitter';
}
if (/tumblr.com\//i.test(document.referrer) === true && /Safari\//.test(navigator.userAgent) === false) {
return 'tumblr';
}
return null;
})();
if (webviewProvider !== null) {
document.body.classList.add(webviewProvider);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment