From 8ba9ba7633fe3c9208d22fac35deb2f5c3466b3d Mon Sep 17 00:00:00 2001 From: Amauri CHAMPEAUX Date: Sat, 7 Mar 2015 03:04:23 +0100 Subject: [PATCH] Prevent loading advertising.js if the adblock feature is disabled --- tarteaucitron.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tarteaucitron.js b/tarteaucitron.js index e9b84e3..6116af5 100644 --- a/tarteaucitron.js +++ b/tarteaucitron.js @@ -95,7 +95,7 @@ var tarteaucitron = { pathToServices = cdn + 'tarteaucitron.services.js?v=' + tarteaucitron.version, linkElement = document.createElement('link'), defaults = { - "adblocker": true, + "adblocker": false, "hashtag": '#tarteaucitron', "highPrivacy": false, "orientation": "top", @@ -275,7 +275,7 @@ var tarteaucitron = { tarteaucitron.cookie.number(); setInterval(tarteaucitron.cookie.number, 60000); } - }); + }, defaults.adblocker); if (defaults.adblocker === true) { setTimeout(function () { @@ -790,7 +790,7 @@ var tarteaucitron = { return 'en_US'; } }, - "addScript": function (url, id, callback) { + "addScript": function (url, id, callback, execute) { "use strict"; var script = document.createElement('script'), done = false; @@ -809,7 +809,14 @@ var tarteaucitron = { } }; } - document.getElementsByTagName('head')[0].appendChild(script); + + if (execute === false) { + if (typeof callback === 'function') { + callback(); + } + } else { + document.getElementsByTagName('head')[0].appendChild(script); + } }, "makeAsync": { "antiGhost": 0,