MediaWiki:Common.js: Unterschied zwischen den Versionen

Aus Pornopedia, der geilen Enzyklopädie
Till Kraemer (Diskussion | Beiträge)
Keine Bearbeitungszusammenfassung
Till Kraemer (Diskussion | Beiträge)
Keine Bearbeitungszusammenfassung
Zeile 1: Zeile 1:
/* Any JavaScript here will be loaded for all users on every page load. */
/* Any JavaScript here will be loaded for all users on every page load. */
/* From https://en.wikipedia.org/wiki/MediaWiki:Common.js */
/* global mw, $ */
/* jshint strict:false, browser:true */
mw.loader.using( ['mediawiki.user', 'mediawiki.util', 'mediawiki.notify'] ).done( function () {
/* Begin of mw.loader.using callback */


if ( /^MediaWiki(\/.+)?$/.test( wgPageName ) && wgAction == "view" ) {
if ( /^MediaWiki(\/.+)?$/.test( wgPageName ) && wgAction == "view" ) {

Version vom 2. Juni 2019, 12:37 Uhr

/* Any JavaScript here will be loaded for all users on every page load. */

/* From https://en.wikipedia.org/wiki/MediaWiki:Common.js */

/* global mw, $ */
/* jshint strict:false, browser:true */

mw.loader.using( ['mediawiki.user', 'mediawiki.util', 'mediawiki.notify'] ).done( function () {
/* Begin of mw.loader.using callback */


if ( /^MediaWiki(\/.+)?$/.test( wgPageName ) && wgAction == "view" ) {
    addOnloadHook(function(){
        document.body.className+=" mainpage";
        document.write('<style type="text/css">/*<![CDATA[*/ #lastmod, #siteSub, h1.firstHeading { display: none !important; } #content { padding-top: 1em; }/*]]>*/</style>'); /*REMOVE THIS LINE AFTER 22/01/2009 */
    })
}

/* Fromt https://en.wikipedia.org/wiki/MediaWiki:Common.js */


/* Force preview for anons */
/* by Marc Mongenet, 2006, fr.wikipedia */

function forcePreview() {
  if (wgUserName != null || wgAction != "edit") return;
  saveButton = document.getElementById("wpSave");
  if (!saveButton) return;
  saveButton.disabled = true;
  saveButton.value = "Save page (use preview first)";
  saveButton.style.fontWeight = "normal";
  document.getElementById("wpPreview").style.fontWeight = "bold";
}
addOnloadHook(forcePreview);

/* End of forcePreview */

/** includePage ************
 * force the loading of another JavaScript file
 *
 * Maintainer: [[Commons:User:Dschwen]]
 */
 
function includePage( name )
{
 document.write('<script type="text/javascript" src="/w/index.php?title='
  + name 
  + '&action=raw&ctype=text/javascript"><\/script>' 
 );
}
/* End of includePage */

/* Including extra .js pages */ 

// switches for scripts
// TODO: migrate to JSConfig
// var load_extratabs = true;
var load_edittools = true;

// extra drop down menu on editing for adding special characters
includePage( 'MediaWiki:Edittools.js' );

//Editpage scripts
if (wgAction=='edit' || wgAction == 'submit')
  importScript('MediaWiki:Editpage.js')

/* End of extra pages */

/**
 * Collapsible tables
 *
 * Allows tables to be collapsed, showing only the header. See [[Wikipedia:NavFrame]].
 * @maintainer [[User:R. Koot]] (on Wikipedia)
 */

var autoCollapse = 2;
var collapseCaption = 'Verbergen';
var expandCaption = 'Anzeigen';

function hasClass( element, className ) {
	var Classes = element.className.split( " " );
	for ( var i = 0; i < Classes.length; i++ ) {
		if ( Classes[i] == className ) {
			return true;
		}
	}
	return false;
}

function collapseTable( tableIndex ) {
	var i;
	var Button = document.getElementById( 'collapseButton' + tableIndex );
	var Table = document.getElementById( 'collapsibleTable' + tableIndex );

	if ( !Table || !Button ) {
		return false;
	}

	var Rows = Table.getElementsByTagName( 'tr' );

	if ( Button.firstChild.data == collapseCaption ) {
		for ( i = 1; i < Rows.length; i++ ) {
			Rows[i].style.display = 'none';
		}
		Button.firstChild.data = expandCaption;
	} else {
		for ( i = 1; i < Rows.length; i++ ) {
			Rows[i].style.display = Rows[0].style.display;
		}
		Button.firstChild.data = collapseCaption;
	}
}

function createCollapseButtons() {
	var i;
	var tableIndex = 0;
	var NavigationBoxes = {};
	var Tables = document.getElementsByTagName( 'table' );

	for ( i = 0; i < Tables.length; i++ ) {
		if ( hasClass( Tables[i], 'collapsible' ) ) {
			NavigationBoxes[ tableIndex ] = Tables[i];
			Tables[i].setAttribute( 'id', 'collapsibleTable' + tableIndex );

			var Button = document.createElement( 'span' );
			var ButtonLink = document.createElement( 'a' );
			var ButtonText = document.createTextNode( collapseCaption );

			Button.style.styleFloat = 'right';
			Button.style.cssFloat = 'right';
			Button.style.fontWeight = 'normal';
			Button.style.textAlign = 'right';
			Button.style.width = '6em';

			ButtonLink.setAttribute( 'id', 'collapseButton' + tableIndex );
			ButtonLink.setAttribute( 'href', 'javascript:collapseTable(' + tableIndex + ');' );
			ButtonLink.appendChild( ButtonText );

			Button.appendChild( document.createTextNode( '[' ) );
			Button.appendChild( ButtonLink );
			Button.appendChild( document.createTextNode( ']' ) );

			var Header = Tables[i].getElementsByTagName( 'tr' )[0].getElementsByTagName( 'th' )[0];
			/* only add button and increment count if there is a header row to work with */
			if (Header) {
				Header.insertBefore( Button, Header.childNodes[0] );
				tableIndex++;
			}
		}
	}

	for ( i = 0; i < tableIndex; i++ ) {
		if ( hasClass( NavigationBoxes[i], 'collapsed' ) || ( tableIndex >= autoCollapse && hasClass( NavigationBoxes[i], 'autocollapse' ) ) ) {
			collapseTable( i );
		}
	}
}

$( createCollapseButtons );


/**
 * Dynamic Navigation Bars (experimental)
 *
 *  See [[Wikipedia:NavFrame]].
 */

// set up the words in your language
var NavigationBarHide = '[' + collapseCaption + ']';
var NavigationBarShow = '[' + expandCaption + ']';

// shows and hides content and picture (if available) of navigation bars
// Parameters:
// indexNavigationBar: the index of navigation bar to be toggled
function toggleNavigationBar(indexNavigationBar) {
	var NavChild;
	var NavToggle = document.getElementById( 'NavToggle' + indexNavigationBar);
	var NavFrame = document.getElementById( 'NavFrame' + indexNavigationBar);

	if (!NavFrame || !NavToggle) {
		return false;
	}

	// if shown now
	if (NavToggle.firstChild.data == NavigationBarHide) {
		for ( NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling) {
			if ( hasClass( NavChild, 'NavPic' ) ) {
				NavChild.style.display = 'none';
			}
			if ( hasClass( NavChild, 'NavContent') ) {
				NavChild.style.display = 'none';
			}
		}
		NavToggle.firstChild.data = NavigationBarShow;

	// if hidden now
	} else if (NavToggle.firstChild.data == NavigationBarShow) {
		 for ( NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling) {
			 if (hasClass(NavChild, 'NavPic')) {
				 NavChild.style.display = 'block';
			 }
			 if (hasClass(NavChild, 'NavContent')) {
				 NavChild.style.display = 'block';
			 }
		 }
		 NavToggle.firstChild.data = NavigationBarHide;
	}
}

// adds show/hide-button to navigation bars
function createNavigationBarToggleButton(){
	var indexNavigationBar = 0;
	// iterate over all < div >-elements
	var divs = document.getElementsByTagName( 'div' );
	for (var i = 0; NavFrame = divs[i]; i++) {
		// if found a navigation bar
		if ( hasClass(NavFrame, 'NavFrame' )) {

			indexNavigationBar++;
			var NavToggle = document.createElement('a');
			NavToggle.className = 'NavToggle';
			NavToggle.setAttribute('id', 'NavToggle' + indexNavigationBar);
			NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + indexNavigationBar + ');');

			var NavToggleText = document.createTextNode(NavigationBarHide);
			for (var NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling) {
				if ( hasClass( NavChild, 'NavPic' ) || hasClass( NavChild, 'NavContent' ) ) {
					if (NavChild.style.display == 'none') {
						NavToggleText = document.createTextNode(NavigationBarShow);
						break;
					}
				}
			}

			NavToggle.appendChild(NavToggleText);
			// Find the NavHead and attach the toggle link (Must be this complicated because Moz's firstChild handling is borked)
			for(var j=0; j < NavFrame.childNodes.length; j++) {
				if (hasClass(NavFrame.childNodes[j], 'NavHead')) {
					NavFrame.childNodes[j].appendChild(NavToggle);
				}
			}
			NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar);
		}
	}
}

$( createNavigationBarToggleButton );

/* From https://en.wikipedia.org/wiki/User:Alex_21/script-functions.js */

/* HTML colour names */
var colour_names = {};
colour_names.aliceblue = "f0f8ff";
colour_names.antiquewhite = "faebd7";
colour_names.aqua = "00ffff";
colour_names.aquamarine = "7fffd4";
colour_names.azure = "f0ffff";
colour_names.beige = "f5f5dc";
colour_names.bisque = "ffe4c4";
colour_names.black = "000000";
colour_names.blanchedalmond = "ffebcd";
colour_names.blue = "0000ff";
colour_names.blueviolet = "8a2be2";
colour_names.brown = "a52a2a";
colour_names.burlywood = "deb887";
colour_names.cadetblue = "5f9ea0";
colour_names.chartreuse = "7fff00";
colour_names.chocolate = "d2691e";
colour_names.coral = "ff7f50";
colour_names.cornflowerblue = "6495ed";
colour_names.cornsilk = "fff8dc";
colour_names.crimson = "dc143c";
colour_names.cyan = "00ffff";
colour_names.darkblue = "00008b";
colour_names.darkcyan = "008b8b";
colour_names.darkgoldenrod = "b8860b";
colour_names.darkgray = "a9a9a9";
colour_names.darkgrey = "a9a9a9";
colour_names.darkgreen = "006400";
colour_names.darkkhaki = "bdb76b";
colour_names.darkmagenta = "8b008b";
colour_names.darkolivegreen = "556b2f";
colour_names.darkorange = "ff8c00";
colour_names.darkorchid = "9932cc";
colour_names.darkred = "8b0000";
colour_names.darksalmon = "e9967a";
colour_names.darkseagreen = "8fbc8f";
colour_names.darkslateblue = "483d8b";
colour_names.darkslategray = "2f4f4f";
colour_names.darkslategrey = "2f4f4f";
colour_names.darkturquoise = "00ced1";
colour_names.darkviolet = "9400d3";
colour_names.deeppink = "ff1493";
colour_names.deepskyblue = "00bfff";
colour_names.dimgray = "696969";
colour_names.dimgrey = "696969";
colour_names.dodgerblue = "1e90ff";
colour_names.firebrick = "b22222";
colour_names.floralwhite = "fffaf0";
colour_names.forestgreen = "228b22";
colour_names.fuchsia = "ff00ff";
colour_names.gainsboro = "dcdcdc";
colour_names.ghostwhite = "f8f8ff";
colour_names.gold = "ffd700";
colour_names.goldenrod = "daa520";
colour_names.gray = "808080";
colour_names.grey = "808080";
colour_names.green = "008000";
colour_names.greenyellow = "adff2f";
colour_names.honeydew = "f0fff0";
colour_names.hotpink = "ff69b4";
colour_names.indianred = "cd5c5c";
colour_names.indigo = "4b0082";
colour_names.ivory = "fffff0";
colour_names.khaki = "f0e68c";
colour_names.lavender = "e6e6fa";
colour_names.lavenderblush = "fff0f5";
colour_names.lawngreen = "7cfc00";
colour_names.lemonchiffon = "fffacd";
colour_names.lightblue = "add8e6";
colour_names.lightcoral = "f08080";
colour_names.lightcyan = "e0ffff";
colour_names.lightgoldenrodyellow = "fafad2";
colour_names.lightgray = "d3d3d3";
colour_names.lightgrey = "d3d3d3";
colour_names.lightgreen = "90ee90";
colour_names.lightpink = "ffb6c1";
colour_names.lightsalmon = "ffa07a";
colour_names.lightseagreen = "20b2aa";
colour_names.lightskyblue = "87cefa";
colour_names.lightslategray = "778899";
colour_names.lightslategrey = "778899";
colour_names.lightsteelblue = "b0c4de";
colour_names.lightyellow = "ffffe0";
colour_names.lime = "00ff00";
colour_names.limegreen = "32cd32";
colour_names.linen = "faf0e6";
colour_names.magenta = "ff00ff";
colour_names.maroon = "800000";
colour_names.mediumaquamarine = "66cdaa";
colour_names.mediumblue = "0000cd";
colour_names.mediumorchid = "ba55d3";
colour_names.mediumpurple = "9370db";
colour_names.mediumseagreen = "3cb371";
colour_names.mediumslateblue = "7b68ee";
colour_names.mediumspringgreen = "00fa9a";
colour_names.mediumturquoise = "48d1cc";
colour_names.mediumvioletred = "c71585";
colour_names.midnightblue = "191970";
colour_names.mintcream = "f5fffa";
colour_names.mistyrose = "ffe4e1";
colour_names.moccasin = "ffe4b5";
colour_names.navajowhite = "ffdead";
colour_names.navy = "000080";
colour_names.oldlace = "fdf5e6";
colour_names.olive = "808000";
colour_names.olivedrab = "6b8e23";
colour_names.orange = "ffa500";
colour_names.orangered = "ff4500";
colour_names.orchid = "da70d6";
colour_names.palegoldenrod = "eee8aa";
colour_names.palegreen = "98fb98";
colour_names.paleturquoise = "afeeee";
colour_names.palevioletred = "db7093";
colour_names.papayawhip = "ffefd5";
colour_names.peachpuff = "ffdab9";
colour_names.peru = "cd853f";
colour_names.pink = "ffc0cb";
colour_names.plum = "dda0dd";
colour_names.powderblue = "b0e0e6";
colour_names.purple = "800080";
colour_names.rebeccapurple = "663399";
colour_names.red = "ff0000";
colour_names.rosybrown = "bc8f8f";
colour_names.royalblue = "4169e1";
colour_names.saddlebrown = "8b4513";
colour_names.salmon = "fa8072";
colour_names.sandybrown = "f4a460";
colour_names.seagreen = "2e8b57";
colour_names.seashell = "fff5ee";
colour_names.sienna = "a0522d";
colour_names.silver = "c0c0c0";
colour_names.skyblue = "87ceeb";
colour_names.slateblue = "6a5acd";
colour_names.slategray = "708090";
colour_names.slategrey = "708090";
colour_names.snow = "fffafa";
colour_names.springgreen = "00ff7f";
colour_names.steelblue = "4682b4";
colour_names.tan = "d2b48c";
colour_names.teal = "008080";
colour_names.thistle = "d8bfd8";
colour_names.tomato = "ff6347";
colour_names.turquoise = "40e0d0";
colour_names.violet = "ee82ee";
colour_names.wheat = "f5deb3";
colour_names.white = "ffffff";
colour_names.whitesmoke = "f5f5f5";
colour_names.yellow = "ffff00";
colour_names.yellowgreen = "9acd32";

function colourCompliance(bground,fground){
	var ratio;
	bground = bground.trim().toLowerCase();;
	if (colour_names[bground]) bground = colour_names[bground];
	
	if (fground === false) {
        var ratio_w = getColorsRatio(bground,'FFFFFF');
        var ratio_b = getColorsRatio(bground,'000000');
        fground = (ratio_w > ratio_b ? 'FFFFFF' : '000000');
        ratio = (ratio_w > ratio_b ? ratio_w : ratio_b);
	} else {
		ratio = getColorsRatio(bground,fground);
	}

	if (ratio <= 7) {
		hsv = RGBtoHSV(br,bg,bb);
		bh = hsv.h; bs = hsv.s; bv = hsv.v;
		if (bv < 100 && bv > 0) {
			bv += (fground == 'FFFFFF' ? -1 : 1);
		} else {
			bs += (fground == 'FFFFFF' ? 1 : -1);
		}
		var new_bground = HSVtoRGB(bh,bs,bv);
		new_bground = RGBtoHEX(new_bground[0],new_bground[1],new_bground[2]);
		return colourCompliance(new_bground,fground,false);
	} else {
		if (bground.length == 3) bground = bground[0]+bground[0]+bground[1]+bground[1]+bground[2]+bground[2];
		return bground.toUpperCase();
	}
}

function getColorsRatio(bground,fground) {
    var bgroundH = HEXtoRGB(bground);
    var fgroundH = HEXtoRGB(fground);
    
	br = bgroundH.r; bg = bgroundH.g; bb = bgroundH.b;
    fr = fgroundH.r; fg = fgroundH.g; fb = fgroundH.b;
	
	var ratio = 1;
	var l1 = getLuminance([fr/255, fg/255, fb/255]);
	var l2 = getLuminance([br/255, bg/255, bb/255]);

	if (l1 >= l2) {
		ratio = (l1 + 0.05) / (l2 + 0.05);
	} else {
		ratio = (l2 + 0.05) / (l1 + 0.05);
	}
	ratio = Math.round(ratio * 100) / 100;
	
	return ratio;
}

function getLuminance(rgb){
	for (var i = 0; i < rgb.length; i++) {
		if (rgb[i] <= 0.03928) {
			rgb[i] = rgb[i] / 12.92;	
		} else {
			rgb[i] = Math.pow( ((rgb[i]+0.055)/1.055), 2.4 );
		}
	}
	var l = (0.2126 * rgb[0]) + (0.7152 * rgb[1]) + (0.0722 * rgb[2]);
	return l;
}

function componentToHex(c) {
    var hex = parseInt(c).toString(16).toUpperCase();
    return hex.length == 1 ? "0" + hex : hex;
}

function RGBtoHEX(r, g, b) {
    return componentToHex(r) + componentToHex(g) + componentToHex(b);
}

function HEXtoRGB(hex) {
	if (hex.length == 6) {
		return {
			r: parseInt(hex[0]+''+hex[1], 16),
			g: parseInt(hex[2]+''+hex[3], 16),
			b: parseInt(hex[4]+''+hex[5], 16)
		};
	} else {
		return {
			r: parseInt(hex[0]+''+hex[0], 16),
			g: parseInt(hex[1]+''+hex[1], 16),
			b: parseInt(hex[2]+''+hex[2], 16)
		};
	}
}

function RGBtoHSV() {
    var rr, gg, bb,
        r = arguments[0] / 255,
        g = arguments[1] / 255,
        b = arguments[2] / 255,
        h, s,
        v = Math.max(r, g, b),
        diff = v - Math.min(r, g, b),
        diffc = function(c){
            return (v - c) / 6 / diff + 1 / 2;
        };

    if (diff === 0) {
        h = s = 0;
    } else {
        s = diff / v;
        rr = diffc(r);
        gg = diffc(g);
        bb = diffc(b);

        if (r === v) {
            h = bb - gg;
        }else if (g === v) {
            h = (1 / 3) + rr - bb;
        }else if (b === v) {
            h = (2 / 3) + gg - rr;
        }
        if (h < 0) {
            h += 1;
        }else if (h > 1) {
            h -= 1;
        }
    }
    return {
        h: Math.round(h * 360),
        s: Math.round(s * 100),
        v: Math.round(v * 100)
    };
}

function HSVtoRGB(h,s,v) {
    s = s / 100,
	v = v / 100;

    var hi = Math.floor((h/60) % 6);
    var f = (h / 60) - hi;
    var p = v * (1 - s);
    var q = v * (1 - f * s);
    var t = v * (1 - (1 - f) * s);

    var rgb = [];

    switch (hi) {
        case 0: rgb = [v,t,p];break;
        case 1: rgb = [q,v,p];break;
        case 2: rgb = [p,v,t];break;
        case 3: rgb = [p,q,v];break;
        case 4: rgb = [t,p,v];break;
        case 5: rgb = [v,p,q];break;
    }

    var r = Math.min(255, Math.round(rgb[0]*256)),
        g = Math.min(255, Math.round(rgb[1]*256)),
        b = Math.min(255, Math.round(rgb[2]*256));

    return [r,g,b];

}

function RGBSTRtoHEX(rgb) {
	if (colour_names[rgb]) return '#'+colour_names[rgb];
	rgb = rgb.split(',');
	rgb.r=parseInt(rgb[0].substring(4)).toString(16);
	rgb.g=parseInt(rgb[1]).toString(16);
	rgb.b=parseInt(rgb[2]).toString(16);
	var hex="#"+(rgb.r.length==1?'0':'')+rgb.r+(rgb.g.length==1?'0':'')+rgb.g+(rgb.b.length==1?'0':'')+rgb.b;
	return hex.toUpperCase();
}

function copyContent(text) {
	var textArea = document.createElement("textarea");
	textArea.innerHTML = text;
	document.body.appendChild(textArea);
	textArea.select();
	if (!document.execCommand('copy')) console.log(text);
	document.body.removeChild(textArea);
}

function newContentHeader(title,id) {
	var div = document.createElement('div');
	div.className = 'portal';
	div.setAttribute('role','navigation');
	div.setAttribute('id',id);
	div.setAttribute('aria-labelledby','p-tb-label');
	document.getElementById('p-tb').parentNode.insertBefore(div, document.getElementById('p-tb').nextSibling);

	var h3 = document.createElement('h3');
	h3.id = id+'-label';
	h3.innerHTML = title;
	document.getElementById(id).appendChild(h3);

	var divB = document.createElement('div');
	divB.className = 'body';
	document.getElementById(id).appendChild(divB);
}

newContentHeader('TV Tools','p-tv');


/* Based on https://en.wikipedia.org/wiki/User:Alex_21/script-redlinks.js */

$(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://de.pornopedia.com/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 window.location = window.location.href.substr(0, window.location.href.indexOf('#'))+"?action=edit";
			} else {
				alert('No redlinks!');
			}
		});
	});
});

function redlinks_removeall() {
	// Automatic removal of redlinks when stored.
    if (localStorage.redlinks !== "" && localStorage.redlinks !== undefined) {
		// Gather saved redlinks
		var redlinks = JSON.parse(localStorage.redlinks);
		
		// 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:Till Kraemer/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 = '';
	}
}