User:GeorgeMoney/TEMP/Rpotd.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
//security risk. Delete when done using!!!

//Prefix to use when automatically moving
var movevar='rpotdmove=1';
var moveenabled = 1;
var movesummary='Moving RPOTD pages to a new userspace, per the [[WP:Templates_for_deletion/Log/2008_June_27#Template:Rpotd|TfD]].';
var movenp = 'User:Presidentman/potd';
var moveoldprefix = /^(?:User\:GeorgeMoney\/potd(\/.+)?|Template\:RPOTD(\/.+)?)$/i;
var movenewprefix = movenp+'$1$2';

//Prefix to use when fixing references to GM/potd
var fixvar='rpotdfix=1';
var fixenabled = 1;
var fixsummary='Preparing pages for move.';

//Prefix to use when autodeleting the old Template:Rpotd
var delvar='rpotddel=1';
var delenabled = 1;
var delsummary = 'Deleting old pages, per the [[WP:Templates_for_deletion/Log/2008_June_27#Template:Rpotd|TfD]] and per [[WP:CSD#G6|CSD G6]].';

if(moveenabled && wgPageName=='Special:MovePage' && window.location.href.indexOf(movevar) != -1) {

document.getElementById('wpReason').value=movesummary;

var newtitle;
var oldtitle=-1;
var tds = document.getElementsByTagName('td'); len = tds.length;
for(i=0; i<len; i++) {
if(tds[i].className=='mw-input') {
oldtitle = tds[i].getElementsByTagName('strong')[0].getElementsByTagName('a')[0].innerHTML;
break;
}
}
if(oldtitle != -1) {
newtitle = oldtitle.replace(moveoldprefix, movenewprefix);
document.getElementById('wpNewTitle').value=newtitle;
document.getElementsByName('wpMove')[0].click();
}

}

if(wgPageName.indexOf(movenp)==0 && window.location.href.indexOf(fixvar) != -1) {

document.getElementById('wpSummary').value=fixsummary;

}