Add ATInternet hybrid mode

This commit is contained in:
Amauri CHAMPEAUX 2021-03-03 16:25:51 +01:00
parent d72c71e756
commit f65b959790
2 changed files with 114 additions and 9 deletions

View File

@ -626,10 +626,10 @@ var tarteaucitron = {
tarteaucitron.userInterface.respondAll(true); tarteaucitron.userInterface.respondAll(true);
}); });
tarteaucitron.addClickEventToId("tarteaucitronAllDenied", function () { tarteaucitron.addClickEventToId("tarteaucitronAllDenied", function () {
tarteaucitron.userInterface.respondAll(false); tarteaucitron.userInterface.respondAll(false, '', true);
}); });
tarteaucitron.addClickEventToId("tarteaucitronAllDenied2", function () { tarteaucitron.addClickEventToId("tarteaucitronAllDenied2", function () {
tarteaucitron.userInterface.respondAll(false); tarteaucitron.userInterface.respondAll(false, '', true);
if (tarteaucitron.reloadThePage === true) { if (tarteaucitron.reloadThePage === true) {
window.location.reload(); window.location.reload();
} }
@ -863,7 +863,7 @@ var tarteaucitron = {
document.getElementById(id).classList.remove(className); document.getElementById(id).classList.remove(className);
} }
}, },
"respondAll": function (status, type) { "respondAll": function (status, type, allowSafeAnalytics) {
"use strict"; "use strict";
var s = tarteaucitron.services, var s = tarteaucitron.services,
service, service,
@ -872,7 +872,11 @@ var tarteaucitron = {
for (index = 0; index < tarteaucitron.job.length; index += 1) { for (index = 0; index < tarteaucitron.job.length; index += 1) {
if (typeof type !== 'undefined' && s[tarteaucitron.job[index]].type !== type) { if (typeof type !== 'undefined' && type !== '' && s[tarteaucitron.job[index]].type !== type) {
continue;
}
if (allowSafeAnalytics && typeof s[tarteaucitron.job[index]].safeanalytic !== "undefined" && s[tarteaucitron.job[index]].safeanalytic === true) {
continue; continue;
} }
@ -936,7 +940,8 @@ var tarteaucitron = {
nbPending = 0, nbPending = 0,
nbAllowed = 0, nbAllowed = 0,
sum = tarteaucitron.job.length, sum = tarteaucitron.job.length,
index; index,
s = tarteaucitron.services;
if (status === true) { if (status === true) {
document.getElementById(key + 'Line').classList.add('tarteaucitronIsAllowed'); document.getElementById(key + 'Line').classList.add('tarteaucitronIsAllowed');
@ -948,6 +953,12 @@ var tarteaucitron = {
// check if all services are allowed // check if all services are allowed
for (index = 0; index < sum; index += 1) { for (index = 0; index < sum; index += 1) {
if (typeof s[tarteaucitron.job[index]].safeanalytic !== "undefined" && s[tarteaucitron.job[index]].safeanalytic === true) {
sum -= 1;
continue;
}
if (tarteaucitron.state[tarteaucitron.job[index]] === false) { if (tarteaucitron.state[tarteaucitron.job[index]] === false) {
nbDenied += 1; nbDenied += 1;
} else if (tarteaucitron.state[tarteaucitron.job[index]] === undefined) { } else if (tarteaucitron.state[tarteaucitron.job[index]] === undefined) {
@ -1823,4 +1834,4 @@ var tarteaucitron = {
} }
} }
} }
}; };

View File

@ -2675,6 +2675,7 @@ tarteaucitron.services.atinternet = {
"name": "AT Internet (privacy by design)", "name": "AT Internet (privacy by design)",
"uri": "https://helpcentre.atinternet-solutions.com/hc/fr/categories/360002439300-Privacy-Centre", "uri": "https://helpcentre.atinternet-solutions.com/hc/fr/categories/360002439300-Privacy-Centre",
"needConsent": false, "needConsent": false,
"safeanalytic": true,
"cookies": ['atidvisitor', 'atreman', 'atredir', 'atsession', 'atuserid'], "cookies": ['atidvisitor', 'atreman', 'atredir', 'atsession', 'atuserid'],
"js": function () { "js": function () {
"use strict"; "use strict";
@ -2684,12 +2685,106 @@ tarteaucitron.services.atinternet = {
tarteaucitron.addScript(tarteaucitron.user.atLibUrl, '', function() { tarteaucitron.addScript(tarteaucitron.user.atLibUrl, '', function() {
var tag = new ATInternet.Tracker.Tag(); window.tag = new ATInternet.Tracker.Tag();
if (typeof tarteaucitron.user.atMore === 'function') { if (typeof tarteaucitron.user.atMore === 'function') {
tarteaucitron.user.atMore(); tarteaucitron.user.atMore();
} }
})
if (typeof window.tag.privacy !== 'undefined') {
document.getElementById('atinternetLine').style.display = 'none';
if (tarteaucitron.cookie.read().indexOf('atinternetoptin=true') === -1 && tarteaucitron.cookie.read().indexOf('atinternetoptout=true') === -1) {
window.tag.privacy.setVisitorMode('cnil', 'exempt');
}
tarteaucitron.addClickEventToElement(document.getElementById('atinternetDenied'), function () {
tarteaucitron.launch['atinternetoptout'] = false;
tarteaucitron.launch['atinternetoptin'] = false;
tarteaucitron.userInterface.respond(document.getElementById('atinternetoptinDenied'), false);
tarteaucitron.userInterface.respond(document.getElementById('atinternetoptoutDenied'), false);
});
tarteaucitron.addClickEventToElement(document.getElementById('atinternetoptoutDenied'), function () {
if (tarteaucitron.cookie.read().indexOf('atinternetoptin=true') === -1 && tarteaucitron.cookie.read().indexOf('atinternetoptout=true') === -1) {
window.tag.privacy.setVisitorMode('cnil', 'exempt');
}
});
tarteaucitron.addClickEventToElement(document.getElementById('atinternetoptinDenied'), function () {
if (tarteaucitron.cookie.read().indexOf('atinternetoptin=true') === -1 && tarteaucitron.cookie.read().indexOf('atinternetoptout=true') === -1) {
window.tag.privacy.setVisitorMode('cnil', 'exempt');
}
});
}
setTimeout(function() {
tag.page.send();
}, 70);
});
}
};
// AT Internet (optin)
tarteaucitron.services.atinternetoptin = {
"key": "atinternetoptin",
"type": "analytic",
"name": "AT Internet",
"uri": "https://helpcentre.atinternet-solutions.com/hc/fr/categories/360002439300-Privacy-Centre",
"needConsent": true,
"cookies": ['atidvisitor', 'atreman', 'atredir', 'atsession', 'atuserid'],
"js": function () {
"use strict";
tarteaucitron.launch['atinternetoptout'] = false;
setTimeout(function() {
tarteaucitron.userInterface.respond(document.getElementById('atinternetAllowed'), true);
tarteaucitron.userInterface.respond(document.getElementById('atinternetoptoutDenied'), false);
}, 50);
setTimeout(function() {
if (typeof window.tag.privacy !== 'undefined') {
window.tag.privacy.setVisitorOptin();
}
}, 60);
window.tarteaucitronHackNoSwitch = true;
setTimeout(function() {window.tarteaucitronHackNoSwitch = false;}, 200);
}
};
// AT Internet (optout)
tarteaucitron.services.atinternetoptout = {
"key": "atinternetoptout",
"type": "analytic",
"name": "AT Internet [minimal]",
"uri": "https://helpcentre.atinternet-solutions.com/hc/fr/categories/360002439300-Privacy-Centre",
"needConsent": true,
"cookies": ['atidvisitor', 'atreman', 'atredir', 'atsession', 'atuserid'],
"js": function () {
"use strict";
// hack accept all
if (window.tarteaucitronHackNoSwitch) {
setTimeout(function() {
tarteaucitron.userInterface.respond(document.getElementById('atinternetoptoutDenied'), false);
}, 60);
return;
}
tarteaucitron.launch['atinternetoptin'] = false;
setTimeout(function() {
tarteaucitron.userInterface.respond(document.getElementById('atinternetAllowed'), true);
tarteaucitron.userInterface.respond(document.getElementById('atinternetoptinDenied'), false);
}, 50);
setTimeout(function() {
if (typeof window.tag.privacy !== 'undefined') {
window.tag.privacy.setVisitorOptout();
}
}, 60);
} }
}; };
@ -3505,4 +3600,3 @@ tarteaucitron.services.woopra = {
woopra.track(); woopra.track();
} }
}; };