User:Akodone/global.js

/* Opis przy usuwaniu – by Rail */ if (mw.config.get('wgAction') === 'delete' && !!document.getElementById('wpReason')) { document.getElementById('wpReason').value = ''; }

// Quick theme changer – by Rail mw.loader.using( ['mediawiki.api', 'mediawiki.util'], function {	if ( mw.config.get( 'skin' ) !== 'fandomdesktop' ) {		return;	}	function themeSwitch( theme ) {		new mw.Api.saveOption( 'theme', theme ).done( function( d ) { if ( d.options === 'success' ) { location.reload; }		} );	}	$( '.fandom-community-header__community-name-wrapper' ).append( $( ' ', { class: 'quick-theme-switcher' } ).append(			$( '', { text: '(light)', href: '#', click: function { themeSwitch( 'light' ); }			} ), ' ',			$( '', { text: '(dark)', href: '#', click: function { themeSwitch( 'dark' ); }			} ), ' ',			$( '', { text: '(wiki)', href: '#', click: function { themeSwitch( 'wiki' ); }			} )		)	); } );

/*** Script for finding articles without interwiki in certain language, you can use it if you want but it's in Polish – by me ***/ mw.loader.using( 'mediawiki.api', function {	// Check if a page is called User:Your username/Bez interwiki	const withoutIWpagename='Bez interwiki';		if ( !(mw.config.get('wgNamespaceNumber')==2 && mw.config.get('wgTitle') == mw.config.get('wgUserName') + '/' + withoutIWpagename) ) {			return;	}	// Remove all noarticletext instances to clean the page	const noarticletext=document.getElementsByClassName('noarticletext');		Array.from( noarticletext ).forEach( function ( i ) { i.remove; });

// Create article structure const contentArea=document.getElementById('mw-content-text');

//first heading const poleWyboruH2=document.createElement('h2'); poleWyboruH2.textContent='Pole wyboru'; contentArea.appendChild(poleWyboruH2); //div for select const poleWyboruDiv=document.createElement('div'); poleWyboruDiv.setAttribute('id', 'polewyborujezykow'); contentArea.appendChild(poleWyboruDiv); //second heading const wynikiH2=document.createElement('h2'); wynikiH2.textContent='Wyniki'; contentArea.appendChild(wynikiH2); //ol for articles list const wynikiOL=document.createElement('ol'); wynikiOL.setAttribute('id', 'bezinterwikilista'); contentArea.appendChild(wynikiOL); // Variables var api = new mw.Api; //Create new api var chosenLanguage; //variable for chosen language //create Select var select=document.createElement('select'); select.setAttribute('id', 'languagechange'); select.setAttribute('name', 'languagechange'); poleWyboruDiv.appendChild(select); //create first option of the select var firstOption=document.createElement('option'); firstOption.setAttribute( 'value', 'none' ); firstOption.textContent='Wybierz język!'; select.appendChild(firstOption)

//create list of languages api.get({		action: "query",		meta: "siteinfo",		formatversion: "2",		siprop: "interwikimap"	}).done( function ( siteinforesult ) {		//create list of options		siteinforesult.query.interwikimap.forEach( function ( siresult ) { if ( siresult.language ) { var option=document.createElement('option'); option.setAttribute( 'value', siresult.prefix ); option.textContent=siresult.language; select.appendChild(option) }		})		//add Event listener to the select		select.addEventListener('change', function (e) { if (e.target.value!=='none') { chosenLanguage=e.target.value; cleanLi; getLinksWithoutIW(chosenLanguage); }		})	})

//Main function function getLinksWithoutIW (langToCheck, interwikicontinue) { //get list of all pages api.get({			action: "query",			list: "allpages",			formatversion: "2",			aplimit: "max",			apcontinue: interwikicontinue		}).done( function ( allpagesresult ) {			//get langlinks for each page			allpagesresult.query.allpages.forEach( function ( apresult ) { api.get({					action: "query",					prop: "langlinks",					titles: apresult.title,					formatversion: "2",					lllimit: "max"				}).done( function ( interwikiresult ) {								var iwarticle=interwikiresult.query.pages[0];								if(!(iwarticle.langlinks)) {						//if there are no langlinks, log the page						createLi( iwarticle.title );					} else {						//check if chosen language is in interwikis						var hasChosenLanguage;										iwarticle.langlinks.forEach( function ( iwresult ) { if ( iwresult.lang === langToCheck ) { hasChosenLanguage=true; }						})						//if the article has interwikis, but not in chosen language, log it											if (!hasChosenLanguage) {							createLi( iwarticle.title );						}						}				})//close second api call })//close forEach for allpagesresult.query.allpages			if (allpagesresult.continue) {				//call the function again to show all results				getLinksWithoutIW(chosenLanguage, allpagesresult.continue.apcontinue);			} else {				//Inform about updated list				mw.notify( 'Lista zaktualizowana pomyślnie!' );			}		})//close first api call }

//create li	function createLi (pagetitle) { var li=document.createElement('li'); li.setAttribute('class', 'bezinterwikilistitem'); li.innerHTML='' + pagetitle + ''; wynikiOL.appendChild(li); }

//function for removing li	function cleanLi { var listItem=document.getElementsByClassName('bezinterwikilistitem'); Array.from( listItem ).forEach( function ( i ) {			i.remove;		}); } } ); /*** Interwiki finder – end ***/

/* Skrypty z Dev Wiki */ window.fdButtons = [ {       summary: 'Nieużywany plik', label: 'NU' },   {        summary: 'Brak licencji', label: 'BL' },   {        summary: 'Niedziałający film', label: 'F'   }, {       summary: 'Niepotrzebna strona', label: 'NP' },   {        summary: 'Niepotrzebny szablon', label: 'NS' },   {        summary: 'Zbędne przekierowanie', label: 'ZP' },   {        summary: 'Wandalizm', label: 'W'   }, {       summary: 'Spam', label: 'S'   }, {       summary: 'Prośba autora', label: 'PA' } ];

/* Importy */ importArticles({   type: 'script',    articles: [        'u:dev:MediaWiki:FastDelete/code.js',        'u:dev:MediaWiki:SyntaxHighlight.js',        'u:dev:MediaWiki:MassPatrol/code.js',        'u:dev:MediaWiki:AjaxBatchDelete.js',        'u:dev:MediaWiki:ListFiles/code.js',        'u:dev:MediaWiki:MassRename/code.js',        'u:dev:MediaWiki:FileUsageAuto-update/code.js',        'u:dev:MediaWiki:MassCategorization/code.js',        'u:dev:MediaWiki:MassEdit/code.js',    ] });