Jump to content

User:DannyS712 test/refund.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by DannyS712 test (talk | contribs) at 03:41, 4 March 2019 (try with page.js). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
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 rf_config = {
	name: '[[User:DannyS712/refund request|refund request.js]]',
	version: 1.0,
	debug: true
};
var rf_summary = 'Request a refund with ' + rf_config.name + ' (version ' + rf_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)', 'refund request', 'ca-refund', 'Request a refund');
    	$('#ca-refund').on('click', function() {
        	request_refund();
    	} );
    } );
} );
function request_refund(){
	var page = prompt("What page would you like refunded under G13 (including the namespace prefix)?", "Draft:Example");
	var request = "\n\n{{subst:Refund/G13|" + page + "}}";
	var requesting_page = mw.config.get( 'wgPageName' );
	var old = get_page( requesting_page );
	var new_page = old + request;
	set_page( request_page, new_page, rf_summary );
}
});
//</nowiki>