User:Gryllida/js/parseShortCutsInUrlsForMobiles.js
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
/*
Author : Svetlana Tkachenko svetlana@members.fsf.org
Licence: GPLv3+
Description: [beta] takes over URLs that contain special symbols which serve
as typoing shortcuts on mobile devices
See also [[:n:Special:Permalink/4392223#Re_category_redirects]].
!!! ATTENTION !!!
YOU NEED TO EDIT crapInUrlsForMobiles VARIABLE AND POPULATE IT WITH YOUR FAVOURITE SHORTCUTS
OTHERWISE THIS WILL NOT WORK
*/
var pageName = mw.config.get('wgPageName');
var crapInUrlsForMobiles = {
'°' : 'degree'
};
var crapKeys = Object.keys(crapInUrlsForMobiles);
for (i=0; i<crapKeys.length;i++){
var crap = crapKeys[i];
var word = crapInUrlsForMobiles[key];
if(pageName.indexOf(crap)!=-1) {
pageName = pageName.replace(crap, word);
var newUrl = mw.config.get('wgServer') + mw.config.get('wgArticlePath').replace('$1', pageName);
window.location.href = newUrl;
}
}