Skip to content

Instantly share code, notes, and snippets.

@meehow
Created January 10, 2012 17:14
Show Gist options
  • Save meehow/1590070 to your computer and use it in GitHub Desktop.
Save meehow/1590070 to your computer and use it in GitHub Desktop.
var mobile_url = 'http://m.bankier.pl/art/{ID}/';
var desktop_url = /-(\d+)\.html/;
var agent = navigator.userAgent.toLowerCase();
var isUAMobile =!!(agent.match(/(iPhone|iPod|blackberry|android 0.5|htc|lg|midp|mmp|mobile|nokia|opera mini|palm|pocket|psp|sgh|smartphone|symbian|treo mini|Playstation Portable|SonyEricsson|Samsung|MobileExplorer|PalmSource|Benq|Windows Phone|Windows Mobile|IEMobile|Windows CE|Nintendo Wii)/i));
var isUATablet =!!(agent.match(/(iPad|SCH-I800|xoom|kindle)/i));
var page = document.location.pathname.match(desktop_url);
if (page && (isUAMobile || isUATablet)) {
document.location.href = mobile_url.replace(/{ID}/, page[1]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment