ᱧᱮᱛᱮᱞ: ᱨᱩᱠᱷᱤᱭᱟᱹ ᱦᱩᱭ ᱠᱟᱛᱮ, ᱟᱢᱟᱜ ᱵᱨᱟᱣᱡᱚᱨ ᱠᱮᱪ ᱵᱟᱭᱯᱟᱥ ᱦᱩᱭᱩᱜ ᱛᱟᱢᱟ ᱚᱫᱚᱞ ᱠᱚ ᱧᱮᱞ ᱞᱟᱹᱜᱤᱫ ᱾

  • ᱯᱷᱟᱭᱟᱨᱯᱷᱚᱠᱥ / ᱥᱟᱯᱷᱟᱨᱤ: 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: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Go to Menu → Settings (Opera → Preferences on a Mac) and then to Privacy & security → Clear browsing data → Cached images and files.
mw.loader.load('//www.wikidata.org/w/index.php?title=User:Yair_rand/checksitelinks.js&action=raw&ctype=text/javascript');
mw.loader.load('//en.wikipedia.org/w/index.php?title=User:BrandonXLF/MobileView.js&action=raw&ctype=text/javascript'); // [[User:BrandonXLF/MobileView.js]]
mw.loader.load( '//en.wikipedia.org/w/index.php?title=User:Danski454/wikidata_Qnum.js&action=raw&ctype=text/javascript' );
//importScript('User:Rocky 734/hello-world.js');
importScriptURI('//en.wikipedia.org/w/index.php?title=User%3ACaorongjin%2Fwordcount.js&action=raw&ctype=text/javascript');
importScriptURI('//en.wikipedia.org/w/index.php?title=User:Novem Linguae/Scripts/VisualEditorEverywhere.js&action=raw&ctype=text/javascript');
importScriptURI('//en.wikipedia.org/w/index.php?title=User:Eizen/PageCreator.js&action=raw&ctype=text/javascript');
mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Nardog/PlayAudioNow.js&action=raw&ctype=text/javascript');
mw.loader.load('//meta.wikimedia.org/w/index.php?title=MediaWiki%3AMoreMenu.import.js&action=raw&ctype=text/javascript');
//mw.loader.load('//en.wikipedia.org/w/index.php?title=User%3AQwerfjkl%2Fscripts%2FRETF.js&action=raw&ctype=text/javascript'); // [[User:Qwerfjkl/scripts/RETF.js]]
importScript('User:Ucucha/duplinks.js'); // [[User:Ucucha/duplinks]]
importScript("User:Awesome Aasim/CatMan.js"); //Linkback: [[User:Awesome Aasim/CatMan.js]]
importScript('User:Alex 21/script-functions.js'); // [[User:Alex 21/script-categoriessort]]
importScript('User:Alex 21/script-categoriessort.js');
mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Joeytje50/JWB.js/load.js&action=raw&ctype=text/javascript');
mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:BrandonXLF/ReferenceExpander.js&action=raw&ctype=text/javascript');

if ( $.inArray( mw.config.get( 'wgAction' ), ['edit', 'submit'] ) > -1 ) {
	mw.loader.load('//en.wikipedia.org/w/index.php?title=User:V111P/js/smartLinkingLoader.js'
			+ '&action=raw&ctype=text/javascript');
}


