Note : après avoir enregistré la page, vous devrez forcer le rechargement complet du cache de votre navigateur pour voir les changements.

Mozilla / Firefox / Konqueror / Safari : maintenez la touche Majuscule (Shift) en cliquant sur le bouton Actualiser (Reload) ou pressez Maj-Ctrl-R (Cmd-R sur Apple Mac) ;

Chrome / Internet Explorer / Opera : maintenez la touche Ctrl en cliquant sur le bouton Actualiser ou pressez Ctrl-F5.
var MainCategory = "Category:All free media";



function AddLink(){
     var OngletsCactions = document.getElementById('p-cactions');
     if(OngletsCactions){
          var CactionsUl = OngletsCactions.getElementsByTagName('ul')[0];
          CactionsUl.innerHTML += '<li><a href="javascript:List();">List '+MainCategory+'</a></li>';
          if(OngletsCactions.className){
               OngletsCactions.className = OngletsCactions.className.replace(/[ ]*emptyPortlet[ ]*/, " ");
          }
     }
}

var ajax = {
  http:function(bundle){ var xmlhttp; try{ xmlhttp = new XMLHttpRequest(); }catch(e){ try{ xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }catch(e){ try{ xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }catch(e){ xmlhttp = false; }}}; if(xmlhttp){ xmlhttp.onreadystatechange = function(){ if (xmlhttp.readyState == 4){ ajax.httpComplete(xmlhttp,bundle);}}; xmlhttp.open(bundle.method ? bundle.method : "GET",bundle.url,bundle.async == false ? false : true); if (bundle.headers) { for (var field in bundle.headers){ try{ xmlhttp.setRequestHeader(field,bundle.headers[field]); }catch(err){}}}; xmlhttp.send(bundle.data ? bundle.data : null); }; return xmlhttp;}, 
  httpComplete: function(xmlhttp,bundle){ if(xmlhttp.status == 200 || xmlhttp.status == 302){ if(bundle.onSuccess) bundle.onSuccess(xmlhttp,bundle); }else if(bundle.onFailure){ bundle.onFailure(xmlhttp,bundle); }else{ }}
};

var PageInCategory = new Array();
var PageInCategoryCount = 0;
 
var CategoryInCategory = new Array();
var CategoryInCategoryCount = 0;
 
var IndexCategory = -1;

var APILimit = 499;
if( (mw.config.get('wgUserGroups').indexOf("sysop")!=-1)||(mw.config.get('wgUserGroups').indexOf("bot")!=-1)){
   APILimit = 4999;
}

function List(category, categorycontinue){
      if(!category) category = MainCategory;    
      if(!categorycontinue) categorycontinue = '';
      var URL = mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/api.php?format=xml&action=query&list=categorymembers&cmlimit='+APILimit+'&cmtitle=' + encodeURIComponent(MainCategory) + '&cmcontinue=' + encodeURIComponent(categorycontinue);
      prompt("URL :" , URL);
      ajax.http({ 
          url: URL,
          cat: MainCategory,
          onSuccess:ListDone
      });
}
 
function ListDone(Req, data){ 
      var ElementTraitement = Req.responseXML;
      var Pages = ElementTraitement.getElementsByTagName('cm');
      for(a=0;a<Pages.length;a++){
            var PageNamespace = parseInt(Pages[a].getAttribute('ns'));
            if((PageNamespace!=6)&&(PageNamespace!=14)) continue;
            var TitrePage = Pages[a].getAttribute('title');
            if((TitrePage.indexOf(mw.config.get('wgFormattedNamespaces')[14]+ ':')!=-1)){
                  if(CategoryInCategory.indexOf(TitrePage)==-1){                  
                        CategoryInCategory[CategoryInCategoryCount] = TitrePage;
                        CategoryInCategoryCount++
                  }
             }else if(TitrePage.indexOf(mw.config.get('wgFormattedNamespaces')[14] + ':')==-1){
                  TitrePage = TitrePage+"|[[:"+TitrePage+"]]";
                  if(PageInCategory.indexOf(TitrePage)==-1){
                        PageInCategory[PageInCategoryCount] = TitrePage;
                        PageInCategoryCount++
                  }
            }
      } 
      var MustContinue = ElementTraitement.getElementsByTagName('query-continue')[0];
      if(MustContinue && MustContinue.fistChild){
            var AutreRequeteContinue = MustContinue.fistChild.getAttribute("cmcontinue");
            List(data.cat, AutreRequeteContinue);
      }else{
            IndexCategory++
            var NewCategory = CategoryInCategory[IndexCategory];
            if(NewCategory){
                  List(NewCategory);
            }else{
                  PageInCategory = PageInCategory.sort()
                  DisplayList();
            }
       }
}

function DisplayList(){
       var Header = "Il y a "+PageInCategory.length+" fichiers dans la catégorie "+MainCategory+" :";
       var List = "<gallery>\n"+PageInCategory.join("\n")+"\n</gallery>";
       var Notice = document.getElementById("siteNotice");
       var P = document.createElement('p');
       P.appendChild(document.createTextNode(Header));
       var TextArea = document.createElement('textarea');
       TextArea.rows = 5;
       TextArea.value = List;
       var Div = document.createElement('div');
       Div.appendChild(P);
       Div.appendChild(TextArea);
       Notice.parentNode.insertBefore(Div, Notice);
}
  
$(AddLink);