User:GeorgeBarnick/global.js
Appearance
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)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
// Add purge link to vector menu
if (skin == "vector") {
$('<li id="ca-purge"><a href="/wiki/' + wgPageName + '?action=purge" title="Purge">Purge</a></li>').appendTo('#p-cactions .menu ul');
}
// [[File:Krinkle_RTRC.js]]
mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Krinkle/RTRC.js&action=raw&ctype=text/javascript');
// Gives some useful links on user, user talk and user contribution pages
// by [[m:user:Hoo man]] <http://meta.wikimedia.org/wiki/User:Hoo_man/Scripts/Useful_links>
mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Hoo_man/useful_links.js&action=raw&ctype=text/javascript');
// Add info on userpages listing their flags, account-age, contributions-count, and last-edit-time
mw.loader.load('//en.wikipedia.org/w/index.php?title=User:PleaseStand/userinfo.js&action=raw&ctype=text/javascript');
// Stolen from the nuke on contribs gadget by Grunny and SVG
if( wgCanonicalSpecialPageName === 'Contributions' ) {
$( contribLinks );
}
function contribLinks() {
var ug = wgUserGroups.join(' '),
ctype,
targ = $( 'input[name="target"]' ).val();
// poorman contribs type finder. -1 = existing user
try {
ctype = $( '#contentSub > a:first' ).attr( 'href' ).indexOf( 'User_talk' );
} catch(e) {
ctype = -1;
}
if( !targ ) {
return;
}
insertContentSubContribLink( '//meta.wikimedia.org/wiki/Special:CentralAuth?target=' + targ.replace( ' ', '+' ), 'CentralAuth' );
insertContentSubContribLink( '//tools.wmflabs.org/guc/?user=' + targ.replace( ' ', '+' ), 'global contribs' );
}
//jQuery version of Splarka's insertContentSubContribLink, by Grunny
function insertContentSubContribLink( link, text ) {
$( '#contentSub > a:last' ).after( ' | <a href="' + link + '" title="' + link + '">' + text + '</a>' );
}
// Lists number of active sysops on a wiki
mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Hoo_man/active_sysops.js&action=raw&ctype=text/javascript');
/**
* Unwatch from watchlist
*
* Add an "unwatch" link near each entry on the watchlist view ([[bugzilla:424]]).
*
* @source www.mediawiki.org/wiki/Snippets/Unwatch_from_watchlist
* @author Krinkle
* @revision 2014-12-17
*/
mw.hook( 'wikipage.content' ).add( function ( $content ) {
// Only on Watchlist and not in the /edit or /raw mode
if ( mw.config.get( 'wgCanonicalSpecialPageName' ) !== 'Watchlist' || location.href.indexOf( '/edit' ) > 0 || location.href.indexOf( '/raw' ) > 0 ) {
return;
}
mw.loader.using( 'mediawiki.api.watch' ).done( function () {
// Get the links
var $wlHistLinks = $content.find( 'ul.special > li > a[href$="action=history"]');
$wlHistLinks.each( function () {
var $unwatch,
$el = $( this ),
title = mw.util.getParamValue( 'title', this.href );
$unwatch = $el.clone()
.text( 'unwatch' )
.attr( 'href', function ( i, val ) {
return val.replace( 'action=history', 'action=unwatch' );
} )
.on( 'click', function ( e ) {
new mw.Api().unwatch( title )
.done( function () {
$unwatch.css( { pointerEvents: 'none', opacity: 0.5 } );
} )
.fail( function () {
$unwatch.off( 'click' ).append( ' (try again?)' );
} );
e.preventDefault();
} );
$el.after( $unwatch ).after( ' | ' );
} );
} );
} );