$(document).ready(function()
{
		if(mw.config.get("wgCanonicalNamespace") == "")
		{
			var subjectName;
			var pageName = mw.config.get("wgPageName");
			if(pageName.charAt(pageName.length - 1) == ")")
			{
				subjectName = pageName.substring(0, pageName.lastIndexOf("(") - 1);
			}
			else
			{
				subjectName = pageName;
			}
			var newNode = " <a href='http://www.google.com/search?q=" + encodeURIComponent(subjectName.replace(/_/g, " ")).replace(/'/g,"%27") + "+-wikipedia.org' target='_blank'><span style='font-size:x-small;'>Search Google</span></a>";
			$("#firstHeading").append(newNode);
/*
			var searchNode = document.createElement("a");
			searchNode.href = "http://www.google.com/search?q=" + encodeURIComponent(subjectName.replace(/_/g, " ")) + "+-wikipedia.org";
			searchNode.target = "_blank";
			searchNode.innerHTML = " <span style='font-size:x-small;'>Search Google</span>";
			document.getElementById("firstHeading").appendChild(searchNode);
*/
		}
});

/**
 * script-installer loader
 */

if( mw.config.get( "wgNamespaceNumber" ) > 0 ) {
    var jsPage = mw.config.get( "wgPageName" ).slice( -3 ) === ".js" ||
        mw.config.get( "wgPageContentModel" ) === "javascript";
    if( jsPage || document.getElementsByClassName( "scriptInstallerLink" ).length ||
            document.querySelector( "table.infobox-user-script" ) ) {
mw.loader.load('//en.wikipedia.org/w/index.php?title=MediaWiki%3AGadget-script-installer-core.js&action=raw&ctype=text/javascript');
    }
}



/*
##############################################################################################
##############################################################################################
By User User:SD0001 from
User:SD0001/shortdescs-in-category.js
*/

/**
 * Shows button on category pages to see short description of all pages in the category.
 * 
 * Look for a button saying "Show SDs" towards the right, above the list of pages.
 * 
 */

$.ready.then(function() {

	if (mw.config.get('wgNamespaceNumber') !== 14) {
		return;
	}
	
	$('#mw-pages > p').append(
		$('<button>').text('Show SDs').attr('id', 'showSD-button').addClass('mw-ui-button').css('float', 'right').click(showsSDs)
	);

	if (location.href.indexOf('&showSD=y') !== -1) {
		showsSDs();
	}

});

function fixLinks(showingSDs) {
	if (showingSDs) {
		$('#mw-pages > a').each(function() {
			if (this.href.indexOf('#') !== -1) {
				this.href = this.href.replace(/#/, '&showSD=y#');
			} else {
				this.href += '&showSD=y';
			}
		});
	} else {
		$('#mw-pages > a').each(function() {
			this.href = this.href.replace(/&showSD=y/g, '');
		});
	}
}

function hideSDs(e) {
	if (e) e.preventDefault();
	
	fixLinks(false);
	$('#showSD-button').text('Show SDs').off('click').on('click', showsSDs);
	$('.cat-shortdesc-none, .cat-shortdesc-local, .cat-shortdesc-wikidata').remove();
	
}

function showsSDs(e) {
	if (e) e.preventDefault();

	fixLinks(true);
	$('#showSD-button').text('Hide SDs').off('click').on('click', hideSDs);	
	
	mw.util.addCSS('.cat-shortdesc-none { color: red } .cat-shortdesc-wikidata { color: MediumVioletRed }');

	var titles = $('#mw-pages li').get().map(function(e) {
		var a = e.querySelector('a');
		return mw.Title.newFromText(a.textContent).getSubjectPage().toText();
	});

	var titleSets = arrayChunk(titles, 50);
	var api = new mw.Api();
	var wdApi = new mw.ForeignApi('https://www.wikidata.org/w/api.php', { anonymous: true });

	var promiseArr = titleSets.map(function(set) {
		return api.get({
			"action": "query",
			"format": "json",
			"prop": "description",
			"titles": set,
			"formatversion": "2",
		});
	});
	var promiseArrWd = titleSets.map(function(set) {
		return wdApi.get({
			"action": "wbgetentities",
			"sites": "enwiki",
			"titles": set,
			"props": "descriptions|sitelinks",
			"languages": "en",
			"sitefilter": "enwiki"
		});
	});

	$.when.apply($, promiseArr.concat(promiseArrWd)).then(function() {
		var descs = {};
		Array.prototype.slice.call(arguments).forEach(function(response) {
			var json = response[0];
			if (json.query) { // enwiki API output
				json.query.pages.forEach(function(pg) {
					descs[pg.title] = {
						value: pg.description
					};
				});		
			} else if (json.entities) { // wikidata API output
				$.each(json.entities, function(id, data) {
					var pagename = data.sitelinks && data.sitelinks.enwiki && data.sitelinks.enwiki.title;
					if (pagename) {
						var entry = descs[pagename];
						if (entry && !entry.value) {
							entry.value = data.descriptions && data.descriptions.en && data.descriptions.en.value;
							entry.wd = true;
						} 
					}
				});
			}
		});	
		attachDescriptions(descs);
	});
}

function attachDescriptions(descs) {
	$('#mw-pages li').get().forEach(function(e) {
		var a = e.querySelector('a');
		var title = mw.Title.newFromText(a.textContent).getSubjectPage().toText();
		if (!descs[title] || !descs[title].value) {
			$(e).append(
				$('<span>').text(' – no shortdesc')
					.addClass('cat-shortdesc-none')
			);
		} else {
			$(e).append(
				$('<span>').text(' – ' + descs[title].value)
					.addClass(descs[title].wd ? 'cat-shortdesc-wikidata' : 'cat-shortdesc-local')
			);
		}
	});
}

function arrayChunk(arr, size) {
	var numChunks = Math.ceil(arr.length / size);
	var result = new Array(numChunks);
	for (var i = 0; i < numChunks; i++) {
		result[i] = arr.slice(i * size, (i + 1) * size);
	}
	return result;
}

//<nowiki>
/* Cat-a-lot - changes category of multiple files */
mw.loader.using(['jquery.ui', 'mediawiki.util'], function(){
	mw.loader.load('//commons.wikimedia.org/w/load.php?modules=ext.gadget.Cat-a-lot');
});
////////// Cat-a-lot user preferences //////////
window.catALotPrefs = {"watchlist":"preferences","minor":true,"editpages":true,"docleanup":false,"subcatcount":10};
////////////////////////////////////catALotEnd//
//</nowiki>


/* This script adds a "Possible backlinks" link to the left toolbar, which searches out articles
where possible backlinks may be created for the current page. To use the script, add the following line to Special:MyPage/common.js:
 
importScript('User:Lourdes/Backlinks.js'); // Linkback: [[User:Lourdes/Backlinks.js]]

*/

mw.loader.using("mediawiki.util", function() {
    mw.util.addPortletLink(
        "p-tb",
        "https://sat.wikipedia.org/w/index.php?title=Special:Search&search=\""+encodeURIComponent(mw.config.get("wgPageName"))+"\"+-linksto%3A"+encodeURIComponent(mw.config.get("wgPageName")),
        "Possible backlinks",
        "t-wdlh-check",
        "View articles where possible backlinks may be created for the current page"
    );
});












//remove red links
$(document).ready( function () {
    // Remove redlinks if they exist upon pageload
    redlinks_removeall();
});
$(function($) {
	mw.loader.using( ['mediawiki.util'] ).then( function () {
		var portletlink = mw.util.addPortletLink('p-tb', '#', 'Remove redlinks');
		$(portletlink).click( function(e) {
			e.preventDefault();
			// Default parameters, and begin script on regular view of article
			var loc = window.location.href;
			var redlinks; var i;
			
			// Gather all redlinks with class "new"
			redlinks = [];
			var a = document.getElementsByTagName('a');
			for (i = 0; i < a.length; i++) {
				if (a[i].getAttribute('class') == "new") {
					redlinks[redlinks.length] = a[i].href.replace('https://sat.wikipedia.org/w/index.php?title=','').replace('&action=edit&redlink=1','');
					redlinks[redlinks.length-1] = redlinks[redlinks.length-1].replace(/_/g,' ');
					redlinks[redlinks.length-1] = decodeURIComponent(redlinks[redlinks.length-1]);
				}
			}
			
			// Save all redlinks
			if (redlinks.length > 0) {
				localStorage.redlinks = JSON.stringify(redlinks);
				
				// If we are in the edit page, then remove redlinks automatically; if we are on the reading page, then go to the edit page
				if (window.location.href.indexOf('action') >= 0) redlinks_removeall();
				else {
					var pageTitle;
					if (window.location.href.indexOf('?title=') >= 0) {
						var regex = /\?title=(.+?)&/;
						var regexMatch = window.location.href.match(regex);
						pageTitle = regexMatch[1];
					} else {
						pageTitle = window.location.href;
						if (window.location.href.indexOf('#') >= 0) pageTitle = pageTitle.substr(0, pageTitle.indexOf('#'));
						pageTitle = pageTitle.substr(window.location.href.indexOf('/wiki/')+6);
					}
					window.location.href = "https://sat.wikipedia.org/wiki/"+pageTitle+"?action=edit";
				}
			} else {
				alert('No redlinks!');
			}
		});
	});
});

function redlinks_removeall() {
	// Automatic removal of redlinks when stored.
    if (localStorage.redlinks !== "" && localStorage.redlinks !== undefined) {
		// Gather saved redlinks
		try { var redlinks = JSON.parse(localStorage.redlinks); } catch (e) {return;}
		
		// Regular expression to escape special characters
		var totalredlinks = 0;
		RegExp.quote = function(str) { return str.replace(/[.?*+^$[\]\\(){}|-]/g, "\\$&"); };
		
		var wpTextbox1 = document.getElementById('wpTextbox1');
		for (i = 0; i < redlinks.length; i++) {
			// Regular expression for piped links and direct links
			var reglink1 = new RegExp('\\[\\[\\s*('+RegExp.quote(redlinks[i]).replace(/\s/g, "[\\s\\_]*")+')\\s*\\|\\s*([^\\]]*)\\s*\\]\\]','gi');
			var reglink2 = new RegExp('\\[\\[\\s*('+RegExp.quote(redlinks[i]).replace(/\s/g, "[\\s\\_]*")+')\\s*\\]\\]','gi');
			
			// Add total number of matches for both
			if (wpTextbox1.value.match(reglink1) !== null) totalredlinks += wpTextbox1.value.match(reglink1).length;
			if (wpTextbox1.value.match(reglink2) !== null) totalredlinks += wpTextbox1.value.match(reglink2).length; // Includes categories
			
			// Remove category rather than simply convert it to unlinked text
			if (redlinks[i].substr(0,9) == "Category:") {
				var reglink3 = new RegExp('\\[\\[\\s*('+RegExp.quote(redlinks[i])+')\\s*\\]\\]\\n','gi');
				wpTextbox1.value = wpTextbox1.value.replace(reglink3,"");
			}
			
			// Remove redlinks and convert to unlinked text
			wpTextbox1.value = wpTextbox1.value.replace(reglink1,"$2");
			wpTextbox1.value = wpTextbox1.value.replace(reglink2,"$1");
		}
		
		// Alert for summary of removed redlinks; total in edit summary
		if (totalredlinks > 0) {
			document.getElementById('wpSummary').value += "Removed "+totalredlinks+" redlink"+(totalredlinks==1?"":"s")+" via [[User:Alex 21/script-redlinks|script]].";
			alert("Automatically removed "+totalredlinks+" redlink"+(totalredlinks==1?"":"s")+"!");
		} else {
			// Redlinks were seen in the article but none were found in the wikicode - check the nevigational boxes for these redlinks
			alert('No redlinks in the article! (Check transcluded templates and the navigational boxes.)');
		}
		
		// Remove the template(s)
		wpTextbox1.value = wpTextbox1.value.replace(/\{\{[Cc]leanup-?\s*[Rr]ed\s*[Ll]inks?[^\}]*\}\}/g, "");
		wpTextbox1.value = wpTextbox1.value.replace(/\{\{[Rr]ed\s*links?[^\}]*\}\}/g, "");
		wpTextbox1.value = wpTextbox1.value.replace(/\{\{[Tt]oo many red links[^\}]*\}\}/g, "");
		
		// Clear all saved redlinks
		localStorage.redlinks = '';
	}
}


