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.
// This script has shamelessly been stolen from [[:de:User:DerHexer/addotrs.js]] and only saw minor adjustments to work on commons.
// blame him if it doesn't work :D

if(!usersignature) var usersignature = "-- \~\~\~\~";

var monthnames = new Array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
 
if(wgNamespaceNumber==6) 
{
  addOnloadHook(function() 
  { 
    var node = document.getElementById('t-whatlinkshere')

    if (skin == "vector")
      mw.util.addPortletLink('p-cactions', "javascript:add_otrs();", "OTRS", 't-otrs', 'add OTRS permission', '');
    else
      mw.util.addPortletLink('p-tb', "javascript:add_otrs();", "OTRS", 't-otrs', 'add OTRS permission', '', node);

    if ((wgAction == 'edit')  || (wgAction=='submit'))
    {
      mw.util.addPortletLink('p-tb', "javascript:add_template();","{{Information|..}}", 't-otrs', 'add image information template', '',  node);
      mw.util.addPortletLink('p-tb', "javascript:add_license('cc-by-sa-3.0');", "+CC-by-sa", 't-ccbysa', 'Lizenz CC-by-sa eintragen', '',  node);
      mw.util.addPortletLink('p-tb', "javascript:add_license('GFDL');", "+GFDL", 't-bildgfdl', 'Lizenz Bild-GFDL-Neu eintragen', '',  node);
    }
  });

  if ((getParamValue("dootrs")== "true") && (wgAction=='edit')) 
    window.setTimeout('add_otrs2()', 500);
}

function add_otrs() 
{
  if ((wgAction!='edit') && (wgAction !='submit'))
  {
    location.href = "http://commons.wikimedia.org/w/index.php?title=" + encodeURIComponent(mw.config.get('wgPageName')) + "&action=edit&dootrs=true";
  } else {
   add_otrs2();
  }
}
 
function add_otrs2() 
{
  var counter = 0;
  while(counter != 3) 
  {
    var ticketnummer=prompt('Ticket number:','');
    if (ticketnummer == null)
    {
      counter = 3;
    } else if (ticketnummer.search(/[^\d ]/) == -1) 
    {
      counter = 3;

      var otrs_datum = ticketnummer.match(/\b(\d{4})(\d{2})(\d{2})/);
      var otrsyear  = RegExp.$1;
      var otrsmonth = RegExp.$2;
      var otrsday   = RegExp.$3;

      if(otrsday.search(/0[0-9]/)!=-1) 
        otrsday = otrsday.match(/0([0-9])/)[1];
      if(otrsmonth.search(/0[0-9]/)!=-1) 
        otrsmonth = monthnames[parseInt(otrsmonth.match(/0([0-9])/)[1])-1]; 
      else 
        otrsmonth = monthnames[parseInt(otrsmonth)-1];

      otrs_text = "\{\{OTRS\|" + otrsday + ". " + otrsmonth + " " + otrsyear + "\|" + ticketnummer.trim() + "\|" + usersignature + "\}\}";
      document.editform.wpSummary.value = "OTRS-Permission";
  
      var text = document.editform.wpTextbox1.value;

      text = text.replace(/\=\= Summary \=\=/g, '== {{int:filedesc}} ==');
      text = text.replace(/\=\= Licensing \=\=/g, '== {{int:license}} ==');

      text = text.replace(/\{\{OTRS[ _]pending[^\}\n]*\}\}/g, '');
      text = text.replace(/\{\{no[ _]permission[^\}\n]*\}\}/g, '');
      text = text.replace(/\{\{delete[^\n]*\(CE[S]?T\)\s*/g, '');
      text = text.replace(/\{\{delete[^\}\n]*\}\}\b/g, '');

      var replacedlicence = text.match(/\|Permission\s?\=([^\n]*)(\n)/);
      replacedlicence = RegExp.$2.toString()+RegExp.$1.toString();
      text = text.replace(/\|Permission\s?\=[^\n]*/, "|Permission = " + otrs_text)
      text += "\r\n" + replacedlicence.toString();
      document.editform.wpTextbox1.value = text;
    } else {
       counter = counter + 1;
    }
  } 	
}

function add_template() 
{
  document.editform.wpTextbox1.value = 
     "== {{int:filedesc}} ==\n{{Information\n|Description=\n|Source=\n|Author=\n|Date=\n|Permission=\n|other_versions=\n}}\n\n== {{int:license}} =="+
     document.editform.wpTextbox1.value;
}

function add_license(vorlage)
{
  if (document.editform.wpTextbox1.value.search(/\=\=.* \{\{int:license\}\}/)>=0)
    document.editform.wpTextbox1.value = document.editform.wpTextbox1.value.replace(/\=\=.* \{\{int:license\}\}[^\n]*/,"== {{int:license}} ==\n\{\{"+vorlage+"\}\}");
  else
    document.editform.wpTextbox1.value += "== {{int:license}} ==\n\{\{"+vorlage+"\}\}";
}