For faster navigation, this Iframe is preloading the Wikiwand page for Benutzer:DerHexer/fixlinks.js.

Benutzer:DerHexer/fixlinks.js

aus Wikipedia, der freien Enzyklopädie

 function newRequest()
   {
     try {
       if (window.XMLHttpRequest) {
         return new XMLHttpRequest();
       } else {
         return new ActiveXObject("MSXML2.XMLHTTP");
       }
     } catch (e) {
       return false;
     }
   }
   
 // token functions
 function generate_flauser () {
   return encodeURIComponent(mw.config.get('wgUserName'));
 }
 
 function validate_flauser (flauser) {
   var retval = false;
   if (flauser == encodeURIComponent(encodeURIComponent(generate_flauser())) )
      retval = true;
 
   return retval;
 }
 
 function generate_flatime () {
   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_flatime (flatime) {
   var retval = false;
   var timediff = generate_flatime() - flatime;
 
   if ((timediff >= 0) && (timediff < 45))
      retval = true;
 
   return retval;
 }
 
 // get URL parameters (used for page type variables)
 var FLUrlParameters = 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("=");
    FLUrlParameters[decodeURIComponent(asReadInUrlParameter[0])] = asReadInUrlParameter[1];
  }
 }

 // Funktion zum Öffnen der Links
 function fixlinksimages() {
  if(confirm("Möchtest du mit dem Abarbeiten von NowCommons bzw. JetztSVG fortfahren? Zum Umbiegen von Links auf eine frei definierbare Seite gehe zuerst in die Linkliste. Zum Löschen von Verlinkungen klicke auf RemoveLinks.")){
   var req = newRequest();
   if (req) {
     var text = mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/api.php?action=query&format=xml&list=imageusage&iulimit=500&iutitle='+mw.config.get('wgPageName');
     req.open("GET", text, false);
     req.send("");
 
     var imageusage = req.responseXML.getElementsByTagName("iu");
   }
   for(i=0;i<10;i++){
     if (!imageusage[i]) continue;
     var replacewith = document.getElementById('Vorlage_NowCommons');
     var fixlinkstype = 'nowcommons';
     if(!replacewith) {
       var replacewith = document.getElementById('Vorlage_JetztSVG');
       fixlinkstype = 'svg';
     }
     if(!replacewith) continue;
     replacewith = replacewith.getElementsByTagName('td')[1].getElementsByTagName('a')[0].getAttribute('title').replace(/\bcommons.File./,'').replace(/\bDatei\:/,'');
     var getuser = generate_flauser();
     var getimage = imageusage[i].getAttribute('title');
     if(getimage.search(/Kategorie\:Wikipedia\:Datei/) != -1) continue;
     if(getimage=='Wikipedia:Grafikwerkstatt') continue;
     if(getimage=='Wikipedia:WikiProjekt SVG/Wunschliste') continue;
     var gettime = generate_flatime();
     var url = mw.config.get('wgServer')+mw.config.get('wgScript')+"?title="+getimage+"&action=edit&replace="+encodeURIComponent(mw.config.get('wgTitle'))+"&replacewith="+encodeURIComponent(replacewith)+"&fixlinkstype="+encodeURIComponent(fixlinkstype)+"&flauser="+encodeURIComponent(getuser)+"&flatime="+encodeURIComponent(gettime);
     url = encodeURI(url);
     window.open(url);
     if(i==9 && imageusage.length>10) {
       document.getElementById('firstHeading').setAttribute('class', 'recentlyrestored');
       document.getElementById('firstHeading').setAttribute('style', 'text-decoration: blink; background-color:red;');
       document.getElementById('firstHeading').innerHTML = 'Es sind noch Einbindungen vorhanden! Skript noch einmal ausführen!';
     }
   }
  }
 }
 
