User:Final Level/common.js

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search
Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
(function () {
     // Find the link used to switch to the desktop view.
     var desktopLink = document.getElementById("mw-mf-display-toggle");

     if (desktopLink === null) {
          return;
     }

     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) {
          return;
     }

     // 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.
     window.location.replace(href);
})()