User:Tanbiruzzaman/Redirector.js
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
//Can be redirected from other pages without leaving the corresponding page.
//by [[User:Tanbiruzzaman]]
//Originally by [[User:Yahya]]
//<nowiki>
( function () {
var redir = $(mw.util.addPortletLink('p-tb','#','Redirector','Redirect creator','Redirect maker','','#pt-mytalk'));
$( redir ).click( function() {
var redirec = prompt("Enter the title of the page from which you want to redirect to this page (please don't create unnecessary extra redirects):", "");
if (redirec === null || redirec === "") {
alert( '!Please enter a title first!' );
} else {
var params = {
action: 'edit',
title: redirec ,
createonly: 1,
prependtext: '#Redirect [[' + mw.config.get("wgPageName") + ']]',
summary: 'Redirected to [[' + mw.config.get("wgPageName") + ']] page by using [[:User:Tanbiruzzaman/Redirector|Redirector]]' ,
format: 'json'
};
api = new mw.Api();
api.postWithToken( 'csrf', params ).done( function ( data ) {
alert( 'Successfully created redirect from ' + redirec + ' page!' );
});
}
}
);
}() );
//</nowiki>