User:Robyn Grayson/wikia.js

$('#mw-htmlform-source').replaceWith(' ');

$('.mw-htmlform-submit').click(function { var Api = new mw.Api; Api.get({ action: 'query', prop: 'revisions', rvprop: 'ids', titles: $('#wpDestFile').val, }).done(function(d) { var q = d.query.pages, p = q[Object.keys(p)[0]]; if (p.missing !== '') { alert('Already exists, kid'); return; }   var form = new FormData; form.append('wpSourceType', 'url'); form.append('wpUploadFileURL', $('#wpUploadFileURL').val); form.append('wpDestFile', $('#wpDestFile').val); form.append('wpEditToken', mw.user.tokens.get('editToken')); form.append('format', 'json'); form.append('title', 'Special:Upload'); form.append('wpUpload', 'Upload file'); form.append('wpDestFileWarningAck', '1'); form.append('wpWatchthis', '1'); form.append('wpLicense', ''); form.append('wpUploadDescription', prompt('Upload description:')); $.ajax({       url: '/wiki/Special:Upload',        contentType: false,        processData: false,        type: 'POST',        data: form,        dataType: 'json',        success: alert('Success!'),        error: alert('Error...')    }); }); });