User:WOSlinker/defaultsort.js

function ds_queryString(p) { var re = RegExp('[&?]' + p + '=([^&]*)'); var matches; if (matches = re.exec(document.location)) { try { return decodeURI(matches[1]); } catch (e) { } }   return null; } //Add a 'ds edit' tab if(wgNamespaceNumber == 0 && wgArticleId != 0 ) { addOnloadHook( function dsEditButton {       mw.util.addPortletLink('p-cactions', wgScript + '?title=' + encodeURIComponent(mw.config.get('wgPageName')) + '&action=edit&ds=true', 'defaultsort', 'p-defaultsort', 'defaultsort edit');   } )} if(wgAction == 'edit' && ds_queryString('ds') == 'true') { addOnloadHook(function ds {       var myContent = document.getElementById('wpTextbox1').value;        myContent = myContent.replace(/\{\{DEFAULTSORT\|/,'{{DEFAULTSORT:');        document.getElementById('wpTextbox1').value=myContent;        document.getElementById('wpSummary').value='fix DEFAULTSORT';        document.getElementById('wpMinoredit').checked = true;    } )}