Advertisement
Guest User

Untitled

a guest
Aug 29th, 2014
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* One-click rename for appending "FANMADE" to files */
  2. if (mw.config.get("wgCanonicalNamespace") === "File") {
  3.    $('#WikiaPageHeader').append('<span id="fanmade-button" class="button">FANMADE</span>');
  4.  
  5.    $('#fanmade-button').click(function() {
  6.       var newname = 'File:FANMADE ' + mw.config.get('wgPageName').substring(5);
  7.       new mw.Api().post({
  8.       format: 'json',
  9.       action: 'move',
  10.       from: mw.config.get('wgPageName'),
  11.       to: newname,
  12.       token: mw.user.tokens.get('editToken'),
  13.       reason: 'Adding FANMADE as per [[Help:Descriptive name]]',
  14.       noredirect: ''
  15.       })
  16.       .done(function(d) {
  17.          if (!d.error) {
  18.             window.location.replace("/wiki/" + newname);
  19.          } else {
  20.             alert('Failed to move page: '+ d.error.code);
  21.          }
  22.       })
  23.       .fail(function() {
  24.             alert('Failed to move page: unknownerror');
  25.       });
  26.    });
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement