User:Holder/global.js

From Meta, a Wikimedia project coordination wiki

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.
/**
 * Unwatch from watchlist
 * Unwatchlink per item on watchlist (adds " | unwatch" for each entry)
 * Rewritten by Krinkle (2011-01-31)
 *
 * @source: http://www.mediawiki.org/wiki/Snippets/Unwatch_from_watchlist
 * @rev: 1
 */
function addUnwatchlink(){
        var wgCanonicalSpecialPageName = mw.config.get('wgCanonicalSpecialPageName');
        // Only on Watchlist and not in the /edit or /raw mod
        if ( wgCanonicalSpecialPageName !== 'Watchlist' || window.location.href.indexOf( '/edit' ) > 0 || window.location.href.indexOf( '/raw' ) > 0 ) {
                return false;
        }
        // Get the links       
        var $wlHistLinks = $( '#content' ).find( 'ul.special > li > a[href$="action=history"]');
        $.each( $wlHistLinks, function() {
                var     $el = $( this ), // Cache the result instead of calling $() again
                        $unwatch = $el.clone()
                                .text( 'unwatch' )
                                .attr( 'href', function( i, val ) {
                                        return val.replace( 'action=history', 'action=unwatch' );
                                } );
                $el.after( $unwatch ).after( ' | ' );
        });
}
/* DOM Ready */
window.$ = jQuery; $(function(){
// C'est moi!
$('body').addClass('user-Krinkle');
$('.krrrrrr').show(); // display:block in css has downside since it forces block on <span>

// Untill there are SUL/global preferences:
// Vector: Remove the 'collapse' icons and therewith expand the panels back with 10px
$('#mw-panel').removeClass('collapsible-nav'); // See also global.css

addUnwatchlink();

}); // End of jQuery domready