//This script uses material from Wikipedia user Ucucha's script "duplinks" ( https://en.wikipedia.org/wiki/User:Ucucha/duplinks.js ), which is released under the Creative Commons Attribution-Share-Alike License 3.0 ( http://creativecommons.org/licenses/by-sa/3.0/ )
//See also https://en.wikipedia.org/wiki/User:Ucucha/duplinks for documentation of the original script
$( function($) {
	var namespaceNumber = mw.config.get('wgNamespaceNumber');
	// only check links in mainspace, and userspace (for userspace drafts), and draftspace
	var isCorrectNamespace = namespaceNumber === 0 || namespaceNumber === 2 || namespaceNumber === 118;
	if (!isCorrectNamespace) {
		return;
	}
	mw.loader.using('mediawiki.util').then(function(){
		var portletlink = mw.util.addPortletLink('p-tb', '#', 'Highlight duplicate links', 'ca-findduplicatelinks');
		$(portletlink).click( function(e) {
			e.preventDefault();			
			// Check if VisualEditor is being used - the element surrounding text is different in VE
			var isVisualEditor = window.location.href.search("veaction")>0;
			// Get the element immediately surrounding the article text.
			var $content = isVisualEditor ? $(".ve-ce-documentNode.ve-ce-branchNode") : $($(".mw-parser-output", "#mw-content-text")[0])
			// Create a separate div to conatin the lead
			$lead = $("<div id='lead'>").prependTo($content);
			// Move the elements containing the lead content into this newly-created div
			$lead.nextAll().each( function() {
				if (this.nodeName.toLowerCase() == 'h2') {
					// Reached the first heading after the lead.
					// Returning false breaks out of the jQuery .each() loop early
					return false;
				}
				$lead.append(this);
				return true;
			});

			// Objects to keep track of whether we've seen a link before, and which links are duplicated
			var seen = {};
			var duplicated = {};
			var hasDuplicatedLinks = false;

			// Styles
			mw.util.addCSS(".duplicate-link { border: 1px solid red; }\n.duplicated-link { border: 1px dashed green; }");
			
			// Detect and mark links which are duplicates
			var finddups = function() {
				var href = this.attributes.href && this.attributes.href.value;
				if (href != undefined && href.indexOf('#') != 0) {
					if (seen[href]) {
						this.classList.add("duplicate-link");
						duplicated[href] = true;
						hasDuplicatedLinks = true;
					}
					else {
						seen[href] = true;
					  }
				}
				return true;
			};
			// Detect and mark the first occurance of duplicated links
			var markdups = function() {
				var href = this.attributes.href && this.attributes.href.value;
				if(href != undefined && href.indexOf('#') != 0) {
					if(duplicated[href]) {
						this.classList.add("duplicated-link");
						duplicated[href] = '';
					}
				}
				return true;
			};

			// Process sections after the lead
			mw.util.$content.find('p a').not('#lead *, .infobox *, .navbox *').each(finddups);
			mw.util.$content.find('p a').not('#lead *, .infobox *, .navbox *').each(markdups);
			
			// Reset tracking objects, process lead section
			seen = {};
			duplicated = {};
			mw.util.$content.find('#lead p a').not('.infobox *, .navbox *').each(finddups);
			mw.util.$content.find('#lead p a').not('.infobox *, .navbox *').each(markdups);

			// Show a notice if no duplicates were found
			if (!hasDuplicatedLinks) {
				mw.notify('No duplicated links were detected');
			}
		});
	});
});