MediaWiki:Common.js:修订间差异
MediaWiki界面页面
更多语言
更多操作
创建页面,内容为“→这里的任何JavaScript将为所有用户在每次页面加载时加载。: mw.loader.using( "mediawiki.util" ).then( function () { var link = document.getElementById( "authorpages-link" ); if ( !link ) { return; } // Try the standard footer id used by many skins. var lastmod = document.getElementById( "footer-info-lastmod" ); if ( lastmod ) { // Move the link right after the last-modified block. var wra…” |
无编辑摘要 |
||
| 第1行: | 第1行: | ||
mw.loader.using( "mediawiki.util" ).then( function () { | mw.loader.using( "mediawiki.util" ).then( function () { | ||
var link = document.getElementById( "authorpages-link" ); | var link = document.getElementById( "authorpages-link" ); | ||
| 第7行: | 第5行: | ||
} | } | ||
// | // Remove it from the footer where it was originally rendered | ||
if ( link.parentNode ) { | |||
link.parentNode.removeChild( link ); | |||
if ( | |||
} | } | ||
// | // Find the page footer area (Citizen still uses a <footer> element) | ||
var footer = | var footer = document.querySelector( "footer" ); | ||
if ( !footer ) { | if ( !footer ) { | ||
return; | return; | ||
} | } | ||
// | // Look for the element that contains the "This page was last edited" text | ||
var | var infoElems = footer.querySelectorAll( "p, div, span, li" ); | ||
var lastEditedElem = null; | |||
for ( var i = 0; i < infoElems.length; i++ ) { | |||
if ( /This page was last edited/i.test( infoElems[ i ].textContent ) ) { | |||
lastEditedElem = infoElems [ i ]; | |||
break; | break; | ||
} | } | ||
} | } | ||
// If we can’t find it, just drop the link at the end of the footer | |||
if ( !lastEditedElem ) { | |||
footer.appendChild( link ); | |||
return; | |||
} | |||
// Insert the author link *under* the "last edited" line | |||
var wrapper = document.createElement( "div" ); | |||
wrapper.id = "authorpages-under-lastmod"; | |||
wrapper.appendChild( link ); | |||
lastEditedElem.parentNode.insertBefore( wrapper, lastEditedElem.nextSibling ); | |||
} ); | } ); | ||
2025年11月22日 (六) 23:49的最新版本
mw.loader.using( "mediawiki.util" ).then( function () {
var link = document.getElementById( "authorpages-link" );
if ( !link ) {
return;
}
// Remove it from the footer where it was originally rendered
if ( link.parentNode ) {
link.parentNode.removeChild( link );
}
// Find the page footer area (Citizen still uses a <footer> element)
var footer = document.querySelector( "footer" );
if ( !footer ) {
return;
}
// Look for the element that contains the "This page was last edited" text
var infoElems = footer.querySelectorAll( "p, div, span, li" );
var lastEditedElem = null;
for ( var i = 0; i < infoElems.length; i++ ) {
if ( /This page was last edited/i.test( infoElems[ i ].textContent ) ) {
lastEditedElem = infoElems [ i ];
break;
}
}
// If we can’t find it, just drop the link at the end of the footer
if ( !lastEditedElem ) {
footer.appendChild( link );
return;
}
// Insert the author link *under* the "last edited" line
var wrapper = document.createElement( "div" );
wrapper.id = "authorpages-under-lastmod";
wrapper.appendChild( link );
lastEditedElem.parentNode.insertBefore( wrapper, lastEditedElem.nextSibling );
} );