Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* One-click rename for appending "FANMADE" to files */
- if (mw.config.get("wgCanonicalNamespace") === "File") {
- $('#WikiaPageHeader').append('<span id="fanmade-button" class="button">FANMADE</span>');
- $('#fanmade-button').click(function() {
- var newname = 'File:FANMADE ' + mw.config.get('wgPageName').substring(5);
- new mw.Api().post({
- format: 'json',
- action: 'move',
- from: mw.config.get('wgPageName'),
- to: newname,
- token: mw.user.tokens.get('editToken'),
- reason: 'Adding FANMADE as per [[Help:Descriptive name]]',
- noredirect: ''
- })
- .done(function(d) {
- if (!d.error) {
- window.location.replace("/wiki/" + newname);
- } else {
- alert('Failed to move page: '+ d.error.code);
- }
- })
- .fail(function() {
- alert('Failed to move page: unknownerror');
- });
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement