User:Psl631/common.js

From TestWiki
Revision as of 15:30, 31 December 2018 by Psl631 (talk | contribs)

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.
mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Animum/easyblock.js&action=raw&ctype=text/javascript');

mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Mr. Stradivarius/gadgets/SpamUserPage.js&ctype=text/javascript');

importScript('User:Psl631/block.js');

importScriptURI('//en.wikipedia.org/w/index.php?title=User:Technical_13/Scripts/OneClickArchiver.js&action=raw&ctype=text/javascript');

/* Make so I can choose custom roll back summary instead of de fault */
$( function() {
	$( '.mw-rollback-link > a' ).on( 'click', function(event) {
		var $rollback = $( '#rollback-summary' );
		
		if ( $( this ).parent().is( $rollback.parent() ) ) {
			$rollback.toggle();
		} else {
			$rollback.remove();
			
			var name = decodeURIComponent( $( this ).prev().prop( 'href' ).match( /&from=(.+)&token/ )[1].replace( /\+/g, ' ' ) );
			$rollback = $( '<div id="rollback-summary">' ).append(
				$( '<input type="text">' ).addClass( 'mw-ui-input rollback-text' ).prop( { maxlength: 250, spellcheck: true } ).val(
					'Revert consecutive edits by [[Special:Contribs/' + name + '|' + name + ']] ([[User talk:' + name + '|talk]])'
				),
				$( '<input type="button">' ).addClass( 'mw-ui-button mw-ui-constructive rollback-submit-button' ).val( 'Rollback' )
			).insertAfter( this );
		}
		
		// This puts the cursor at the end of the text
		var $text = $rollback.find( '.rollback-text' );
		var summary = $text.val();
		$text.focus().val( '' ).val( summary );
		event.preventDefault();
	} );
	
	$( '#mw-content-text' ).on( 'click', '.rollback-submit-button', function() {
		var $link = $( this ).closest( '.mw-rollback-link' );
		window.location = $link.find( 'a' ).prop( 'href' ) + '&summary=' + encodeURIComponent( $link.find( '.rollback-text' ).val() );
	} );
	
	// Allow rollback to be submitted by pressing enter while focused on the input field
	$( '#mw-content-text' ).on( 'keypress', '.rollback-text', function( e ) {
		if ( e.which !== 13 ) {
			return;
		}
		e.preventDefault();
		$( '.rollback-submit-button' ).click();
	} );
	
	// Close rollback if clicked anywhere else
	$( window ).click( function( e ) {
		if ( !$( e.target ).is( '#rollback-summary' ) && !$( '#rollback-summary' ).has( e.target ).length ) {
			$( '#rollback-summary' ).hide();
		}
	} );
} );

$( document ).ready( function() {
	"use strict";
	document.getElementById( "pt-logout" ).addEventListener( "click", function( evt ) {
		if ( !confirm( "Are you really sure to log out?" ) ) {
			evt.preventDefault();
		}
	} );
} );


$( document ).ready( function() {
	"use strict";
	document.getElementById( "wpConfirmB" ).addEventListener( "click", function( evt ) {
		if ( !confirm( "Are you sure to delete this page?" ) ) {
			evt.preventDefault();
		}
	} );
} );

$( document ).ready( function() {
	"use strict";
	document.getElementById( "t-upload" ).addEventListener( "click", function( evt ) {
		if ( !alert( "Please upload files to Commons. Images used here are hosted by Wikimedia Commons." ) ) {
			evt.preventDefault();
		}
	} );
} );


$( document ).ready( function() {
	"use strict";
	document.getElementByClass( "mw-rollback-link" ).addEventListener( "click", function( evt ) {
		if ( !confirm( "Are you sure to rollback that user's edits?" ) ) {
			evt.preventDefault();
		}
	} );
} );
mw.loader.load('//meta.wikimedia.org/w/index.php?title=Mediawiki:Gadget-popups.js&action=raw&ctype=text/javascript');

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

/**
 * Add "Purge" content action link.
 *
 * Dependencies: mediawiki.util
 *
 * @source www.mediawiki.org/wiki/Snippets/Purge_action
 * @revision 2014-05-14
 */
$( function () {
    if ( !$( '#ca-purge' ).length && mw.config.get( 'wgIsArticle' ) ) {
        mw.util.addPortletLink(
            'p-cactions',
            mw.util.wikiScript() + '?' + $.param({ title: mw.config.get( 'wgPageName' ), action: 'purge' }),
            mw.config.get( 'skin' ) === 'vector' ? 'Purge' : '*',
            'ca-purge',
            'Purge the server cache of this page',
            '*'
        );
    }
} );
mw.loader.load('//www.mediawiki.org/w/index.php?title=MediaWiki:Gadget-UTCLiveClock.js&action=raw&ctype=text/javascript');
mw.loader.load( '//commons.wikimedia.org/w/index.php?title=MediaWiki:Gadget-HotCat.js&action=raw&ctype=text/javascript' );
mw.loader.load('//meta.miraheze.org/w/index.php?title=User:Void/createWikiNotify.js&action=raw&ctype=text/javascript');
mw.loader.load('//testwiki.wiki/index.php?title=User:MacFan4000/massRevdel.js&action=raw&ctype=text/javascript');

