Jump to content

User:Aveaoz/AutoMobileRedirect.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
/*
  based on:
  - https://en.wikipedia.org/wiki/User:%C3%9Ejarkur/NeverUseMobileVersion.js
  - https://stackoverflow.com/a/7995898/3286892
*/
if (window.location.href.match(/^https?:\/\/[^.]+\.m\./)) {
    var isMobile = navigator.userAgent.match(/(iPad)|(iPhone)|(iPod)|(android)|(webOS)/i);
    var desktopUrl = $('#mw-mf-display-toggle').attr('href');
    if (!isMobile && desktopUrl) {
        window.location.href = desktopUrl;
    }
}