Minecraft Wiki

The Minecraft Wiki has moved from Fandom; see the linked discussion page for details.

READ MORE

Minecraft Wiki
Advertisement

Documentation may be created at User:Nixinova/gpmobile.js/doc.

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.

/**
 * Disables FandomMobile
 */

const classes = $('body').attr('class');
const paramString = '&action=view&mobileaction=toggle_view_desktop&mobileaction=toggle_view_mobile';
if (classes.includes('skin-fandommobile')) {
	
	// Mobile view
	if (!location.search) location.search = paramString;
}
else if (classes.includes('skin-minerva')) {

	// Collapse headings
	$('h2').click();

	// Improve diff view
	if (location.pathname.includes('Special:MobileDiff')) {
		const urlRegex = /.*Special:MobileDiff\/([0-9]+).*/;
    	const currentID = location.pathname.replace(urlRegex, '$1');
    	const prevID = $('#mw-mf-diffarea .revision-history-prev a[href]').attr('href').replace(urlRegex, '$1');
    	const pagelink = $('#mw-mf-diffarea a[href*="oldid"]');
    	const undoUrl = `/${pagelink.text().replace(/ /g, '_')}?action=edit&undoafter=${prevID}&undo=${currentID}mobileaction=toggle_view_desktop&mobileaction=toggle_view_mobile`;
    	pagelink.after(`<br>(<a href="/${pagelink.text().replace(/ /g, '_')}" style="color:#36c">View current page</a>)`);
    	$('#mw-mf-diffarea').append(`<a class="mw-ui-button" href="${undoUrl}">Undo</a>`);
	}
	
	// Styles
	$('head').append(`<style>
	.skin-minerva tr[class*="mw-changeslist"] {display: block !important;} /* Unhide recent changes entries */
	.skin-minerva .editor-overlay .header-container:after {content: unset;} /* Remove editing overlay */
	</style>`)
	
	// Add desktop view button
	setTimeout(() => {
		$('.post-content').after(`<a href="${location.pathname}?mobileaction=toggle_view_desktop" class="keep mw-ui-button button">Desktop</a>`);
	}, 600);
	
	// Load all links as GP
	setTimeout(applyLinks, 500);
}

function applyLinks() {
	$('a').each((i, link) => {
		let href = $(link).attr('href');
		if (!href.includes('?')) href += paramString.replace(/^&/, '?');
		else if (href.match(/[?&]action=/)) href += paramString.replace('action=view&', '');
		else href += paramString;
		$(link).attr('href', href);
	});
}
Advertisement