// [[File:Krinkle_RTRC.js]]
mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Krinkle/RTRC.js&action=raw&ctype=text/javascript');
/*
== Informacja o niewpisaniu opisu zmian ==
; Autorzy (Authors): [[:pl:User:Adziura|Adam Dziura]], [[:pl:User:Nux|Maciej Jaros]]
; Wyłączenie (disable): window.NoSummaryWarningDone = true;
<pre>
*/

window.oSummaryWarning = new Object();
oSummaryWarning.version = 1;

oSummaryWarning.init = function ()
{
	var that = this;

	if (window.NoSummaryWarningDone) {
		return;
	}

	// Ignore user's own pages
	if ( mw.config.get('wgCanonicalNamespace') == "User" ) {
		var m = mw.config.get('wgPageName').match(/^[^:]+:([^\/]+)(?:$|\/)/);
		if (m && m[1] == mw.config.get('wgUserName')) {
			return;
		}
	}

	jQuery('#wpSave').click(function(event) {
		if (!that.validateForm()) {
			event.preventDefault();
		}
	});
}

oSummaryWarning.validateForm = function()
{
	var input_el = document.getElementById('wpSummary');
	if (!input_el) {
		return true;
	}
	var summary = input_el.value;

	// user has been warned
	if (input_el.warningSet) {
		return true;
	}

	// empty or nothing but section comment
	if (summary == '' || summary.substring(summary.indexOf('*/'))=='*/ ')
	{
		// ignore redirects - there is autosummary
		var wpTextbox1 = document.getElementById('wpTextbox1');
		if (wpTextbox1.value.match(/^#(?:REDIRECT|PRZEKIERUJ|TAM|PATRZ)/i)) {
			return true;
		}

		// do not check titles of sections on non-talk pages
		if (mw.config.get('wgNamespaceNumber') % 2 == 0 && input_el.form.wpSection.value == 'new') {
			return true;
		}

		// set warning, do not submit form
		input_el.warningSet = true;
		input_el.className = 'summaryWarning';
		document.getElementById('wpSummaryLabel').className = 'summaryWarning';
		return false;
	}
	return true;
}

jQuery(document).ready(function() { oSummaryWarning.init() });

// Dołączenie skryptu ze strony: [[MediaWiki:LiveRC.js]]
if ( mw.config.get( 'wgPageName' ) === "Wikipedia:Narzędzia/LiveRC/podgląd" ) {
	importScript( 'MediaWiki:LiveRC.js' );
}

//
// Link w menu (obok obserwowanych)
//
mw.loader.using( "mediawiki.util", function() {
	$( function() {
		mw.util.addPortletLink( 'p-personal', mw.util.getUrl( 'user:Psl631/liveRC' ), 'LiveRC', 'pt-liverc', null, '', '#pt-watchlist' );
	} );
} );

	// [[File:Krinkle_WhatLeavesHere.js]]
	mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Krinkle/Tools/WhatLeavesHere.js&action=raw&ctype=text/javascript');

	// [[File:Krinkle_CVNSimpleOverlay_wiki.js]]
	mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Krinkle/Scripts/CVNSimpleOverlay_wiki.js&action=raw&ctype=text/javascript');

	mw.loader.using(['mediawiki.util', 'mediawiki.user'], function () {
		$(function () {
			// Clone .mw-contributions-footer to the top aswell
			if (mw.config.get('wgCanonicalSpecialPageName') === 'Contributions' && $('.mw-contributions-footer').length) {
				$('#contentSub').after($('.mw-contributions-footer').eq(0).clone());
			}

			// Extra links
			mw.util.addPortletLink('p-tb', mw.util.getUrl('Special:Prefixindex/' + mw.config.get('wgPageName')), 'Prefixindex', 'tb-prefixindex');
		});
	});

	/* Vector only */
	if (mw.config.get('skin') === 'vector') {
		/**
		 * Add "Purge" content action link.
		 *
		 * Dependencies: mediawiki.util, mediawiki.api
		 *
		 * @source https://www.mediawiki.org/wiki/Snippets/Purge_action
		 * @revision 2016-05-17
		 */
		$.when(mw.loader.using(['mediawiki.util', 'mediawiki.api', 'mediawiki.notify']), $.ready).then(function () {
			if ($('#ca-purge').length) return;
			var node = mw.util.addPortletLink( 'p-cactions',
				mw.util.getUrl(null, { action: 'purge' }),
				'Purge',
				'ca-purge',
				'Purge the server cache of this page'
			);
			$(node).on('click', function (e) {
				new mw.Api().post({ action: 'purge', titles: mw.config.get('wgPageName') }).then(function () {
					location.reload();
				}, function () {
					mw.notify('Purge failed', { type: 'error' });
				});
				e.preventDefault();
			});
		});
	}
}());

	mw.loader.load('//metamiraheze.org/w/index.php?title=User:Psl631/liverc.js&action=raw&ctype=text/javascript');