Jump to content

User:DannyS712 test/isdead.js

From Wikipedia, the free encyclopedia
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.
//<nowiki>
$(function (){
var IsD_config = {
	name: '[[User:DannyS712/Is Dead|Is Dead.js]]',
	version: 1.0,
	debug: true
};
var IsD_summary = 'Set wikiproject parameters to reflect that the subject has died - with ' + IsD_config.name + ' (version ' + IsD_config.version + ')';

mw.loader.using( 'mediawiki.util', function () {
	importScript('User:DannyS712 test/page.js')
    $(document).ready( function () { 
    	mw.util.addPortletLink ( 'p-cactions', 'javascript:void(0)', 'Is Dead', 'ca-make-dead', 'Edit to make dead');
    	$('#ca-make-dead').on('click', function() {
        	Make_dead();
    	} );
    } );
} );
function Make_dead(){
	var name = mw.config.get( 'wgPageName' );
	var current = get_page( name );
	var new_page = current.replace(/(living|blp)=(?:yes|y)/gi, '$1=no');
	console.log( new_page );
	set_page( name, new_page, IsD_summary, true);
}
});
//</nowiki>