Misplaced Pages

User:The Earwig/monobook.js: Difference between revisions

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
< User:The Earwig Browse history interactively← Previous editNext edit →Content deleted Content added
Revision as of 03:24, 15 July 2017 view sourceThe Earwig (talk | contribs)Edit filter managers, Administrators26,508 edits -markblocked← Previous edit Revision as of 03:40, 15 July 2017 view source The Earwig (talk | contribs)Edit filter managers, Administrators26,508 edits fix my broken resourceloader codeNext edit →
Line 19: Line 19:
// Fix sandbox link // Fix sandbox link


$.when(mw.loader.using(), $.ready).then(function() {
(function () {
var uname = mw.util.wikiUrlencode(mw.config.get("wgUserName")); var uname = mw.util.wikiUrlencode(mw.config.get("wgUserName"));
var url = "/User:" + uname + "/Sandbox"; var url = "/User:" + uname + "/Sandbox";
$("#pt-sandbox a").attr("href", url).toggleClass("new"); $("#pt-sandbox a").attr("href", url).toggleClass("new");
})(); });


// Add a ] portlet link for subpages // Add a ] portlet link for subpages


$.when(mw.loader.using(), $.ready).then(function() {
(function () {
var title = mw.util.wikiUrlencode(mw.config.get("wgPageName")); var title = mw.util.wikiUrlencode(mw.config.get("wgPageName"));
var url = mw.util.getUrl("Special:PrefixIndex/" + title); var url = mw.util.getUrl("Special:PrefixIndex/" + title);
Line 37: Line 37:
"List subpages of the current page" "List subpages of the current page"
); );
})(); });


// Move "Upload file" and "Special pages" from tools portlet to interaction portlet // Move "Upload file" and "Special pages" from tools portlet to interaction portlet


$.when($.ready).then(function() {
$("#t-upload,#t-specialpages").appendTo($("#p-interaction ul")); $("#t-upload,#t-specialpages").appendTo($("#p-interaction ul"));
});


// Modifications to edit links // Modifications to edit links


mw.loader.using("ext.visualEditor.core", function () { $.when(mw.loader.using(), $.ready).then(function() {
if ($("#ca-edit a").text().indexOf("Create") >= 0)
$(function () {
if ($("#ca-edit a").text().indexOf("Create") >= 0) $("#ca-edit a").text("Create"); // "create this page / create source" -> "create"
else
$("#ca-edit a").text("Create"); // "create this page / create source" -> "create" $("#ca-edit a").text("Edit"); // "edit this page / edit source" -> "edit"
else
$("#ca-edit a").text("Edit"); // "edit this page / edit source" -> "edit" $("#ca-addsection a").text("+"); // "new section" -> "+"
$("#ca-addsection a").text("+"); // "new section" -> "+" $("#ca-ve-edit a").text("VE"); // "edit this page" -> "ve"
$("#ca-ve-edit a").text("VE"); // "edit this page" -> "ve"


$(".mw-editsection a:first-of-type").text("edit"); // "edit source" -> "edit" $(".mw-editsection a:first-of-type").text("edit"); // "edit source" -> "edit"
$(".mw-editsection-visualeditor").text("ve"); // "edit" -> "ve" $(".mw-editsection-visualeditor").text("ve"); // "edit" -> "ve"
});
}); });


mw.loader.using("ext.gadget.dropdown-menus-nonvector", function () { $.when(mw.loader.using(), $.ready).then(function() {
$("#ca-page a").text("Logs");
$(function () {
$("#ca-page a").text("Logs"); $("#opt-page ul li").hide();
$("#opt-page ul li").hide(); $("#opt-page-logs ul li").appendTo($("#opt-page ul"));
$("#opt-page-logs ul li").appendTo($("#opt-page ul"));
if ($("#opt-user-rfx").length > 0) { if ($("#opt-user-rfx").length > 0) {
var uname = mw.config.get("wgTitle").split("/"); var uname = mw.config.get("wgTitle").split("/");
var uname_enc = encodeURIComponent(uname.replace(/ /g, "_")); var uname_enc = encodeURIComponent(uname.replace(/ /g, "_"));
$("#opt-user-rfx ul").append($("<li/>", {id: "c-ux-brfa"}).append( $("#opt-user-rfx ul").append($("<li/>", {id: "c-ux-brfa"}).append(
$("<a/>", { $("<a/>", {
href: "/search/?title=Special:PrefixIndex/Wikipedia:Bots/Requests_for_approval/" + uname_enc, href: "/search/?title=Special:PrefixIndex/Wikipedia:Bots/Requests_for_approval/" + uname_enc,
text: "BRFAs" text: "BRFAs"
}))); })));


var api = new mw.Api(); var api = new mw.Api();
api.get({ api.get({
action: "query", action: "query",
list: "allpages", list: "allpages",
apprefix: "Bots/Requests for approval/" + uname, apprefix: "Bots/Requests for approval/" + uname,
apnamespace: 4, apnamespace: 4,
aplimit: 1 aplimit: 1
}).done(function(data) { }).done(function(data) {
if (data.query.allpages.length === 0) { if (data.query.allpages.length === 0) {
$("#c-ux-brfa a").remove(); $("#c-ux-brfa a").remove();
$("#c-ux-brfa").text("BRFAs").addClass("ca-disabled"); $("#c-ux-brfa").text("BRFAs").addClass("ca-disabled");
} }
}); });
} }
});
}); });


