User:Nastoshka/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.
/**
 * Hoo useful links tool
 */
 // 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');

// // Edit crosswiki nella pagina dei contributi
// // Original code: http://www.mediawiki.org/wiki/MediaWiki:Gadget-SpecialNukeOnContribsLink.js
// // this version: [[user:Wim b]]
// if( mw.config.get('wgCanonicalSpecialPageName') === 'Contributions' ) {
// 	$( contribTool );
// }

// function contribTool() {
// 	var	ug = mw.config.get('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;
// 	}

// 	var regIP = /(([0-9]+\.){3}[0-9]|^([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4}$)/;
// 	var isIP = regIP.test(targ);

//         insertContentSubContribTool('//tools.wmflabs.org/guc/?user=' + targ.replace( ' ', '+' ) + '', 'crosswiki edits' );
//         if (isIP === false )    insertContentSubContribTool(mw.config.get('wgServer') +'/wiki/Special:CentralAuth/' + targ.replace( ' ', '_' ) + '', 'Central Auth' );
//         if (isIP === true )    insertContentSubContribTool('//whois.domaintools.com/' + targ.replace( ' ', '+' ) + '', 'whois' );

// }

// Tagger (example, speedy deletions)
// By [[m:User:Hoo man]], https://meta.wikimedia.org/wiki/User:Hoo_man/Scripts/Tagger
mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Hoo_man/tagger.js&action=raw&ctype=text/javascript');
	if(typeof window.taggerConfig === 'undefined') window.taggerConfig = {};
	taggerConfig.allowSectionTags = true;
//<nowiki>
	if(typeof window.taggerConfig === 'undefined') window.taggerConfig = {};
taggerConfig.tags = [];
taggerConfig.editSummary = [];
taggerConfig.tags[1] = '{{delete|seem to be a test}}';
taggerConfig.editSummary[taggerConfig.tags[1]] = '+ delete, test';
taggerConfig.tags[2] = '{{delete|vandalism}}';
taggerConfig.editSummary[taggerConfig.tags[2]] = '+ delete, vandalism';
taggerConfig.tags[3] = '{{delete|nonsense}}';
taggerConfig.editSummary[taggerConfig.tags[3]] = '+ delete, nonsense';
taggerConfig.tags[4] = '{{delete|not in the project language}}';
taggerConfig.editSummary[taggerConfig.tags[4]] = '+ delete';
taggerConfig.tags[5] = '{{stub}}';
taggerConfig.editSummary[taggerConfig.tags[5]] = 'stub';
//</nowiki>


/* Also this by Krinkle. Toglie dagli osservati speciali
 * @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( ' | ' );
		} );
	} );
} );

// Shows the number of active (one log entry in the last 7 days, or as configured) sysops, uses data from the toolserver
// by [[m:user:Hoo man]] <http://meta.wikimedia.org/wiki/User:Hoo_man/Scripts/Active_sysops>
mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Hoo_man/active_sysops.js&action=raw&ctype=text/javascript');

/**
 * Special:WhatLinksHere edit, history and delete links
 *
 * Adds "edit", "hist" and "delete" link to [[Special:WhatLinksHere]]
 *
 * @source: http://www.mediawiki.org/wiki/Snippets/Special:WhatLinksHere_history_link
 * @rev: 2
 */
$( '#mw-whatlinkshere-list li' ).each( function() {
        var url = mw.config.get( 'wgScript' ) + '?title=' + encodeURIComponent( $( 'a:first', this ).text() ) + '&action=';
        $( '.mw-whatlinkshere-tools a:last', this )
                .after( $( '<a>' ).attr( 'href', url + 'delete' ).text( 'delete' ) ).after( ' | ' )
                .after( $( '<a>' ).attr( 'href', url + 'edit' ).text( 'edit' ) ).after( ' | ' );
});

/** Rollback prompt **/
$(document).ready(function(){
    var rollbackPrompt=function(ev){
        var summary = prompt("Inserisci un oggetto:", "<default>");
        if(summary == null || summary == "") {
            ev=ev || window.event;
            if(ev.preventDefault) ev.preventDefault();
            if(ev.stopPropagation) ev.stopPropagation();
            ev.returnValue = false;
            ev.cancelBubble = true;
            return false;
        }
        if(summary != "<default>")
            this.href = this.href.replace("?", "?summary=" + encodeURIComponent(summary) + "&");
        return true;
    };
 
    var links=document.getElementById('content').getElementsByTagName('a');
    for(var i=links.length-1; i>=0; i--){
        if(/[?&]action=rollback([&#]|$)/.test(links[i].href))
            links[i].onclick=rollbackPrompt;
    }
 
});

// [[File:Krinkle_RTRC.js]]
(mw.loader.getState('ext.gadget.rtrc') ? mw.loader.load('ext.gadget.rtrc') : mw.loader.load('https://www.mediawiki.org/w/load.php?modules=ext.gadget.rtrc&lang=' + mw.config.get('wgUserLanguage', 'en')));

/**     ******************************************************************** 
 * 
 * Strumento potenziato per le Regex e inserimento template con un click. Adattato a it.wikivoyage.org da Nastoshka
 * Al posto dei template, per chi ne è capace, si possono aggiungere anche script JS tramite il parametro <tt>script:</tt>
 * Può essere personalizzato co numerosi parametri utili.
 * @see https://meta.wikimedia.org/wiki/TemplateScript
 * @source https://tools-static.wmflabs.org/meta/scripts/pathoschild.templatescript.js
 */
//importScript("Utente:Nastoshka/TemplateScript.js");
importScript("User:Nastoshka/TemplateScript.js");

// Smart Patrol tool
mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Nastoshka/smartPatrol.js&action=raw&ctype=text/javascript');

// More menu tool
mw.loader.load('https://meta.wikimedia.org/w/index.php?action=raw&ctype=text/javascript&title=MediaWiki:MoreMenu.import.js');

// Twinkle global
mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Xiplus/TwinkleGlobal/load.js&action=raw&ctype=text/javascript');