User:Docu/test1.js
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.
Documentation for this user script can be added at User:Docu/test1. |
var functionName = mw.util.getParamValue("function");
function universal_replace() {
if (wgPageName == 'User_talk:CommonsDelinker/commands' || wgPageName == 'User_talk:CommonsDelinker/commands') {
var old_image = mw.util.getParamValue("oldimage").replace(/_/g, ' ');
if ( old_image === null ) {
old_image = prompt('What is the name of the old image (without: "File:")');
}
var new_image = mw.util.getParamValue("newimage").replace(/_/g, ' ');
if ( new_image === null ) {
new_image = prompt('What is the name of the new image (without: "File:")');
}
var reason = mw.util.getParamValue("replace_reason").replace(/_/g, ' ');
if ( reason === null ) {
reason = '';
}
document.editform.wpTextbox1.value += '{{universal replace|' + old_image + '|' + new_image + '|reason=' + reason + '}}';
document.editform.wpSummary.value = 'universal replace: [[:File:' + old_image + ']] → [[:File:' + new_image + ']] (' + reason + ')';
if (typeof window.DelinkerSave == "undefined") {
document.editform.wpDiff.click();
} else {
document.editform.wpSave.click();
}
}
}
function move_cat() {
var oldcat = decodeURI(mw.util.getParamValue("oldcat")).replace(/_/g, ' ');
var newcat = decodeURI(mw.util.getParamValue("newcat")).replace(/_/g, ' ');
if (wgPageName == 'User_talk:CommonsDelinker/commands') {
document.editform.wpTextbox1.value += '{{move cat|' + oldcat + '|' + newcat + '}}';
document.editform.wpSummary.value = 'Adding move cat: [[:Category:' + oldcat + ']] → [[:Category:' + newcat + ']]';
document.editform.wpDiff.click();
}
}
for (var key in wgUserGroups) {
if (wgUserGroups[key] == 'autoconfirmed' && functionName == 'replace') {
$(universal_replace);
} else if (wgUserGroups[key] == 'autoconfirmed' && functionName == 'movecat') {
$(move_cat);
}
}
//</source>