Przejdź do zawartości

Wikipedysta:PG/wp sk.js

Z Wikipedii, wolnej encyklopedii

Uwaga: aby zobaczyć zmiany po opublikowaniu, może zajść potrzeba wyczyszczenia pamięci podręcznej przeglądarki.

  • Firefox / Safari: Przytrzymaj Shift podczas klikania Odśwież bieżącą stronę, lub naciśnij klawisze Ctrl+F5, lub Ctrl+R (⌘-R na komputerze Mac)
  • Google Chrome: Naciśnij Ctrl-Shift-R (⌘-Shift-R na komputerze Mac)
  • Edge: Przytrzymaj Ctrl, jednocześnie klikając Odśwież, lub naciśnij klawisze Ctrl+F5.
  • Opera: Naciśnij klawisze Ctrl+F5.
( function()
{
	function attachToSk()
	{
		//console.log( "Attaching to WP:SK" );
		wp_sk.PGsk_cleanerWikiVaria = wp_sk.cleanerWikiVaria;
		wp_sk.extension += "+[[Wikipedysta:PG/wp sk.js|PGme]]";

		wp_sk.cleanerWikiVaria = function( str )
		{
			str = wp_sk.PGsk_cleanerWikiVaria( str );

			str = str.replace( /data śmierci nieznana\)/g, 'zm. ?\)' );
			str = str.replace( /zm\.\?\)/g, 'zm. ?)' );
			str = str.replace( /\[\[Stany Zjednoczone\|Amerykańskim\]\] Trybunałem Wojskowym/g, 'amerykańskim Trybunałem Wojskowym' );
			str = str.replace( /formacie pdf\]/g, 'formacie PDF\]' );
			str = str.replace( /format pdf\]/g, 'format PDF\]' );
			str = str.replace( /allmusic \(\(\(\s*(.*?) > Overview\s*\)\)\)/g, 'AllMusic – $1' );
			str = str.replace( /allmusic \(\(\( (.*?) > Review \)\)\)/g, 'AllMusic – $1' );
			str = str.replace( / \(([a-z][a-z])\)\]/g, '\] \{\{lang\|$1\}\}' );
			str = str.replace( / \(([a-z][a-z])\)/g, ' \{\{lang\|$1\}\}' );
			// refy za kropką
			str = str.replace( /\.<ref(.*?)>(.*?)<\/ref>/g, '<ref$1>$2<\/ref>\.' );
			str = str.replace( /\.<ref(.+?) \/>/g, '<ref$1 />\.' );
			str = str.replace( /\.\{\{(r|u)\|(.*?)}}/g, '\{\{$1\|$2}}\.' );
			str = str.replace( /\.\{\{odn\|(.+?)}}/g, '\{\{odn\|$1}}\.' );
			// imitacje polskiego cudzysłowu
			str = str.replace( /,,(.*?)"/g, '„$1”' );
			str = str.replace( /,,(.*?)”/g, '„$1”' );
            // de-enwikizacja
			str = str.replace( /(\d\d\d\d)[—–-]obecnie/g, 'od $1' );
			str = str.replace( /(\d\d\d\d)[—–-]nadal/g, 'od $1' );
            // // // // //
			// rok z przyklejonym "r", z kropką lub bez
			str = str.replace( /(\d+?)r\./g, '$1 r\.' );
			// wiek z przyklejonym "w."
			str = str.replace( /([\|IVX]+)w\]\]\./g, '$1 w.\]\]' );
			str = str.replace( /([\|IVX]+)w\.\]\]/g, '$1 w.\]\]' );
			str = str.replace( /([\s-–\/\(][IVX]+)w\./g, '$1 w.' );
			str = str.replace( /([\s-–\/\(][IVX]+)w(\W)/g, '$1 w.$2' );
			// w dniu...
			str = str.replace( /[w|W] dniu \[*\[*(\d+) (stycznia|lutego|marca|kwietnia|maja|czerwca|lipca|sierpnia|września|października|listopada|grudnia)\]*\]*/g, '$1 $2' );

			return str;
		};
	}

	if ( typeof( wp_sk ) !== 'undefined' )
	{
		//console.log( "WP:SK is present" );
		attachToSk();
	}
	else
	{
		//console.log( "WP:SK is not present" );
		var timer;
		var attemptsLeft = 600;
		timer = window.setInterval( function()
		{
			if ( typeof( wp_sk ) !== 'undefined' )
			{
				attachToSk();
				window.clearInterval( timer );
				return;
			}
			attemptsLeft--;
			if ( attemptsLeft < 0 )
			{
				//console.log( "WP:SK is not present, giving up" );
				window.clearInterval( timer );
			}
		}, 100 );
	}
} )();