MediaWiki:Gadget-MoveUtil.js: Difference between revisions
From Elwiki
mNo edit summary |
mNo edit summary |
||
Line 1: | Line 1: | ||
if(wgNamespaceNumber == -1 && /MovePage(\/.+)?/.test(wgTitle)){ | if(wgNamespaceNumber == -1 && /MovePage(\/.+)?/.test(wgTitle)){ | ||
$('# | var link = $('#mw-content-text > p > b > a'); | ||
if(link){ | |||
var from, to, wiki, edittoken = '', new_wiki; | |||
from = link.first().text(); | |||
to = link.last().text(); | |||
/* Get Wiki Content From User:Boxsnake/MoveList */ | |||
$.get('/wiki/api.php?action=query&titles=User:Boxsnake/MoveList&prop=revisions&rvprop=content&format=json', function(data){ | $.get('/wiki/api.php?action=query&titles=User:Boxsnake/MoveList&prop=revisions&rvprop=content&format=json', function(data){ | ||
if(data.query.pages['-1']){ | if(data.query.pages['-1']){ | ||
Line 15: | Line 16: | ||
} | } | ||
}, 'json'); | }, 'json'); | ||
/* Get Edit Token and Add a Line in MoveList */ | |||
$.get('/wiki/api.php?action=tokens&type=edit&format=json', function(data){ | |||
try{ | |||
edittoken = data.tokens.edittoken; | |||
} | |||
/* Compose New Wikitext */ | |||
new_wiki = wiki + '\n' + from + ' -> ' + to; | |||
/* Add Line in MoveList */ | |||
$.post('/wiki/api.php?minor&recreate&bot', { | |||
'action': 'edit', | |||
'title': 'User:Boxsnake/MoveList', | |||
'summary': 'Bot Adding From Page Move. --[[Special:Gadgets|Move Util]]', | |||
'token': edittoken, | |||
'text': new_wiki | |||
}, function(){alert('')}); | |||
}); | }); | ||
}); | } | ||
else{ | |||
$('#wpMovetalk').attr('checked', 'checked'); | |||
$('#wpLeaveRedirect').removeAttr('checked'); | |||
$('#wpMovesubpages').attr('checked', 'checked'); | |||
} | |||
} | } |
Revision as of 22:29, 6 May 2015
if(wgNamespaceNumber == -1 && /MovePage(\/.+)?/.test(wgTitle)){
var link = $('#mw-content-text > p > b > a');
if(link){
var from, to, wiki, edittoken = '', new_wiki;
from = link.first().text();
to = link.last().text();
/* Get Wiki Content From User:Boxsnake/MoveList */
$.get('/wiki/api.php?action=query&titles=User:Boxsnake/MoveList&prop=revisions&rvprop=content&format=json', function(data){
if(data.query.pages['-1']){
wiki = '';
}
else{
data = data.query.pages;
wiki = data[Object.keys(data)[0]].revisions[0]['*'];
}
}, 'json');
/* Get Edit Token and Add a Line in MoveList */
$.get('/wiki/api.php?action=tokens&type=edit&format=json', function(data){
try{
edittoken = data.tokens.edittoken;
}
/* Compose New Wikitext */
new_wiki = wiki + '\n' + from + ' -> ' + to;
/* Add Line in MoveList */
$.post('/wiki/api.php?minor&recreate&bot', {
'action': 'edit',
'title': 'User:Boxsnake/MoveList',
'summary': 'Bot Adding From Page Move. --[[Special:Gadgets|Move Util]]',
'token': edittoken,
'text': new_wiki
}, function(){alert('')});
});
}
else{
$('#wpMovetalk').attr('checked', 'checked');
$('#wpLeaveRedirect').removeAttr('checked');
$('#wpMovesubpages').attr('checked', 'checked');
}
}