',
};
Object.keys(replaceText).forEach((txtorig) => {
//txtorig is the key in replacetext object
const txtnew = replaceText[txtorig];
//txtnew is the value of the key in replacetext object
let entryFooter = document.querySelector('article .entry-footer');
if (document.querySelectorAll('.single-post').length > 0) {
//console.log('Article found.');
const text = entryFooter.innerHTML;
entryFooter.innerHTML = text.replace(txtorig, txtnew);
} else {
// console.log('Article not found.'); //removing comment 09/04/24
}
});
var css = document.createElement('style');
css.type = 'text/css';
css.innerHTML =
'.post-tags { display:none !important } .article-cta a { font-size: 18px; }';
document.body.appendChild(css);
//Extra
//This function adds some accessibility needs to the site.
function addAlly() {
// In this function JQuery is replaced with vanilla javascript functions
const imgCont = document.querySelector('.uw-imgcont');
imgCont.setAttribute('aria-label', 'AI news, latest developments');
imgCont.title = 'AI news, latest developments';
imgCont.rel = 'noopener';
document.querySelector('.page-mobile-menu-logo a').title =
'Towards AI Home';
document.querySelector('a.social-link').rel = 'noopener';
document.querySelector('a.uw-text').rel = 'noopener';
document.querySelector('a.uw-w-branding').rel = 'noopener';
document.querySelector('.blog h2.heading').innerHTML = 'Publication';
const popupSearch = document.querySelector$('a.btn-open-popup-search');
popupSearch.setAttribute('role', 'button');
popupSearch.title = 'Search';
const searchClose = document.querySelector('a.popup-search-close');
searchClose.setAttribute('role', 'button');
searchClose.title = 'Close search page';
// document
// .querySelector('a.btn-open-popup-search')
// .setAttribute(
// 'href',
// 'https://medium.com/towards-artificial-intelligence/search'
// );
}
// Add external attributes to 302 sticky and editorial links
function extLink() {
// Sticky 302 links, this fuction opens the link we send to Medium on a new tab and adds a "noopener" rel to them
var stickyLinks = document.querySelectorAll('.grid-item.sticky a');
for (var i = 0; i < stickyLinks.length; i++) {
/*
stickyLinks[i].setAttribute('target', '_blank');
stickyLinks[i].setAttribute('rel', 'noopener');
*/
}
// Editorial 302 links, same here
var editLinks = document.querySelectorAll(
'.grid-item.category-editorial a'
);
for (var i = 0; i < editLinks.length; i++) {
editLinks[i].setAttribute('target', '_blank');
editLinks[i].setAttribute('rel', 'noopener');
}
}
// Add current year to copyright notices
document.getElementById(
'js-current-year'
).textContent = new Date().getFullYear();
// Call functions after page load
extLink();
//addAlly();
setTimeout(function() {
//addAlly(); //ideally we should only need to run it once ↑
}, 5000);
};
function closeCookieDialog (){
document.getElementById("cookie-consent").style.display = "none";
return false;
}
setTimeout (
function () {
closeCookieDialog();
}, 15000);
console.log(`%c
🚀🚀🚀
███
█████
███████
█████████
███████████
█████████████
███████████████
███████
███████
███████
┌───────────────────────────────────────────────────────────────────┐
│ │
│ Towards AI is looking for contributors! │
│ Join us in creating awesome AI content. │
│ Let's build the future of AI together → │
│ https://towardsai.net/contribute │
│ │
└───────────────────────────────────────────────────────────────────┘
`, `background: ; color: #00adff; font-size: large`);
//Remove latest category across site
document.querySelectorAll('a[rel="category tag"]').forEach(function(el) {
if (el.textContent.trim() === 'Latest') {
// Remove the two consecutive spaces ( )
if (el.nextSibling && el.nextSibling.nodeValue.includes('\u00A0\u00A0')) {
el.nextSibling.nodeValue = ''; // Remove the spaces
}
el.style.display = 'none'; // Hide the
element
}
});
// Add cross-domain measurement, anonymize IPs
'use strict';
//var ga = gtag;
ga('config', 'G-9D3HKKFV1Q', 'auto', {
/*'allowLinker': true,*/
'anonymize_ip': true/*,
'linker': {
'domains': [
'medium.com/towards-artificial-intelligence',
'datasets.towardsai.net',
'rss.towardsai.net',
'feed.towardsai.net',
'contribute.towardsai.net',
'members.towardsai.net',
'pub.towardsai.net',
'news.towardsai.net'
]
} */
});
ga('send', 'pageview');
-->