MediaWiki:Gadget-checkRestricted.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)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/** * CheckRestricted - 2024 Waki285 * Confirms when an attempt is made to grant the specified authority to another person. * @license MIT or Apache-2.0 */ (function () { var spName = mw.config.get("wgCanonicalSpecialPageName"); if (spName !== "Userrights") { return; } if (typeof restrictedGroups === "undefined") { var restrictedGroups = ["checkuser", "suppress"]; } var $form = $("#mw-content-text form"); if ($form.length === 0) { return; } for (var i = 0; i < restrictedGroups.length; i++) { var $group = $form.find("label[for='wpGroup-" + restrictedGroups[i] + "']"); if ($group.length > 0) { $group.css("color", "red"); $group.append(" (restricted)"); } } var $form2 = $("form[name=editGroup]"); if ($form2.length === 0) { return; } var $initInput = $("input[name='conflictcheck-originalgroups']"); var initGroups = $initInput.val().split(","); $form2.on("submit", function (e) { e.preventDefault(); $form2.append($("input[name=saveusergroups").clone().prop("type", "hidden")); var $group = $form2.find("input[name^='wpGroup-']:checked"); var $user = $form2.find("input[type=hidden][name=user]"); var user = $user.val(); var executor = mw.config.get("wgUserName"); if (executor === user) { $form2.off("submit"); $form2.submit(); return; } var danger = false; for (var i = 0; i < $group.length; i++) { var group = $group.eq(i).prop("name").replace("wpGroup-", ""); if (restrictedGroups.indexOf(group) === -1) { continue; } if (initGroups.indexOf(group) !== -1) { continue; } danger = true; } if (danger) { if (confirm("You are about to add a restricted group to this user. Are you sure you want to continue?")) { if (confirm("Are you really sure?")) { if (confirm("Are you REALLY REALLY sure?")) { alert("Okay, you asked for it..."); $form2.off("submit"); // wait 1sec setTimeout(function () { $form2.submit(); }, 1000); } else { return; } } else { return; } } else { return; } } $form2.off("submit"); $form2.submit(); }); })();