User:WOSlinker/defaultsort.js
Jump to navigation
Jump to search
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.
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;
}
)}