Registration has been disabled and the moderation extension has been turned off.
Contact an admin on Discord or EDF if you want an account. Also fuck bots.

User:Dbaggins/test.js

From Encyclopedia Dramatica
Jump to navigationJump to search

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
wgEditToken = "";

$.ajax({
	url: 'https://encyclopediadramatica.es/api.php?',
    dataType: 'json',
    async: false,
    data: {
	    action: 'query',
	    prop:'info',
	    titles:'User:Dbaggins/Sandbox',
	    intoken:'edit',
	    format: 'json',
	},
	success:
		function( data ) {
			var unknown = Object.keys(data.query.pages)[0];
			wgEditToken = data.query.pages[unknown].edittoken;
    	},
});

function editPage( info ) {
	$.ajax({
		url: "https://encyclopediadramatica.com/api.php",
		type: 'POST',
		dataType: 'json',
		data: {
			format: 'json',
			action: 'edit',
			title: info.title,
			text: info.text, // will replace entire page content
			summary: info.summary,
			token: wgEditToken
		}
	})
	.done (function( data ) {
		if ( data && data.edit && data.edit.result && data.edit.result == 'Success' ) {
			alert( 'Page edited!' );
		} else {
			alert( 'The edit query returned an error. =(' );
		}
	})
	.fail ( function(data) {
		var acc = [];
		$.each(data, function(index, value) {
		    acc.push(index + ': ' + value);
		});
		alert("ERROR: " + JSON.stringify(acc));
	});
}

editPage({
	title: 'User:Dbaggins/Sandbox',
	text: 'Test...',
	summary: 'Trying to edit my sandbox...'
});