Browse Source

Prevent loading advertising.js if the adblock feature is disabled

Amauri CHAMPEAUX 10 years ago
parent
commit
8ba9ba7633
1 changed files with 11 additions and 4 deletions
  1. 11 4
      tarteaucitron.js

+ 11 - 4
tarteaucitron.js

@@ -95,7 +95,7 @@ var tarteaucitron = {
             pathToServices = cdn + 'tarteaucitron.services.js?v=' + tarteaucitron.version,
             pathToServices = cdn + 'tarteaucitron.services.js?v=' + tarteaucitron.version,
             linkElement = document.createElement('link'),
             linkElement = document.createElement('link'),
             defaults = {
             defaults = {
-                "adblocker": true,
+                "adblocker": false,
                 "hashtag": '#tarteaucitron',
                 "hashtag": '#tarteaucitron',
                 "highPrivacy": false,
                 "highPrivacy": false,
                 "orientation": "top",
                 "orientation": "top",
@@ -275,7 +275,7 @@ var tarteaucitron = {
                         tarteaucitron.cookie.number();
                         tarteaucitron.cookie.number();
                         setInterval(tarteaucitron.cookie.number, 60000);
                         setInterval(tarteaucitron.cookie.number, 60000);
                     }
                     }
-                });
+                }, defaults.adblocker);
                 
                 
                 if (defaults.adblocker === true) {
                 if (defaults.adblocker === true) {
                     setTimeout(function () {
                     setTimeout(function () {
@@ -790,7 +790,7 @@ var tarteaucitron = {
             return 'en_US';
             return 'en_US';
         }
         }
     },
     },
-    "addScript": function (url, id, callback) {
+    "addScript": function (url, id, callback, execute) {
         "use strict";
         "use strict";
         var script = document.createElement('script'),
         var script = document.createElement('script'),
             done = false;
             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": {
     "makeAsync": {
         "antiGhost": 0,
         "antiGhost": 0,