
‘
‘;
console.log(`[RecSys] ${template}`);
// Inserting template
body.insertAdjacentHTML(‘beforebegin’, template);
console.log(`[RecSys] Template inserted afterend of the main`);
}
var box = document.querySelector(‘#li-recommendation-unit’);
var numItems = box.querySelectorAll(‘article’).length || 4;
if (box && typeof IntersectionObserver === ‘function’ && typeof window.$p === ‘function’) {
console.log(‘[RecSys] Recommendation box found’);
// Define recommendations options
var options = {};
options.widget=”news-multicontent-widget”;
options.title=”Recomendadas para você”;
options.numItems = numItems;
options.registerOpts = {
excludeIds: [translateCanonicalUrl(window.location.href.split(‘?’)[0])],
maxAgeInSeconds: 2 * 24 * 60 * 60,
site_name: sitename,
_override: ‘news-page’
}
options.abTest = false;
options.slice = 0;
// Globo.com alternative recommendation
// options.alternative=”applyGloboComRecommendation”;
// DataScience Team/Elo alternative recommendation
options.alternative=”applyDataScienceRecommendation”
// Setup observer for 100% viewport intersection
var observer = new IntersectionObserver(function (entries, observer) {
entries.forEach(function (entry) {
if (entry.isIntersecting) {
console.log(‘[RecSys] Apply recommendation’);
// Unobserve right away to avoid multiple calls when user scrolls up and down
observer.unobserve(entry.target);
applyRecommendation(options).then(function () {
// Final steps
// Turn box visible
box.style.visibility = ‘visible’;
box.style.height=”auto”;
})
.catch(function (err) {
console.log(‘[RecSys] Error in recommendation: ‘ + err);
})
}
})
}, {
rootMargin: ‘100%’
});
observer.observe(box);
}
}
// Must await paywall script execute
var timeout = {
init: 500,
step: 500,
quit: 10000
};
var recommendationListener = function () {
setTimeout(function () {
// Check for variable “hasPaywall” which indicates if the page is blocked or not
if (typeof window.hasPaywall === ‘undefined’ || (typeof window.hasPaywall === ‘boolean’ && !window.hasPaywall)) {
console.log(‘[RecSys] Paywall ended execution’);
recommendationTrigger();
return;
}
// Otherwise, wait more 500 miliseconds (until reach 10 seconds)
timeout.init = timeout.init + timeout.step;
if ((timeout.init
📢 Belford Roxo 24h – Aqui a informação nunca para
📞 WhatsApp da Redação: (21) 97915-5787
🔗 Canal no WhatsApp: Entrar no canal
🌐 Mais notícias: belfordroxo24h.com







