User:Pppery/no-ooui-contribs.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
Documentation for this user script can be added at User:Pppery/no-ooui-contribs. |
(function(){
if(mw.config.get("wgCanonicalSpecialPageName") !== "Contributions" ||
$(".mw-htmlform-ooui-wrapper").length === 0) {
return;
}
// Misc UI fix
$("label[for='ooui-php-2']").text('User: ');
// remove collapsing
$(".mw-collapsible-content").removeAttr("class").show();
$(".mw-collapsible").removeAttr("class");
// remove collapsible toggles and other collapse-related miscellany
var l = $("legend").first();
l.removeAttr("role").off();
l.find(".oo-ui-widget").remove();
// Cleanup tag filter before breaking the world (Ideally I would keep the dropdown menu, but it doesn't work)
$("a.oo-ui-buttonElement-button").remove();
// get rid of all the OOUI styling
l.parent().find("*:not(#mw-htmlform-contribs-date *)").addBack().attr("class","");
l.parents("div").first().attr("class","");
// get rid of the extra boxes and legends
$($("fieldset")[1]).children().first().unwrap();
$($("fieldset")[1]).children().first().unwrap();
$($("legend")[1]).remove();
$($("legend")[1]).remove();
// put "user", "namespace", and "tag" fields on the same line as their labels
$("#ooui-php-2, #ooui-php-3, #ooui-php-8").unwrap().unwrap();
// remove the ooui-enhanced selection element in favor of the native one
$("#ooui-php-3").next().remove();
// put the "invert selection" / "associated namespace" checkboxes on the same
// line as the namespace selector
var o;
var admin = mw.config.get("wgDBname") == "mediawikiwiki" || mw.config.get("wgDBname") == "enwiki" || mw.config.get("wgDBname") == "metawiki"
if (admin) {
o = $("#ooui-php-15, #ooui-php-16");
} else {
o = $("#ooui-php-14, #ooui-php-15");
}
o.find("label, input, select").filter(":not(label input)").detach().insertBefore(o.first()).after(" ").find("input").after(" ");
o.remove();
// put all the other checkboxes in the right place
if (admin) {
o = $("#ooui-php-20, #ooui-php-21, #ooui-php-22, #ooui-php-23, #ooui-php-30, #ooui-php-31");
} else {
o = $("#ooui-php-19, #ooui-php-20, #ooui-php-21, #ooui-php-28, #ooui-php-29");
}
o = o.filter(":not(:has(button))");
o.find("label, input, select").detach().insertBefore(o.first()).after(" ");
o.remove();
// put the date fields in the right place
o = $("#mw-htmlform-contribs-date");
o.find("label:not(.oo-ui-widget), #mw-date-start, #mw-date-end").detach().insertBefore(o);
o.remove();
$("#mw-date-start").after("<br\>");
// remove the Help link at the top
$("#coordinates").remove();
// fix spacing
$(".mw-htmlform").css("line-height","1.7");
$(".mw-widget-dateInputWidget, #ooui-php-4, #ooui-php-2").before(" ");
$("#ooui-php-2").css("width","23%");
// re-add the smart invert selection handling
var select = $("#ooui-php-3");
var checkboxes = $("label:has(input)");
select.change(function() {
if (select.val() == "all") {
checkboxes.hide();
} else {
checkboxes.show();
}
});
if (select.val() == "all") {
checkboxes.hide();
} else {
checkboxes.show();
}
// clean up the HTML a little
$('.mw-htmlform span:empty[class=""], .mw-htmlform label:empty[class=""]').remove();
$('.mw-htmlform div[class=""], .mw-htmlform span[class=""], .mw-htmlform fieldset').each(function() {
var t = $(this);
var c = t.children();
if(c.length == 1) {
c.unwrap();
}
});
$('*[class=""]').removeAttr("class");
// Do the right thing with tag filter stuff
$("#ooui-php-2").after("<br/>");
$("#ooui-php-8").parent().append($("#ooui-php-9").parent().detach().children());
$("#ooui-php-9").before(" ").after(" ");
// autocomplete-related hackery
$("#ooui-1, #ooui-2").remove();
$("#ooui-php-2").addClass("mw-autocomplete-user");
mw.loader.load("mediawiki.userSuggest");
setTimeout(function(){
// Remove collapsible stuff in case it was added later
$(".mw-collapsible-toggle").remove();
$(".mw-collapsible-content").children().first().unwrap();
},350);
})();