// ==UserScript==
// @name RecuperationPhotoIconSportFR
// @namespace http://adminphoto.maxifoot.com/
// @version 4.0
// @description Ajoute un formulaire de recup des photos IconSport
// @author JC
// @match https://www.iconsport.photo/*
// @grant GM_xmlhttpRequest
// @grant GM_setValue
// @grant GM_getValue
// ==/UserScript==
(function() {
'use strict';
var api1 = 'http://adminphoto.maxifoot.com/getIconSportFR.php';
var reg1=new RegExp('
]*id="menu_telecharger_([0-9]+)"',"mi"); // ID de la photo, ex: 1098024
var reg2=new RegExp('^[0-9]+$','');
var reg4=new RegExp("^([0-9]+)\=(1|0|-1|-2|-3|-4)",''); // verifie le transfert
var log1=0;
var chkList1 = []; // 0..n : ID des photos
var IDoks= []; // ID1 ... IDn
var Tnom1 = []; // [ID0..IDn] : "nom" des photos
var messOK = []; // photo deja transfere
var aut1="";
function addMFform() {
var allDown, thisDown, photID;
allDown = document.evaluate(
'//div[@class="menu_telecharger"]', // balises "
';
txt4+='
cochez pour tranferer cette ';
txt4+='photo (ID='+photID+')';
newChk1.innerHTML=txt4;
newChk1.id='MF'+photID;
newChk1.style.position='relative';
newChk1.style.zIndex=9;
newChk1.style.top='0px';
// chkList1[ip++]=photID;
chkList1[photID]=photID;
IDoks[photID]=1;
}
thisDown.parentNode.insertBefore(newChk1, thisDown);
}
console.log(ip+' photo trouvees - ');
return false;
} // end addMFform()
function send2mf(){
var isChk1=0;
var data1='auteur='+aut1+'&icon=3';
for (var i in chkList1) {
var photID=chkList1[i];
if (reg2.test(photID)==false) { continue; }
console.log(photID);
if (document.getElementById('chk'+photID)=='undefined') {
alert('chk'+photID+' non defini ???');
} else if (document.getElementById('chk'+photID).checked) {
data1+='&photos['+photID+']=1';
isChk1++;
}
}
if (isChk1>0) {
var req1=api1+'?'+data1;
var txt5='Transfert de '+isChk1+" photo(s):\n\nCliquez sur OK pour lancer le transfert\n\nEnsuite, MERCI DE PATIENTER";
txt5+="(le transfert prend plusieurs secondes par photo)\nUn message vous informera a la fin du transfert\n\n";
if (confirm(txt5)) {
if (log1) { return true; }
// alert('Recuperation de(s) photo(s) en cours ...')
GM_xmlhttpRequest({
method: "GET",
url: req1,
onerror: function(res) {
alert('Erreur durant la recuperation de(s) photo(s) ...');
},
onload: function(response) {
var rep1=response.responseText;
console.log('rep1='+rep1);
if (rep1==undefined) { alert('Echec transfert'); return false; }
var getOK="Transfert termine\n\n";
var reg5=new RegExp("\n", "");
var tab1=rep1.split(reg5);
if (tab1.length>=1) {
for (var i1=0; i1
0) {
var matchArray=reg4.exec(txt1);
var idPHO=matchArray[1];
if ((matchArray[2]==1) && (messOK[idPHO]==undefined)) { // recup photo OK
getOK+="OK\n";
// on desactive le checkbox
GM_setValue(idPHO, 1);
var obj1=document.getElementById('chk'+idPHO);
var getText1=document.createElement('span');
getText1.innerHTML='OK';
obj1.parentNode.replaceChild(getText1,obj1);
messOK[idPHO]=1;
} else if (matchArray[2]==0) { // photo deja presente dans l'admin photo maxifoot
getOK+="- DEJA DANS L'ADMIN MAXIFOOT\n";
} else {
getOK+='- ECHEC TRANSFERT : err='+matchArray[2]+"\n";
}
}
}
} else {
getOK+='- AUCUNE PHOTO DOWNLOADEE ...'+"\n";
}
alert(getOK);
}
});
}
} else {
alert('Aucune photo selectionnee');
}
return false;
}
console.log('start mf');
var allTD, thisTD;
allTD = document.evaluate(
'//div[@class="flexPage"]',
document,
null,
XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
null);
thisTD = allTD.snapshotItem(0);
var thisParElt1=thisTD;
var newForm1 = document.createElement("button");
var txt6="Cliquez ici pour transferer dans l'admin photo de Maxifoot, les photos cochees ci-dessous
";
newForm1.innerHTML=txt6;
newForm1.addEventListener('click', send2mf, null);
newForm1.style.backgroundColor='#000';
newForm1.style.margin='0 auto';
newForm1.style.display='inline-block';
newForm1.style.borderRadius='8px';
var newForm2 = document.createElement("div");
newForm2.style.display='inline-block';
newForm2.addEventListener('click', hideb1, null);
var txt7='';
txt7+='masquer les cases a cocher pour capture
';
newForm2.innerHTML=txt7;
var divIns1=document.createElement("div");
divIns1.style.position='fixed';
divIns1.style.zIndex=99;
divIns1.style.marginTop='-85px';
divIns1.appendChild(newForm2);
divIns1.appendChild(newForm1);
thisParElt1.parentNode.insertBefore(divIns1, thisParElt1.previousSibling);
addMFform();
var h0=document.getElementById('container_liste_photo').clientHeight;
function hideb1() {
var i1=0;
var o1=document.getElementById('hideb1');
var el1 = document.getElementsByClassName('mfb0');
if (o1.style.borderRadius=='4px') {
o1.style.borderRadius='5px';
o1.innerHTML='afficher les cases a cocher';
for (i1=0; i1h0) { addMFform(); }
// timeControl = setInterval ( function () {
// if (document.getElementById('fancybox-overlay').style.display!='none') { return false; }
// clearInterval (timeControl);
// addMFform();
// isloading=0;
// },
// 300
// );
}, false);
})();