Difference between revisions of MediaWiki:Common.js

Jump to navigation Jump to search
No edit summary
(Blanked the page)
Tag: Blanking
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
/* Any JavaScript here will be loaded for all users on every page load. */
try {
switch ( section ) {
case 'languages':
var target = 'p-lang';
break;
case 'toolbox':
var target = 'p-tb';
break;
case 'navigation':
var target = 'p-navigation';
break;
default:
var target = 'p-' + section;
break;
}


if ( action == 'add' ) {
var node = document.getElementById( target )
  .getElementsByTagName( 'div' )[0]
  .getElementsByTagName( 'ul' )[0];
var aNode = document.createElement( 'a' );
var liNode = document.createElement( 'li' );
aNode.appendChild( document.createTextNode( name ) );
aNode.setAttribute( 'href', link );
liNode.appendChild( aNode );
liNode.className = 'plainlinks';
node.appendChild( liNode );
}
if ( action == 'remove' ) {
var list = document.getElementById( target )
  .getElementsByTagName( 'div' )[0]
  .getElementsByTagName( 'ul' )[0];
var listelements = list.getElementsByTagName( 'li' );
for ( var i = 0; i < listelements.length; i++ ) {
if (
listelements[i].getElementsByTagName( 'a' )[0].innerHTML == name ||
listelements[i].getElementsByTagName( 'a' )[0].href == link
)
{
list.removeChild( listelements[i] );
}
}
}
} catch( e ) {
// let's just ignore what's happened
return;
}
}
function CustomizeModificationsOfSidebar() {
// adds [[Special:CategoryTree|Special:CategoryTree]] to toolbox
//ModifySidebar( 'add', 'toolbox', 'CategoryTree', 'https://en.wikipedia.org/wiki/Special:CategoryTree' );
// removes [[Special:Upload|Special:Upload]] from toolbox
//ModifySidebar( 'remove', 'toolbox', 'Upload file', 'https://en.wikipedia.org/wiki/Special:Upload' );
ModifySidebar( 'add', 'toolbox', 'Import pages', 'https://wiki.endmyopia.org/wiki/Special:Import' );
}
jQuery( CustomizeModificationsOfSidebar );
$( function ()  {
/** * @source https://www.mediawiki.org/wiki/Snippets/Load_JS_and_CSS_by_URL * @revision 2020-04-04 */ mw.loader.using( ['mediawiki.util'], function () { var extraCSS = mw.util.getParamValue( 'withCSS' ), extraJS = mw.util.getParamValue( 'withJS' );  if ( extraCSS ) { // WARNING: DO NOT REMOVE THIS "IF" - REQUIRED FOR SECURITY (against XSS/CSRF attacks) if ( /^MediaWiki:[^&<>=%#]*\.css$/.test( extraCSS ) ) { mw.loader.load( '/w/index.php?title=' + encodeURIComponent( extraCSS ) + '&action=raw&ctype=text/css', 'text/css' ); } else { mw.notify( 'Only pages from the MediaWiki namespace are allowed.', { title: 'Invalid withCSS value' } ); } }  if ( extraJS ) { // WARNING: DO NOT REMOVE THIS "IF" - REQUIRED FOR SECURITY (against XSS/CSRF attacks) if ( /^MediaWiki:[^&<>=%#]*\.js$/.test( extraJS ) ) { mw.loader.load( '/w/index.php?title=' + encodeURIComponent( extraJS ) + '&action=raw&ctype=text/javascript' ); } else { mw.notify( 'Only pages from the MediaWiki namespace are allowed.', { title: 'Invalid withJS value' } ); } } });
} );

Latest revision as of 11:58, 14 June 2020