User:MZMcBride/speedy.js

/** * Simple speedy deletion script * @author Legoktm, MZMcBride * Public domain; 2015 */

if (mw.config.get('wgNamespaceNumber') === 2 || mw.config.get('wgNamespaceNumber') === 3) { var speedylink = mw.util.addPortletLink(		'p-cactions',		'#',		'Speedy',		'ca-speedy',		'Speedy',		's'	); }

// Bind click handler $( speedylink ).click( function {	var page_title = mw.config.get('wgPageName');	speedy( page_title ); });

function speedy( page_title ) { var api = new mw.Api;

api.get( {		action: 'query',		meta: 'tokens',		type: 'csrf',		format: 'json'	} ).done(

function( data ) { var edit_token = data.query.tokens.csrftoken; api.post( {				action: 'edit',				title: page_title,				prependtext: '{'+'{db-u5}}'+'\n',				summary: 'CSD U5',				token: edit_token			} ).done(

function( data ) { window.close; if (!window.closed) { window.location = '/wiki/'+page_title; }				}

);		}	); }

const pages = ["User:MZMcBride/Sandbox", "Wikipedia:Database_reports/Potential_U5s" ]; const current_page = mw.config.get('wgPageName'); if (pages.includes(current_page) || current_page.startsWith('Wikipedia:Database_reports/Potential_U5s')) { $( '.wikitable a' ).click( function {		var page_title = this.href;		this.removeAttribute("href");		this.setAttribute("style", "display: none;");		if (page_title) {			window.open( page_title, "_blank" );		}	}); }