Jump to content

User:DannyS712 test/move.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by DannyS712 test (talk | contribs) at 01:04, 29 April 2020 (try). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
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.
mw.loader.using( 'mediawiki.util', function () {
    $(document).ready( function () {
    	if ( $('.ambox-move > tbody > tr').length > -1 ){
	    	var row = $('.ambox-move > tbody > tr')[0];
	    	var noticeText = row.children[1].innerText;
	    	var target = noticeText.replace(/(It has been requested that the title of this article be changed to )|(\. Please see the relevant discussion. The page should not be moved unless the discussion is closed; summarizing the consensus achieved in support of the move\.)/g, '');
			target = target.replace(/(A request that this article title be changed to )|( is under discussion\. Please do not move this article until the discussion is closed\.)/g, '');
	    	target = encodeURIComponent( target );
	    	console.log( 'MOVE', row, noticeText, target );
	    	var current = mw.config.get('wgPageName');
	    	var link = '<td><a href=/w/index.php?title=Special:MovePage&wpOldTitle=' + current + '&wpNewTitle=' + target + '&wpMovetalk=1&wpMovesubpages=1>Move</a></td>';
	    	$(row).append( $(link) );
	    	console.log( link );
    	}
    } );
} );