Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
// bouton Typo //
$.typo = {
  todo: new Array(),
  add: function(fonction) {
    this.todo.push(fonction);
  },
  exec: function() {
    var txt = $('#wpTextbox1').val();
    for(var i in this.todo) {
      txt = this.todo[i](txt);
    }
    $('#wpTextbox1').val(txt);
  },
  editForm: function() {
    if($('#wpTextbox1').length == 0)
      return;
    if(mw.user.options.get('usebetatoolbar')) {
      mw.loader.using('ext.wikiEditor', function() {
        $('#wpTextbox1').wikiEditor('addToToolbar', {
          section: 'advanced',
          group: 'format',
          tools: {
            'typo': {
              label: 'Corrections',
              type: 'button',
              icon: '//upload.wikimedia.org/wikipedia/commons/8/82/Toolbaricon_regular_T.png'
            }
          }
        });
        $('img[rel="typo"]').mouseup(function() {
          $.typo.exec();
        });
      });
    } else {
      $("#toolbar").append('<img id="typo-button" width="23" height="22" border="0" src="//upload.wikimedia.org/wikipedia/commons/9/9f/Button_defaultsort.png" alt="Corrections" title="Corrections" style="cursor: pointer;">');
      $('#typo-button').mouseup(function() {
        $.typo.exec();
      });
    }
  }
}
 
