From ab8bb3de652a5fcb5c69918db5a34066ef7ed9c3 Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Mon, 23 Mar 2020 17:25:35 +0100 Subject: [PATCH 1/4] useExternalJs should only apply to internal scripts --- tarteaucitron.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tarteaucitron.js b/tarteaucitron.js index 1ed5f4d..77c4caf 100644 --- a/tarteaucitron.js +++ b/tarteaucitron.js @@ -497,7 +497,7 @@ var tarteaucitron = { tarteaucitron.cookie.number(); setInterval(tarteaucitron.cookie.number, 60000); } - }, tarteaucitron.parameters.adblocker); + }, tarteaucitron.parameters.adblocker, null, null, true); if (tarteaucitron.parameters.adblocker === true) { setTimeout(function () { @@ -519,8 +519,8 @@ var tarteaucitron = { } }, 1500); } - }); - }); + }, null, null, null, true); + }, null, null, null, true); if(tarteaucitron.events.load) { tarteaucitron.events.load(); @@ -1396,7 +1396,7 @@ var tarteaucitron = { return 'en_US'; } }, - "addScript": function (url, id, callback, execute, attrName, attrVal) { + "addScript": function (url, id, callback, execute, attrName, attrVal, internal) { "use strict"; var script, done = false; @@ -1430,7 +1430,7 @@ var tarteaucitron = { } } - if ( !tarteaucitron.parameters.useExternalJs ) { + if ( !tarteaucitron.parameters.useExternalJs || !internal ) { document.getElementsByTagName('head')[0].appendChild(script); } } @@ -1470,7 +1470,7 @@ var tarteaucitron = { tarteaucitron.makeAsync.buffer = ''; tarteaucitron.makeAsync.execJS(id); } - }); + }, null, null, null, true); }, "execJS": function (id) { /* not strict because third party scripts may have errors */ From 4eb716c35194daa65ac489a328ae238553abd8e9 Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Tue, 21 Apr 2020 18:30:32 +0200 Subject: [PATCH 2/4] Refactor to make addScript() calls easier to read --- tarteaucitron.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/tarteaucitron.js b/tarteaucitron.js index 77c4caf..9e9b8bc 100644 --- a/tarteaucitron.js +++ b/tarteaucitron.js @@ -255,12 +255,12 @@ var tarteaucitron = { document.getElementsByTagName('head')[0].appendChild(linkElement); } // Step 2: load language and services - tarteaucitron.addScript(pathToLang, '', function () { + tarteaucitron.addInternalScript(pathToLang, '', function () { if(tarteaucitronCustomText !== ''){ tarteaucitron.lang = tarteaucitron.AddOrUpdate(tarteaucitron.lang, tarteaucitronCustomText); } - tarteaucitron.addScript(pathToServices, '', function () { + tarteaucitron.addInternalScript(pathToServices, '', function () { // css for new middle bar @@ -427,7 +427,7 @@ var tarteaucitron = { html += ''; } - tarteaucitron.addScript(tarteaucitron.cdn + 'advertising.js?v=' + tarteaucitron.version, '', function () { + tarteaucitron.addInternalScript(tarteaucitron.cdn + 'advertising.js?v=' + tarteaucitron.version, '', function () { if (tarteaucitronNoAdBlocker === true || tarteaucitron.parameters.adblocker === false) { // create a wrapper container at the same level than tarteaucitron so we can add an aria-hidden when tarteaucitron is opened @@ -497,7 +497,7 @@ var tarteaucitron = { tarteaucitron.cookie.number(); setInterval(tarteaucitron.cookie.number, 60000); } - }, tarteaucitron.parameters.adblocker, null, null, true); + }, tarteaucitron.parameters.adblocker); if (tarteaucitron.parameters.adblocker === true) { setTimeout(function () { @@ -519,8 +519,8 @@ var tarteaucitron = { } }, 1500); } - }, null, null, null, true); - }, null, null, null, true); + }); + }); if(tarteaucitron.events.load) { tarteaucitron.events.load(); @@ -1435,6 +1435,9 @@ var tarteaucitron = { } } }, + "addInternalScript": function (url, id, callback, execute, attrName, attrVal) { + tarteaucitron.addScript(url, id, callback, execute, attrName, attrVal, true); + }, "makeAsync": { "antiGhost": 0, "buffer": '', @@ -1464,13 +1467,13 @@ var tarteaucitron = { return; } tarteaucitron.makeAsync.antiGhost += 1; - tarteaucitron.addScript(url, '', function () { + tarteaucitron.addInternalScript(url, '', function () { if (document.getElementById(id) !== null) { document.getElementById(id).innerHTML += " " + tarteaucitron.makeAsync.buffer; tarteaucitron.makeAsync.buffer = ''; tarteaucitron.makeAsync.execJS(id); } - }, null, null, null, true); + }); }, "execJS": function (id) { /* not strict because third party scripts may have errors */ From e555e47ecd38dd5f14ca3b3a9051751895789fb1 Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Wed, 22 Apr 2020 11:08:39 +0200 Subject: [PATCH 3/4] Default value for internal parameter --- tarteaucitron.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tarteaucitron.js b/tarteaucitron.js index 9e9b8bc..983088d 100644 --- a/tarteaucitron.js +++ b/tarteaucitron.js @@ -1396,7 +1396,7 @@ var tarteaucitron = { return 'en_US'; } }, - "addScript": function (url, id, callback, execute, attrName, attrVal, internal) { + "addScript": function (url, id, callback, execute, attrName, attrVal, internal = false) { "use strict"; var script, done = false; From 6cca3a0836e690a6403ab400381944a134884c47 Mon Sep 17 00:00:00 2001 From: Amauri CHAMPEAUX Date: Fri, 24 Apr 2020 10:12:08 +0200 Subject: [PATCH 4/4] Fix #442 --- tarteaucitron.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tarteaucitron.js b/tarteaucitron.js index a074941..2a7750c 100644 --- a/tarteaucitron.js +++ b/tarteaucitron.js @@ -1422,7 +1422,7 @@ var tarteaucitron = { return 'en_US'; } }, - "addScript": function (url, id, callback, execute, attrName, attrVal, internal = false) { + "addScript": function (url, id, callback, execute, attrName, attrVal, internal) { "use strict"; var script, done = false;