Skip to content

Instantly share code, notes, and snippets.

@asadowski10
Last active August 29, 2015 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asadowski10/ad1eb542ea5662b9b0d8 to your computer and use it in GitHub Desktop.
Save asadowski10/ad1eb542ea5662b9b0d8 to your computer and use it in GitHub Desktop.
JQUERY SMARTBANNER - Fix user agent for webview of Facebook / Twitter
if (this.options.force ) {
this.type = this.options.force;
} else if ( null != n.match(/Windows Phone 8/i) && null !== n.match(/Touch/i) ){
this.type = "windows";
} else if( null != n.match(/iPhone|iPod/i) || n.match(/iPad/) && this.options.iOSUniversalApp ){
if( null != n.match(/Safari/i) && (null != n.match(/CriOS/i) || window.Number(n.substr(n.indexOf("OS ") + 3, 3).replace("_", ".")) < 6) ){
this.type = "ios"; //Only Chrome iOS
}else if( null != n.match(/FBAV/i) || ( null == n.match(/Safari/i) && null != n.match(/Mobile/i) ) ){
this.type = "ios"; //Only webview Facebook / Twitter
}
} else if( n.match(/\bSilk\/(.*\bMobile Safari\b)?/) || n.match(/\bKF\w/) || n.match("Kindle Fire") ){
this.type = "kindle";
} else if( null != n.match(/Android/i) && (this.type = "android"), console.log("US", n), console.log("type", this.type), !this.type || i || this.getCookie("sb-closed") || this.getCookie("sb-installed") ){
return void console.log("donotshow", this.getCookie("sb-closed"));
}
@mattpramschufer
Copy link

Thanks for the snippet! I am incorporating into next version of SmartBanners Wordpress Plugin. I did have to go through and replace n.match with UA.match and then removed your || i || in the last line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment