User:MZMcBride/coords.js

/** * Simple title coords remover * @author MZMcBride * Public domain; 2022 */

var coordslink = mw.util.addPortletLink(	'p-cactions',	'#',	'Cooooooords',	'ca-coords',	'Cooooooords',	'c' );

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

function coords( 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,				summary: 'coords in the infobox seem sufficient',				token: edit_token			} ).done(

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

);		}	); }