User:Proteins/listredirectstothispage.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.
//<pre>
// List pages that redirect to this one
//
// To use this script, add "importScript('User:Proteins/listredirectstothispage.js');" to your monobook.js subpage 
// under your user page, as you can see at User:Proteins/monobook.js

function listRedirectsToThisPage() { 

	var api_query;
	var page_name;
	var article_name;

	page_name = wgPageName;
 	article_name = (wgNamespaceNumber == 1) ? page_name.substr(5) : page_name;
	article_name = URLEncode(article_name);

	api_query = "http://en.wikipedia.org/w/api.php?action=query&list=backlinks&bltitle="+article_name+"&bllimit=500&blfilterredir=redirects";

	window.open(api_query);
} // closes listRedirectsToThisPage()

addOnloadHook(function () {
mw.util.addPortletLink('p-navigation', 'javascript:listRedirectsToThisPage()', 'List redirects', 'ca-redirects', 'List pages that redirect to this page', '=', '');
});
 
//</pre>