User:Joritochip/common.js

// FastDelete configuration (partially from 0Michael105) window.FastDeleteNoConfirm = false; var fdButtons = [ {		'summary': 'Non-notable topic', 'label': 'Non-notable topic' },	{		'summary': 'Vandalism', 'label': 'Vandalism' },	{		'summary': 'Spam', 'label': 'Spam' },	{		'summary': 'Cleanup', 'label': 'Cleanup' },	{		'summary': 'Low-effort page', 'label': 'Low-effort page' },	{		'summary': 'Unused file', 'label': 'Unused file' } ];

/* FandomDesktop Ajax Fast Delete */ $(function {	const conf = mw.config.get([ 'wgNamespaceNumber', 'wgPageName', 'wgArticleId', 'skin' ]);	if ( conf.skin !== 'fandomdesktop' || window.FastDeleteLoaded || !window.fdButtons || conf.wgNamespaceNumber === -1 || conf.wgArticleId === 0 || (conf.wgNamespaceNumber === 2 && $('.noarticletext').length) || (conf.wgNamespaceNumber != 2 && !$('#ca-delete').length) || !/sysop|staff|helper|wiki-manager|content-team-member|content-volunteer|content-moderator|soap/.test(mw.config.get('wgUserGroups').join) ) return;	window.FastDeleteLoaded = true;	function promptDelete(reason) {		if (window.FastDeleteNoConfirm === true || confirm('Are you sure you want to delete this page? Delete reason will be "'+reason+'".') === true) {			new mw.Api.postWithToken('csrf', { action: 'delete', title: conf.wgPageName, reason: reason, bot: true }).done(function(res) { if (res.error) return alert('An error occured while trying to delete the page: '+res.error.code+' - '+res.error.info); location.reload; }).fail(function { return alert('An error occured while trying to delete the page!'); });		}	}	mw.hook('dev.wds').add(function(wds) { var dropdown = $(' ').appendTo('.page-side-tools'); var toggle = $(' ').appendTo(dropdown); $('').append(wds.icon('trash-small')).appendTo(toggle); var content = $('').appendTo($(' ').appendTo(dropdown)); fdButtons.forEach(function(array) {			$(''+array.label+'').appendTo(content).click(function { promptDelete(array.summary); });		});	});	if (!window.dev || !window.dev.wds) {		importArticle({ type: 'script', article: 'u:dev:MediaWiki:WDSIcons/code.js' });	} });

/* Show last revision on deleted pages */ mw.loader.using(['mediawiki.api']).done(function {   if ( window.LastDeletedRevisionReady || $('#mw-content-text .mw-warning-with-logexcerpt').length === 0 ) return;   window.LastDeletedRevisionReady = true;

var api = new mw.Api; var name = mw.config.get('wgPageName'); api.get({       action: 'query',        prop: 'deletedrevisions',        titles: name,        drvslots: '*',        drvlimit: 1,        drvprop: 'user|comment|content|timestamp'    }).done(function(data) {        if (data.query.pages['-1']) {            var wikitext = data.query.pages['-1'].deletedrevisions[0].slots.main['*'];

api.parse(wikitext).done(function(html) {               $('.noarticletext').remove;                $(' ', { class: 'mw-warning-with-logexcerpt mw-content-ltr', append: html, appendTo: $('#mw-content-text') });           });        }    }); });