Jump to content

User:Closed Limelike Curves/matrix-2022.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.
// Replace logo with better one for small size
if (window.location.hostname.includes("wikipedia")) {
	$("body").addClass("wikipedia");
	$(".mw-logo-icon").attr("src", "/media/wikipedia/commons/1/10/Wikipedia-W-bold-in-square.svg");
}

mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:Closed_Limelike_Curves/ArticleInfo.js&action=raw&ctype=text/javascript');
mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:Closed_Limelike_Curves/Collapser.js&action=raw&ctype=text/javascript');

/* complete button layout changes */
$("#p-lang-btn").insertAfter($(".mw-logo"));
$("a.mw-logo").addClass("cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only");
// $("img.mw-logo-icon").addClass("vector-icon");

/* TODO: modify grid layout? */
/*
$(".mw-page-container-inner").css("display", "block");
$("#content").prepend($(".vector-column-start"));
$("#content").css("column-count", "3");
$(".mw-body .vector-page-titlebar").css("grid-column", "2");
$("#content .vector-page-toolbar").css("grid-row", "2");
$("#bodyContent").css("grid-column", "2");
$(".vector-column-start").css("grid-column", "1");
$(".vector-column-end").css("grid-column", "3");
*/

/* TODO: Replace mask with svg so I can use stroke instead of ugly drop-shadow
$(".cdx-button .vector-icon").each(function(index){
    x = $(this)
    x.append($('<mask>', {"src": x.css("mask-image").split('"')[1], "fill": x.css("background-color")}))
})
*/
	
// Citations menu
mw.util.addPortlet("p-cite", "Citations", "#p-tb");

buildCitationMenu();
async function buildCitationMenu() {
	// Adds link to fill in references with ReFill
	var link = "https://refill.toolforge.org/ng/result.php?page=" + 
			    mw.config.get("wgPageName") + 
			   "&wiki=en&method-wiki=Fix%20page&addblankmetadata=on&noaccessdate=on";
	await mw.util.addPortletLink("p-cite", link, "ReFill", "t-refill", "Fill references with ReFill");
	// Move citation tools to portlet
	$("#p-cite > div.vector-menu-content > ul").append($("#t-refill"))
		.append($("#ca-RefCon"));
}

// subtitle
// Remove "from Wikipedia"
$("#siteSub").hide();
// prepend to subtitle in case empty
$(".vector-body-before-content").prepend($("<div>"));

mw.hook( 'wikipage.indicators' ).add(function(){
	const topicons = $("div.mw-indicators");
	topicons.prepend($("#mw-indicator-user-info-popup-indicator"));
	topicons.insertAfter($("#firstHeading")); // Move topicons
});

mw.hook( 'wikipage.content' ).add(function(){
	$(".vector-body-before-content").css("display", "flex");
	$(".vector-body-before-content").css("justify-content", "space-between");
	$(".vector-body-before-content").append($("#xtools"));
	$(".vector-body-before-content").append($("#p-pbar"));
	$(".vector-body-before-content").prepend($("#sdh")); // Move #sdh
	const topicons = $("div.mw-indicators");
	topicons.prepend($("#mw-indicator-user-info-popup-indicator"));
	topicons.insertAfter($("#firstHeading")); // Move topicons
});

/* Load CSS in case user hasn't added it themselves */
mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:Closed_Limelike_Curves/ColorfulButtons.css&action=raw&ctype=text/css', 'text/css');
mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:Closed_Limelike_Curves/matrix-2022.css&action=raw&ctype=text/css', 'text/css');