User:Nw520/common.js
Jump to navigation
Jump to search
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
// Jobs
mw.hook( 'wikipage.content' ).add( function hook () {
mw.hook( 'wikipage.content' ).remove( hook );
mw.loader.using( [ 'mediawiki.api' ] ).then( function () {
var api = new mw.Api();
api.get( {
action: 'query',
meta: 'siteinfo',
siprop: 'statistics'
} ).done( function ( data ) {
var li = document.createElement( 'li' );
li.innerHTML = 'Jobs: ' + data.query.statistics.jobs;
document.querySelector( '#p-personal ul' ).appendChild( li );
} );
} );
} );
// Watchlist: Select redlinks
mw.hook( 'wikipage.content' ).add( function ( $container ) {
if ( mw.config.get( 'wgPageName' ) !== 'Special:EditWatchlist' ) {
return;
}
mw.loader.using( [ 'oojs-ui', 'oojs-ui-core' ] ).then( function () {
setTimeout( function() {
const watchlist = $container[ 0 ].querySelector( '.mw-htmlform-ooui-wrapper.oo-ui-panelLayout.oo-ui-panelLayout-padded.oo-ui-panelLayout-framed' );
const button = new OO.ui.ButtonWidget( {
label: 'Select redlinks'
} );
button.on( 'click', function () {
watchlist.querySelectorAll( '.oo-ui-labelElement.oo-ui-fieldLayout.oo-ui-fieldLayout-align-inline' ).forEach( function ( item ) {
if ( item.querySelectorAll( '.new:first-child' ).length > 0 ) {
item.querySelector( 'input' ).click();
}
} );
} );
watchlist.querySelector( '.mw-htmlform-ooui-header' ).insertAdjacentElement( 'afterend', button.$element[ 0 ] );
}, 3000 );
} );
} );