User:Nixinova/gpmobile.js

/** * 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(` (View current page)`); $('#mw-mf-diffarea').append(`Undo`); }	// Styles $('head').append(` 	.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 */	 `) // Add desktop view button setTimeout( => {		$('.post-content').after(`Desktop`);	}, 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);	}); }