Hinweis: Leere nach dem Veröffentlichen den Browser-Cache, um die Änderungen sehen zu können.
- Firefox/Safari: Umschalttaste drücken und gleichzeitig Aktualisieren anklicken oder entweder Strg+F5 oder Strg+R (⌘+R auf dem Mac) drücken
- Google Chrome: Umschalttaste+Strg+R (⌘+Umschalttaste+R auf dem Mac) drücken
- Edge: Strg+F5 drücken oder Strg drücken und gleichzeitig Aktualisieren anklicken
function newRequest() {
try {
if (window.XMLHttpRequest) {
return new XMLHttpRequest();
} else {
return new ActiveXObject("MSXML2.XMLHTTP");
}
} catch (e) {
return false;
}
}
// get URL parameters (used for page type variables)
var UrlParameters = new Array ();
readparams();
function readparams() {
var asReadInUrlParameters;
var asReadInUrlParameter;
// Get URL parameters
asReadInUrlParameters = location.search.substring(1, location.search.length).split("&");
for (i = 0; i < asReadInUrlParameters.length; i++) {
asReadInUrlParameter = asReadInUrlParameters[i].split("=");
UrlParameters[decodeURIComponent(asReadInUrlParameter[0])] = decodeURIComponent(asReadInUrlParameter[1]);
}
}
// token functions
function generate_asuser () {
return encodeURIComponent(mw.config.get("wgUserName"));
}
function validate_asuser (asuser) {
var retval = false;
if (encodeURIComponent(asuser) == generate_asuser() )
retval = true;
return retval;
}
function generate_astime () {
var arbitrary_datestamp = Date.UTC(2008,10,1,0,0,0,0); // 1.11.2008
var current_date = new Date();
var current_timestamp = current_date.getTime();
return ( Math.floor((current_timestamp - arbitrary_datestamp) / 1000) );
}
function validate_astime (astime) {
var retval = false;
var timediff = generate_astime() - astime;
if ((timediff >= 0) && (timediff < 45))
retval = true;
return retval;
}
function fixlinks() {
var allredirects = $( '.mw-redirect' );
for (i=0;i<allredirects.length;i++){
if(!allredirects[i].getAttribute('title')) continue;
var currenttitle = allredirects[i].getAttribute("title");
//alert('currenttitle: '+currenttitle);
var req;
if (req = newRequest()) {
var text = '/w/api.php?format=xml&action=query&titles=' + currenttitle + '&redirects=';
req.open("GET", text, false);
req.send("");
var linkresult = req.responseXML.getElementsByTagName("page")[0].getAttribute('title');
var testforsection = req.responseXML.getElementsByTagName("r");
var foundsection = 0;
if (testforsection) for(k=0;k<testforsection.length;k++) if(testforsection[k].getAttribute("tofragment")) foundsection = 1;
//alert('linkresult: '+linkresult);
}
if(foundsection) continue;
var cleanedtitle = currenttitle.replace(/\s/g,'[\\s_]').replace(/\(/g,'\\(').replace(/\)/g,'\\)');
var regex2 = new RegExp('\\[\\['+cleanedtitle+'#(.+?)\\|');
var regex1 = new RegExp('\\[\\['+cleanedtitle+'\\]\\](\\W)');
var regex5 = new RegExp('\\[\\['+cleanedtitle+'\\]\\](\\w+)');
var regex3 = new RegExp(cleanedtitle+'\\|');
var regex4 = new RegExp('\\[\\['+cleanedtitle+'\\|(.+?)\\]\\](\\w*)');
/*alert(regex1);
alert(regex2);
alert(regex3);*/
if (document.editform.wpTextbox1.value.search(regex2) != -1) {
document.editform.wpTextbox1.value = document.editform.wpTextbox1.value.replace(regex2, '[['+linkresult+'#$1|');
} else if (document.editform.wpTextbox1.value.search(regex1) != -1){
var regexlinkresult3 = new RegExp('^'+linkresult);
if (currenttitle.search(regexlinkresult3) != -1) {
//alert('type 7');
document.editform.wpTextbox1.value = document.editform.wpTextbox1.value.replace(regex1, '[['+linkresult+']]'+currenttitle.replace(linkresult,'')+'$1');
} else {
document.editform.wpTextbox1.value = document.editform.wpTextbox1.value.replace(regex1, '[['+linkresult+'|'+currenttitle+']]$1');
}
} else if (document.editform.wpTextbox1.value.search(regex5) != -1) {
var testsimilarity2 = document.editform.wpTextbox1.value.match(regex5);
var combined2 = currenttitle.replace(/_/,' ')+RegExp.$1;
var regexlinkresult2 = new RegExp('^'+linkresult);
if (combined2.search(regexlinkresult2) != -1) {
//alert('type 5');
document.editform.wpTextbox1.value = document.editform.wpTextbox1.value.replace(regex5, '[['+linkresult+']]'+combined2.replace(linkresult,''));
} else {
//alert('type 6');
document.editform.wpTextbox1.value = document.editform.wpTextbox1.value.replace(regex5, '[['+linkresult+'|'+currenttitle+'$1]]');
}
} else if (document.editform.wpTextbox1.value.search(regex3) != -1) {
var testsimilarity = document.editform.wpTextbox1.value.match(regex4);
var beforebrackets = RegExp.$1;
var behindbrackets = RegExp.$2;
var combined = beforebrackets+behindbrackets;
var regexlinkresult = new RegExp('^'+linkresult);
/*alert(combined);
alert(linkresult);
if(behindbrackets) { alert('regexes 2: '+ beforebrackets + behindbrackets) } else { alert('regexes 1: '+ beforebrackets) }*/
if (combined === linkresult) {
//alert('type 2');
document.editform.wpTextbox1.value = document.editform.wpTextbox1.value.replace(regex4, '[['+linkresult+']]');
} else if (combined.search(regexlinkresult) != -1) {
//alert('type 4');
document.editform.wpTextbox1.value = document.editform.wpTextbox1.value.replace(regex4, '[['+linkresult+']]'+combined.replace(linkresult,''));
} else {
//alert('type 3');
document.editform.wpTextbox1.value = document.editform.wpTextbox1.value.replace(regex4, '[['+linkresult+'|$1$2]]');
}
}
}
document.editform.wpSummary.value = 'linkfix';
document.editform.wpMinoredit.click();
document.editform.wpDiff.click();
}
if (UrlParameters["linkfix"] == "1") window.setTimeout(function() { $(fixlinks); }, 1000);
mw.util.addPortletLink( 'p-Mitmachen', '//de.wikipedia.org/w/index.php?title=' + mw.config.get("wgPageName") + '&action=edit&linkfix=1', 'Linkfix', 't-linkfix', 'fix links', 'a', '' );