this post was submitted on 11 Jul 2023
3 points (100.0% liked)

Wikipedia

1367 readers
129 users here now

A place to share interesting articles from Wikipedia.

Rules:

Recommended:

founded 1 year ago
MODERATORS
 

I recently discovered this:

  1. Create an account
  2. Go to your common.js page
  3. Paste in the following and save:

mw.loader.load( "https://en.wikipedia.org/w/index.php?title=User:%C3%9Ejarkur/NeverUseMobileVersion.js&action=raw&ctype=text/javascript" );

See the script page for more info.

And voilà! Wikipedia will now redirect you to the desktop site if ever you land on the mobile version of Wikipedia, so long as you're logged in.

top 2 comments
sorted by: hot top controversial new old
[–] duroth 2 points 1 year ago

Be careful though; the code actually loads a different script that's been posted by a Wikipedia user, not Wikipedia itself. You can view the script here, and do heed the warning at the top:

Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page.

Never run/execute code that you haven't verified yourself. Also, keep in mind that while the code might be trusted now, because you're including code from a wikipedia page that might be changed at any one moment, you can't be sure the page won't serve you malware tomorrow. So instead of using the code above, it's safer to use the code below (which is just a copy-paste of the actual script, and therefore can not be changed by other people):

/*
  Force Wikipedia to use the desktop version.
  Google on mobile uses "en.m.wikipedia.org", this scripts redirects to the normal version.
  
  CC0
*/
if(window.location.href.match(/^https?:\/\/[^.]+\.m\./)) {
  var desktopUrl = $('#mw-mf-display-toggle').attr('href')
  if(desktopUrl) {
  	window.location.href = desktopUrl
  }
}
[–] lazycouchpotato 2 points 1 year ago

Any idea why they don't automatically redirect you to the non-mobile version on desktop based on your user-agent string? They have no problem doing the inverse on mobile.