/******************************************************************************************************************/
/* Enhanced "What links here" script */
/* */
/* author: User:Technical_13 */
/* source: http://en.wikipedia.orghttps://wiki95.com/en/User:Technical_13/Scripts/Enhanced_"What_links_here".js */
/* documentation: http://en.wikipedia.orghttps://wiki95.com/en/User:Technical_13/Scripts/Enhanced_"What_links_here" (redlink) */
/* contact: http://en.wikipedia.orghttps://wiki95.com/en/User_talk:Technical_13 */
/* license: CC-BY-SA 3.0 (http://creativecommons.org/licenses/by-sa/3.0/) */
/******************************************************************************************************************/
// Look for "What links here" in the toolbox
if (mw.config.get('wgNamespaceNumber') >= 0 && $('#t-whatlinkshere').length === 0) {
alert('Missing "What links here" in the side menu! Contact script creator for assistance.');
// return;
} else {
/*/ Start process
$('#t-whatlinkshere').load(function () {
*/
// Build arrays
$.ajax({
url: mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/api.php?action=query&meta=siteinfo&siprop=namespaces&format=json',
dataType: 'json',
async: false,
success: function (siResponse) {
var i = 0;
for (var ns in siResponse.query.namespaces) {
if (siResponse.query.namespaces.id > -1) {
// Define namespace number
nsPos = siResponse.query.namespaces.id;
// Define namespace displayed name
nsPos = siResponse.query.namespaces.nodeValue;
// Pull number of links for current namespace up to 500
$.ajax({
url: mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/api.php?action=query&list=backlinks&bllimit=500&blnamespace=' + nsNum + '&bltitle=' + mw.config.get('wgPageName') + '&format=json',
dataType: 'json',
async: false,
success: function (blResponse) {
// Define number of links for current namespace up to 500
bl = blResponse.query.backlinks.length;
if (isNaN(bl) ){
bl = 0;
}
if(typeof nsPos !== 'undefined') {
nsPos = bl;
}
}
});
// TRON
if(typeof nsPos !== 'undefined') {
alert(i + ' => + ', ' + nsPos + ', ' + nsPos + ']');
}
// TROFF
i++;
}
}
}
});
// for now //});
}