function fixlinkslinklist(gettype) {
 var counter = 0;
  var movefrom = mw.config.get('wgPageName');
  if(mw.config.get('wgCanonicalSpecialPageName') == "Whatlinkshere") movefrom = document.getElementById('contentSub').getElementsByTagName('a')[0].innerHTML; 
  if (gettype == '1') {
    var moveto = prompt('Wohin sollen die Links gefixt werden?');
    var startwith = prompt('Wie viele Links sollen übersprungen werden?', '0');
    startwith = parseInt(startwith);
  } else {
    var moveto = 'DELETE';
    var startwith = 0;
  }
  if(moveto && (moveto !== '') && (moveto !== movefrom)) {
   var req2 = newRequest();
   if (req2) {
     var text = mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/api.php?action=query&format=xml&list=backlinks&bllimit=500&blfilterredir=nonredirects&blnamespace=0|4|6|10|12|14|100&bltitle='+movefrom;
     req2.open("GET", text, false);
     req2.send("");
 
     var linklist1 = req2.responseXML.getElementsByTagName("bl");
   }
   var req3 = newRequest();
   if (req3) {
     var text = mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/api.php?action=query&format=xml&list=imageusage&iulimit=500&iufilterredir=nonredirects&iunamespace=0|4|6|10|12|14|100&iutitle='+movefrom;
     req3.open("GET", text, false);
     req3.send("");
 
     var linklist2 = req3.responseXML.getElementsByTagName("iu");
   }
   var req4 = newRequest();
   if (req4) {
     var text = mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/api.php?action=query&format=xml&list=embeddedin&eilimit=500&eifilterredir=nonredirects&einamespace=0|4|6|10|12|14|100&eititle='+movefrom;
     req4.open("GET", text, false);
     req4.send("");
 
     var linklist3 = req4.responseXML.getElementsByTagName("ei");
   }
   if (gettype=='1') { var fixlinkstype = 'linklist'; } else { var fixlinkstype = 'deletelinks'; }
   for(i=0;i<10;i++){
    if(counter < 10) {
     var getuser = generate_flauser();
     var gettime = generate_flatime();
 
     if (linklist1[i+startwith]) {
       var getimage = linklist1[i+startwith].getAttribute('title');
       var testvar = true;
       if(getimage.search(/Kategorie\:Wikipedia\:Datei/) != -1) testvar = false;
       if(getimage=='Wikipedia:Grafikwerkstatt') testvar = false;
       if(getimage=='Wikipedia:WikiProjekt SVG/Wunschliste') testvar = false;
       getimage = getimage.replace(/\&/g, '%26');
      if(testvar) {
       var url = mw.config.get('wgServer')+mw.config.get('wgScript')+"?title="+getimage+"&action=edit&replace="+encodeURIComponent(movefrom)+"&replacewith="+encodeURIComponent(moveto)+"&fixlinkstype="+fixlinkstype+"&flauser="+encodeURIComponent(getuser)+"&flatime="+encodeURIComponent(gettime);
       //url = encodeURI(url);
       window.open(url);
       counter++;
      }
     }
     if (linklist2[i]) {
       var getimage = linklist2[i].getAttribute('title');
       var testvar = true;
       if(getimage.search(/Kategorie\:Wikipedia\:Datei/) != -1) testvar = false;
       if(getimage=='Wikipedia:Grafikwerkstatt') testvar = false;
       if(getimage=='Wikipedia:WikiProjekt SVG/Wunschliste') testvar = false;
      if(testvar) {
       var url = mw.config.get('wgServer')+mw.config.get('wgScript')+"?title="+getimage+"&action=edit&replace="+encodeURIComponent(movefrom)+"&replacewith="+encodeURIComponent(moveto)+"&fixlinkstype="+fixlinkstype+"&flauser="+encodeURIComponent(getuser)+"&flatime="+encodeURIComponent(gettime);
       url = encodeURI(url);
       window.open(url);
       counter++;
      }
     }
     if (linklist3[i] && !linklist) {
       var getimage = linklist3[i].getAttribute('title');
       var testvar = true;
       if(getimage.search(/Kategorie\:Wikipedia\:Datei/) != -1) testvar = false;
       if(getimage=='Wikipedia:Grafikwerkstatt') testvar = false;
       if(getimage=='Wikipedia:WikiProjekt SVG/Wunschliste') testvar = false;
      if(testvar) {
       var url = mw.config.get('wgServer')+mw.config.get('wgScript')+"?title="+getimage+"&action=edit&replace="+encodeURIComponent(movefrom)+"&replacewith="+encodeURIComponent(moveto)+"&fixlinkstype="+fixlinkstype+"&flauser="+encodeURIComponent(getuser)+"&flatime="+encodeURIComponent(gettime);
       url = encodeURI(url);
       window.open(url);
       counter++;
      }
     }
 
    } else {
      document.getElementById('firstHeading').setAttribute('class', 'recentlyrestored');
      document.getElementById('firstHeading').setAttribute('style', 'text-decoration: blink; background-color:red;');
      document.getElementById('firstHeading').innerHTML = 'Es sind noch Einbindungen vorhanden! Skript noch einmal ausführen!';
    }
   }
  }
 //}
}
 
 // Funktion zum Ändern der Artikelinhalte
 function fixlinks(){
   if (validate_flauser(FLUrlParameters["flauser"])) {
     if (validate_flatime(FLUrlParameters["flatime"])) {
       var replacewith = decodeURIComponent(decodeURIComponent(decodeURIComponent(FLUrlParameters["replacewith"])));
       var replacer = decodeURIComponent(decodeURIComponent(FLUrlParameters["replace"])).replace(/[\s_\.]/g,'.').replace(/\(/,'\\(').replace(/\)/,'\\)');
       if (FLUrlParameters["fixlinkstype"] == 'linklist' || FLUrlParameters["fixlinkstype"] == 'deletelinks') {
         replacer = '\\[\\['+replacer;
         replacer = replacer.replace(/\\\[\\\[(Bild:|Image:|Datei:|File:)/g, '');
       }
       if (FLUrlParameters["fixlinkstype"] != 'deletelinks') replacer = new RegExp(replacer, 'gi');
       //alert(replacer);
       //alert(replacewith);
       if(FLUrlParameters["fixlinkstype"] == 'nowcommons'){
         document.editform.wpSummary.value = "Die Datei [[Datei:"+decodeURIComponent(decodeURIComponent(FLUrlParameters["replace"]))+"]] ist nun auf Commons unter [[commons:File:"+decodeURIComponent(replacewith)+"]] zu finden. ([[Benutzer:DerHexer/fixlinks.js|fixlinks.js]])";
       } else if (FLUrlParameters["fixlinkstype"] == 'svg') {
         document.editform.wpSummary.value = "Die Datei [[Datei:"+decodeURIComponent(decodeURIComponent(FLUrlParameters["replace"]))+"]] ist nun als [[Scalable Vector Graphics|SVG]] unter [[Datei:"+decodeURIComponent(replacewith)+"]] zu finden. ([[Benutzer:DerHexer/fixlinks.js|fixlinks.js]])";
       } else if (FLUrlParameters["fixlinkstype"] == 'linklist') {
         document.editform.wpSummary.value = "[[Benutzer:DerHexer/fixlinks.js|Linkfix]] ([["+decodeURIComponent(decodeURIComponent(FLUrlParameters["replace"])).replace(/\[\[/,'')+"]] → [["+decodeURIComponent(replacewith)+"]])";
         replacewith = '[['+replacewith;
         replacewith = replacewith.replace(/\[\[(Bild:|Image:|Datei:|File:)/, '');
       } else if (FLUrlParameters["fixlinkstype"] == 'deletelinks') {
         document.editform.wpSummary.value = "Links von [["+decodeURIComponent(decodeURIComponent(FLUrlParameters["replace"])).replace(/\[\[/,'')+"]] wurden gelöscht. ([[Benutzer:DerHexer/fixlinks.js|fixlinks.js]])";
         replacer = '\(\\[\\[\)\?\(Bild:|Image:|Datei:|File:|bild:|image:|datei:|file:\)\?' + replacer + '\.\*\(\\]\\]\)\?';
         //alert(replacer);
         replacer = new RegExp(replacer, 'i');
         //alert(replacer);
       } else {
         document.editform.wpSummary.value = "Die Datei [[Datei:"+decodeURIComponent(decodeURIComponent(FLUrlParameters["replace"]))+"]] wurde durch die Datei [[Datei:"+decodeURIComponent(replacewith)+"]] ersetzt. ([[Benutzer:DerHexer/fixlinks.js|fixlinks.js]])";
       }
       document.editform.wpMinoredit.checked=true;
       if (FLUrlParameters["fixlinkstype"] != 'deletelinks') { document.editform.wpTextbox1.value = document.editform.wpTextbox1.value.replace(replacer, replacewith); } else { document.editform.wpTextbox1.value = document.editform.wpTextbox1.value.replace(replacer, ''); }
       document.editform.wpDiff.click();
       //document.editform.wpSave.click();
       //window.setTimeout(function() { window.close(); }, 1000);
     } else {
       alert("Token zur automatischen Speicherung ist abgelaufen.");
     }
   }
 }
 if(FLUrlParameters["replace"] && FLUrlParameters["replacewith"]) $(fixlinks);
 
 if(mw.config.get('wgNamespaceNumber')==6) 
 {
  $(function() 
  { 
    mediaWiki.util.addPortletLink('p-tb', "javascript:fixlinksimages();", "FixLinks", 't-fixlinks', 'fix Links', '',  document.getElementById('t-whatlinkshere'));
  });
 }
 if(mw.config.get('wgCanonicalSpecialPageName') == "Whatlinkshere")
 {
  $(function() 
  { 
    mediaWiki.util.addPortletLink('p-tb', "javascript:fixlinkslinklist(1);", "FixLinks", 't-fixlinks', 'fix Links', '',  document.getElementById('t-upload'));
  });
 }
 if(mw.config.get('wgNamespaceNumber')==6 || mw.config.get('wgCanonicalSpecialPageName') == "Whatlinkshere") 
 {
  $(function() 
  { 
    mediaWiki.util.addPortletLink('p-tb', "javascript:fixlinkslinklist(2);", "RemoveLinks", 't-removelinks', 'entferne Links', '',  document.getElementById('t-whatlinkshere'));
  });
 }
{{bottomLinkPreText}} {{bottomLinkText}}
Benutzer:DerHexer/fixlinks.js
Listen to this article

This browser is not supported by Wikiwand :(
Wikiwand requires a browser with modern capabilities in order to provide you with the best reading experience.
Please download and use one of the following browsers:

This article was just edited, click to reload
This article has been deleted on Wikipedia (Why?)

Back to homepage

Please click Add in the dialog above
Please click Allow in the top-left corner,
then click Install Now in the dialog
Please click Open in the download dialog,
then click Install
Please click the "Downloads" icon in the Safari toolbar, open the first download in the list,
then click Install
{{::$root.activation.text}}

Install Wikiwand

Install on Chrome Install on Firefox
Don't forget to rate us

Tell your friends about Wikiwand!

Gmail Facebook Twitter Link

Enjoying Wikiwand?

Tell your friends and spread the love:
Share on Gmail Share on Facebook Share on Twitter Share on Buffer

Our magic isn't perfect

You can help our automatic cover photo selection by reporting an unsuitable photo.

This photo is visually disturbing This photo is not a good choice

Thank you for helping!


Your input will affect cover photo selection, along with input from other users.

X

Get ready for Wikiwand 2.0 🎉! the new version arrives on September 1st! Don't want to wait?