Jump to content

User:Pppery/no-ooui-contribs.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
(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);
})();