// Add a SUL info link to userpages // Add a SUL info link to userpages


$.when(mw.loader.using(), $.ready).then(function() {
(function () {
if (mw.config.get("wgNamespaceNumber") & ~1 != 2) if (mw.config.get("wgNamespaceNumber") & ~1 != 2)
return; return;

Revision as of 03:40, 15 July 2017

// ------------------------------ Script imports ------------------------------

importScript("User:The Earwig/copyvios.js"); // ]
importScript("User:The Earwig/permalink.js"); // ]
importScript("User:The Earwig/tfdclerk.js"); // ]
importScript("User:The Earwig/orfurrev.js"); // ]

importScript('User:Shubinator/DYKcheck.js');
importScript('User:Mr.Z-man/closeAFD.js');
importScript('User:Dr_pda/prosesize.js');
importScript("User:PleaseStand/userinfo.js");
importScript('User:Ale_jrb/Scripts/csdhelper.js'); // ]
importScript('User:Anomie/linkclassifier.js'); // ]

// ----------------------------- Interface tweaks -----------------------------

// <nowiki>

// Fix sandbox link

$.when(mw.loader.using(), $.ready).then(function() {
	var uname = mw.util.wikiUrlencode(mw.config.get("wgUserName"));
	var url = "/User:" + uname + "/Sandbox";
	$("#pt-sandbox a").attr("href", url).toggleClass("new");
});

// Add a ] portlet link for subpages

$.when(mw.loader.using(), $.ready).then(function() {
	var title = mw.util.wikiUrlencode(mw.config.get("wgPageName"));
	var url = mw.util.getUrl("Special:PrefixIndex/" + title);
	mw.util.addPortletLink(
    	"p-tb",
    	url,
    	"Prefix index",
    	"t-prefixindex",
    	"List subpages of the current page"
	);
});

// Move "Upload file" and "Special pages" from tools portlet to interaction portlet

$.when($.ready).then(function() {
	$("#t-upload,#t-specialpages").appendTo($("#p-interaction ul"));
});

// Modifications to edit links

$.when(mw.loader.using(), $.ready).then(function() {
	if ($("#ca-edit a").text().indexOf("Create") >= 0)
		$("#ca-edit a").text("Create");  // "create this page / create source" -> "create"
	else
		$("#ca-edit a").text("Edit");  // "edit this page / edit source" -> "edit"
	$("#ca-addsection a").text("+"); // "new section" -> "+"
	$("#ca-ve-edit a").text("VE"); // "edit this page" -> "ve"

	$(".mw-editsection a:first-of-type").text("edit"); // "edit source" -> "edit"
	$(".mw-editsection-visualeditor").text("ve"); // "edit" -> "ve"
});

$.when(mw.loader.using(), $.ready).then(function() {
	$("#ca-page a").text("Logs");
	$("#opt-page ul li").hide();
	$("#opt-page-logs ul li").appendTo($("#opt-page ul"));
		
	if ($("#opt-user-rfx").length > 0) { 
		var uname = mw.config.get("wgTitle").split("/");
		var uname_enc = encodeURIComponent(uname.replace(/ /g, "_"));
			
		$("#opt-user-rfx ul").append($("<li/>", {id: "c-ux-brfa"}).append(
			$("<a/>", {
				href: "/search/?title=Special:PrefixIndex/Wikipedia:Bots/Requests_for_approval/" + uname_enc,
				text: "BRFAs"
			})));

		var api = new mw.Api();
		api.get({
			action: "query",
			list: "allpages",
			apprefix: "Bots/Requests for approval/" + uname,
			apnamespace: 4,
			aplimit: 1
		}).done(function(data) {
			if (data.query.allpages.length === 0) {
				$("#c-ux-brfa a").remove();
				$("#c-ux-brfa").text("BRFAs").addClass("ca-disabled");
			}
		});
	}
});

// Add a SUL info link to userpages

$.when(mw.loader.using(), $.ready).then(function() {
	if (mw.config.get("wgNamespaceNumber") & ~1 != 2)
		return;
	var parts = mw.config.get("wgPageName").split("/", 1).split(":");
	parts.shift();
	var user = mw.util.wikiUrlencode(parts.join(":"));
	var url = mw.util.getUrl("Special:CentralAuth/" + user);
	mw.util.addPortletLink(
    	"p-tb",
    	url,
    	"SUL info",
    	"t-sulinfo",
    	"Show global user account info"
	);
})();

// Nav popups

window.popupFixDabs = true;

// </nowiki>