Jump to content

User:PrimeHunter/Mobile view.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.
/* Add a "Mobile view" sidebar link to switch to the mobile version.
   The bottom of desktop pages already have such a link but
   it may be hard to activate for some.
   Install with this in your [[Special:MyPage/common.js]]:

   importScript('User:PrimeHunter/Mobile view.js'); // Linkback: [[User:PrimeHunter/Mobile view.js]]
*/

$( document ).ready( function() {
  mw.util.addPortletLink(
    'p-tb',
    location.href.replace( location.hash, '' ) + ( location.search ? '&' : '?' )
    + 'mobileaction=toggle_view_mobile',
    'Mobile view',
    't-mobileview',
    'Switch to the mobile version'
  );
});