assets/themes/j1/adapter/js/advertising.js in j1-template-2024.2.0 vs assets/themes/j1/adapter/js/advertising.js in j1-template-2024.2.1
- old
+ new
@@ -101,10 +101,11 @@
var gasIns = document.createElement('ins');
var adInitializerScript = document.createElement('script');
var advertisingProvider = 'Google Adsense';
var state = 'not_started';
var layout;
+
var advertisingDefaults;
var advertisingSettings;
var advertisingOptions;
var frontmatterOptions;
var autoHideOnUnfilled;
@@ -222,11 +223,10 @@
} else {
logger.info('\n' + 'use publisherID for Google Adsense: ' + publisherID);
}
// add Google Adsense API dynamically in head section loaded async
- //
logger.info('\n' + 'add Google AdsenseAPI in section: head');
gasScript.async = true;
gasScript.id = 'gas-api';
gasScript.src = '//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js';
@@ -234,11 +234,10 @@
document.head.appendChild(gasScript);
logger.info('\n' + 'adsense api initialized');
// setup monitor for state changes on all ads configured
- //
setTimeout(() => {
var ads_found = (document.getElementsByClassName('adsbygoogle').length > 0) ? true : false;
if (ads_found > 0) {
logger.info('\n' + 'setup Google Ad monitoring');
_this.ad_monitor();
@@ -246,11 +245,10 @@
logger.warn('\n' + 'no initialized Google Ads found in page');
}
}, 1000);
// run protection check
- //
if (checkTrackingProtection) {
logger.debug('\n' + 'run checks for tracking protection');
_this.check_tracking_protection();
var dependencies_met_tracking_check_ready = setInterval (() => {
@@ -286,28 +284,22 @@
clearInterval(dependencies_met_tracking_check_ready);
} // END if checkTrackingProtection
} else {
// user consent on personalization "false"
- //
if (production) {
console.debug('cookies for personalization rejected');
console.debug('initialization of module advertising skipped');
} else {
logger.warn('\n' + 'user consent on personalization: ' + user_consent.personalization);
logger.warn('\n' + 'initializing module: skipped');
}
// if consent is rejected, detect and remove Adsense cookies
- //
var gasCookies = j1.findCookie('__g');
gasCookies.forEach((item) => {
// remove Google Ad cookies
- if (hostname == 'localhost') {
- j1.removeCookie({ name: item, domain: false, secure: false });
- } else {
- j1.removeCookie({ name: item, domain: '.' + hostname, secure: false });
- }
+ j1.removeCookie({ name: item });
});
// manage tracking protection
if (checkTrackingProtection) {
if (!user_consent.personalization) {