if($.inArray(mw.config.get('wgAction'), ['edit', 'submit']) !== -1 ) {
$(function() {
  //typo
  $.typo.add(function(str) {
// s:fr:Auteur: -> creator
    str = str.replace(/\[\[s:fr:Auteur:([^\|\]]*)(\|([^\]]*))?\]\]/g, "{{Creator:$1}}");
//    str = str.replace(/\[\[:no:([^\|\]]*)(\|([^\]]*))?\]\]/g, "{{Creator:$1}}");
    str = str.replace(/={{C:([^\|\]]*)}}/g, "={{creator:$1}}");
    str = str.replace(/\|PND=/g, "\|GND=");
    str = str.replace(/{{LS}}/g, "{{LangSwitch\n}}");
// mise en place modèles Sources
    str = str.replace(/http:\/\/(www\.)?archive\.org\/details\/([a-zA-Z0-9]*)/g, "{{IA\|$2}}");
    str = str.replace(/https:\/\/(www\.)?archive\.org\/details\/([a-zA-Z0-9]*)/g, "{{IA\|$2}}");
    str = str.replace(/http:\/\/www\.the-athenaeum\.org\/art\/full.php\?ID=([0-9]*)/g, "{{From The Athenaeum\|$1}}");
    str = str.replace(/http:\/\/www\.the-athenaeum\.org\/art\/detail\.php\?ID=([0-9]*)/g, "{{From The Athenaeum\|$1}}");
    str = str.replace(/http:\/\/www\.artrenewal\.org\/asp\/database\/image\.asp\?id=([0-9]*)&hires=1/g, "{{Art RC\|$1}}");
    str = str.replace(/http:\/\/gallica\.bnf\.fr\/ark:\|\/12148\/([a-zA-Z0-9]*)/g, "{{ARK-BNF\|ark:\|\/12148\/$1}}");

// balisage modernisé
    str = str.replace(/== Summary ==/g, "=={{int:filedesc}}==");
    str = str.replace(/==Summary==/g, "=={{int:filedesc}}==");
    str = str.replace(/==FD==/g, "=={{int:filedesc}}==");
    str = str.replace(/==LH==/g, "=={{int:license-header}}==");
    str = str.replace(/== Licensing ==/g, "=={{int:license-header}}==");
    str = str.replace(/==Licensing==/g, "=={{int:license-header}}==");
    str = str.replace(/== {{int:license}} ==/g, "=={{int:license-header}}==");
    str = str.replace(/=={{int:license}}==/g, "=={{int:license-header}}==");
// divers
    str = str.replace(/{{date\|(1[0-9][0-9][0-9])}}/g, "$1");
    str = str.replace(/{{circa\|([0-9]*)}}/g, "{{other date\|ca\|$1}}");
    str = str.replace(/{{US}}/g, "{{Unknown\|source}}");
    str = str.replace(/{{UD}}/g, "{{Unknown\|date}}");
    str = str.replace(/{{UA}}/g, "{{Unknown\|author}}");
    str = str.replace(/{{UI}}/g, "{{Unknown\|institution}}");
    str = str.replace(/\|Gallery={{Prado}}/g, "\|institution={{institution:Museo del Prado}}");
    str = str.replace(/{{NPG}}/g, "{{institution:National Portrait Gallery, London}}");
    str = str.replace(/\<\!--{{ImageUpload\|full}}-->/g, "");
    str = str.replace(/\<\!--{{ImageUpload\|basic}}-->/g, "");
    str = str.replace(/{{C}}/g, "# [[date]] [[creator:]] [AC] [[d:]] (FC\/PD)");
 
    str = str.replace(/{{Category scheme astronomy}}/g, "");
    str = str.replace(/{{PD-Art-two-auto\|(1[0-8][0-9][0-9])}}/g, "{{PD-Art\/1923\|$1}}");
    str = str.replace(/\|object_work_type = Paintings/g, "\|object_work_type = Painting");
    str = str.replace(/{{ML}}/g, "[[Category:Location of museum or gallery missing]]");
    str = str.replace(/{{Oil on canvas}}/g, "{{Technique\|oil\|canvas}}");
    str = str.replace(/{{oil on canvas}}/g, "{{Technique\|oil\|canvas}}");
    str = str.replace(/{{Oil on copper}}/g, "{{Technique\|oil\|copper}}");
    str = str.replace(/{{oil on copper}}/g, "{{Technique\|oil\|copper}}");
    str = str.replace(/{{Oil on panel}}/g, "{{Technique\|oil\|panel}}");
    str = str.replace(/{{oil on panel}}/g, "{{Technique\|oil\|panel}}");
    str = str.replace(/{{technique\|Oil on canvas}}/g, "{{Technique\|oil\|canvas}}");
    str = str.replace(/{{technique\|o\|c}}/g, "{{Technique\|oil\|canvas}}");
    str = str.replace(/{{technique\|o\|p}}/g, "{{Technique\|oil\|panel}}");
    str = str.replace(/{{technique\|wb}}/g, "{{Technique\|woodblock print}}");
    str = str.replace(/{{POM\|/g, "{{Portrait of male\|");
    str = str.replace(/{{POF\|/g, "{{Portrait of female\|");
    str = str.replace(/{{NAO}}/g, "{{NationAndOccupation\|}}");
    str = str.replace(/{{OD\|/g, "{{Other date\|");
    str = str.replace(/\|gallery=/g, "\|institution=");
    str = str.replace(/\|gallery *=/g, "\|institution=");
    str = str.replace(/\| Gallery *=/g, "\|institution=");
    str = str.replace(/\|Gallery *=/g, "\|institution=");
    str = str.replace(/\|Year *=/g, "\|date=");
    str = str.replace(/\|Technique *=/g, "\|medium=");
    str = str.replace(/\| Technique *=/g, "\|medium=");
    str = str.replace(/\|Image={{PAGENAME}}/g, "\|Image=");
//    str = str.replace(/\|location *=|\n/g, "\|location =\<\!-- location within the museum --\>"\n);
    str = str.replace(/{{:Museum:([^\|\]]*)}}/g, "{{institution:$1}}");
    str = str.replace(/{{I:([^\|\]]*)}}/g, "{{institution:$1}}");
    str = str.replace(/{{:institution:([^\|\]]*)}}/g, "{{Institution:$1}}");
    str = str.replace(/{{:Institution:([^\|\]]*)}}/g, "{{Institution:$1}}");
    str = str.replace(/{{C:([^\|\]]*)}}/g, "{{Creator:$1}}");
    str = str.replace(/{{:Creator:([^\|\]]*)}}/g, "{{Creator:$1}}");
    str = str.replace(/{{:creator:([^\|\]]*)}}/g, "{{Creator:$1}}");
    str = str.replace(/{{T\|([^\|\]]*)}}/g, "{{Title\|$1}}");
    str = str.replace(/{{FTA\|/g, "{{From The Athenaeum\|");
// automatic templates
    str = str.replace(/{{AW}}/g, "{{Artwork\n\|artist=\n\|title=\n\|description=\n\|date=\n\|medium={{technique\|}}\n\|dimensions={{size\|cm\|}}\n\|institution=\n\|location=\n\|references=\n\|object history=\n\|exhibition history=\n\|credit line=\n\|inscriptions=\n\|notes=\n\|accession number=\n\|source=\n\|permission=\n\|other_versions=}}");
 
    str = str.replace(/\|AWC/g, "\|medium={{technique\|}}\n\|dimensions={{size\|cm\|}}\n\|institution=\n\|location=\n\|references=\n\|object history=\n\|exhibition history=\n\|credit line=\n\|inscriptions=\n\|notes=\n\|accession number= ");
 
    str = str.replace(/{{AP}}/g, "{{Art Photo\n\|artist=\n\|title=\n\|description=\n\|date=\n\|medium={{technique\|}}\n\|dimensions={{size\|cm\|}}\n\|institution=\n\|location=\n\|references=\n\|object history=\n\|exhibition history=\n\|credit line=\n\|inscriptions=\n\|notes=\n\|accession number=\n\|artwork license=\n\|artwork=\n\|photo description=\n\|photo date= \n\|photographer=\n\|source=\n\|photo license=\n\|other_versions=}}");
 
    str = str.replace(/{{AW/g, "{{Artwork");
 
    str = str.replace(/{{BKF}}/g, "{{Book\n\|Author=\n\|Translator=\n\|Editor=\n\|Illustrator=\n\|Title=\n\|Subtitle=\n\|Series title=\n\|Volume=\n\|Edition=\n\|Publisher=\n\|Printer=\n\|Date=\n\|City=Paris\n\|Language=FR\n\|Description=\n\|Source=\n\|Permission=\n\|Image page=\n\|Pageoverview=\n\|Wikisource=:s:fr:Livre:{{PAGENAME}}\n\|Homecat=\n\|Other_versions=\n\|OCLC=\n}}");
    str = str.replace(/{{BK}}/g, "{{Book\n\|Author=\n\|Translator=\n\|Editor=\n\|Illustrator=\n\|Title=\n\|Subtitle=\n\|Series title=\n\|Volume=\n\|Edition=\n\|Publisher=\n\|Printer=\n\|Date=\n\|City=\n\|Language=\n\|Description=\n\|Source=\n\|Permission=\n\|Image page=\n\|Pageoverview=\n\|Wikisource=:s:xx:Index:{{PAGENAME}}\n\|Homecat=\n\|Other_versions=\n\|OCLC=\n}}");

    str = str.replace(/{{CDO}}/g, "{{Category definition: Object \n\|image=\n\|type=\n\|artist=\n\|title=\n\|description=\n\|date=\n\|dimensions={{size\|cm\|}}\n\|medium={{technique\|}}\n\|inscriptions=\n\|object history=\n\|institution={{Institution:Louvre}}\n\|location={{Louvre location\|room ID=\|department=}}\n\|accession number={{Louvre number\|}}\n\|notes=\n\|references={{Louvre online\|}}\n\}}");
 
// licenses
    str = str.replace(/{{PC}}/g, "{{Private collection}}");
    str = str.replace(/{{PDA}}/g, "{{PD-Art\|PD-old-100-1923}}");
    str = str.replace(/{{PD-Art\/1923\|100}}/g, "{{PD-Art\|PD-old-100-1923}}");
    str = str.replace(/{{PD-Art\|PD-old-100}}/g, "{{PD-Art\|PD-old-100-1923}}");
    str = str.replace(/{{PD-art\|PD-old-100}}/g, "{{PD-Art\|PD-old-100-1923}}");
    str = str.replace(/{{PD-Art-100}}/g, "{{PD-Art\|PD-old-100-1923}}");
    str = str.replace(/{{PD-art-100}}/g, "{{PD-Art\|PD-old-100-1923}}");
    str = str.replace(/{{PDS}}/g, "{{PD-Scan|PD-old-100-1923}}");
    str = str.replace(/{{PDS|(1[0-8][0-9][0-9])}}/g, "{{PD-scan\|PD-old-auto-1923\|deathyear=$1}}");
    str = str.replace(/{{PDO}}/g, "{{PD-old-100-1923}}");
    str = str.replace(/{{PD}}/g, "{{PD-old-auto|deathyear=}}");
    str = str.replace(/&#160;/g, " ");
 

    return $.trim(str);
  });
 
  $.typo.editForm();
});
}