User:Mattflaschen/easyMoveConfirm.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:Mattflaschen/easyMoveConfirm. |
- Report page listing warnings and errors.
<!----><pre>
/*
If you are [[Commons:MediaMoveBot/CheckPage|listed]] as a user trusted to confirm moves,
this script will allow you to do so in a single click. Use it carefully and only on
appropriate moves. You will be held accountable for moves you approve. Confirming if
you are not on the list will have no effect; a bot will simply revert you.
To install, put:
// [[User:Superm401/easyMoveConfirm.js]]
importScript("User:Superm401/easyMoveConfirm.js");
in your monobook. Then, simply click Confirm rename on the left of any image page to confirm
the rename. This will automatically bring you to the edit page, change rename needs
confirmation to rename media, then save with an appropriate edit summary.
If there is not a valid requested target, you will be brought to the edit page, but no modifications
will be made and the page will not be saved.
*/
// [[Category:User scripts|easyMoveConfirm]]
function addConfirmOption()
{
mw.util.addPortletLink("p-tb", mw.config.get('wgServer') + mw.config.get('wgScript') + "?title=" + wgPageName + "&action=edit&confirm_rename=1", "Confirm rename", "t-confirmrename", "Confirm rename request by a non-trusted user", null, document.getElementById("nom-for-del"));
}
if (wgCanonicalNamespace == "File" && wgAction == "view")
{
addOnloadHook(addConfirmOption);
}
function doConfirmRename()
{
var conf_regex = /\{\{rename needs confirmation\|((.+?\..+?)(\|.*)?)\}\}/;
var textBox = document.getElementById("wpTextbox1");
var t = textBox.value;
var conf_match = conf_regex.exec(t);
var target;
if(conf_match != null && conf_match.length >= 3)
{
params = conf_match[1];
target = conf_match[2];
}
if(target != null && target.length > 0)
{
t = t.substring(0, conf_match.index) + "{{rename|" + params + "}}" + t.substring(conf_match.index + conf_match[0].length);
textBox.value = t;
document.getElementById("wpSummary").value = "Confirmed rename to [[Image:" + target + "]] using [[User:Superm401/easyMoveConfirm.js|easyMoveConfirm]].";
document.getElementById("wpSave").click();
}
}
if (wgCanonicalNamespace == "File" && wgAction == "edit" && window.location.href.indexOf("&confirm_rename=1") != -1)
{
addOnloadHook(doConfirmRename);
}
//</pre>