I've seen that there are user scripts that Wikipedia users can add to their user profiles. Is there a way to add detect whether the mobile is active and redirect to the desktop version this way?

3 Answers 3


My solution uses a feature of MediaWiki, which allows you to load custom JavaScript into all visited pages while you're logged in. To use it, create an account, navigate to the Appearance section of your preferences and click on Custom JavaScript for Shared CSS/JavaScript for all skins. Paste the following script into the editor there:

(function () {
     // Find the link used to switch to the desktop view.
     var desktopLink = document.getElementById("mw-mf-display-toggle");

     if (desktopLink === null) {

     var href = desktopLink.getAttribute('href')

     // Make sure we're not already in the desktop view, which could lead to
     // an infinite loop.
     if (href.indexOf('.m.') > -1) {

     // Navigate to the new URL, replacing the history element, as if we were
     // never on the mobile site! You can use .assign() instead, if you want to
     // keep the URL of the mobile site in your history.

When the mobile version of a page is loaded, it will look for the Desktop link at the bottom of the page and navigate to the linked URL.

Note: Make sure to switch to the desktop version when you log in to your account on your phone. Only then will it allow you to choose Keep me logged in (for up to 365 days).


Simply scroll down to the bottom of the page and click "Desktop".

footer at bottom of Wikipedia mobile

I think you'll find that most sites with mobile versions, especially those that auto-detect mobile browsers, have such a feature (including Stack Exchange).

  • It does not seem to save that preference though. Does it for you?
    – Lenar Hoyt
    Commented Aug 14, 2016 at 15:48
  • I'm surprised it doesn't set a cookie for future visits.
    – ale
    Commented Aug 14, 2016 at 16:00

I'm a developer on the Wikimedia mobile site.

If you use the desktop link at the bottom of the page and have cookies enabled this should bypass Varnish and in future visits you should land on the desktop site (see https://en.wikipedia.org/wiki/Wikipedia:Enable_mobile_version).

There are various Chrome/Firefox extensions that will also do this for you if you are looking for something which does not rely on cookies. e.g. https://chrome.google.com/webstore/detail/mobile2desktop-wikipedia/hgdfjjhaahfdggnecdecjekkimepkpaf?hl=en

  • shouldn't this be at the top of the page? scroll all the way down to switch is wasted effort.
    – marathon
    Commented Aug 14, 2021 at 14:56
  • This has never worked for me and, as of now, still doesn't work. When browsing Wikipedia I see the mobile version being loaded before the script from my answer redirects me to the desktop version multiple times per day, e.g. when following a link from Google. I have cookies enabled, otherwise my script would not work because I need to be logged in for it to work. Commented Jan 23 at 15:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.