From 8f0893b5f7106215662c7c2f2723d9f0ca500418 Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Sat, 17 Sep 2022 11:11:02 -0300 Subject: [PATCH] Website: Adjustments to Carbon --- docs/static/js/carbon.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/docs/static/js/carbon.js b/docs/static/js/carbon.js index e0fa2871..f18744a2 100644 --- a/docs/static/js/carbon.js +++ b/docs/static/js/carbon.js @@ -1,6 +1,6 @@ (function () { function attachAd() { - const el = document.createElement('script'); + var el = document.createElement('script'); el.setAttribute('type', 'text/javascript'); el.setAttribute('id', '_carbonads_js'); el.setAttribute( @@ -9,7 +9,7 @@ ); el.setAttribute('async', 'async'); - const wrapper = document.getElementById('sidebar-ads'); + var wrapper = document.getElementById('sidebar-ads'); wrapper.innerHTML = ''; wrapper.appendChild(el); } @@ -17,8 +17,13 @@ setTimeout(function () { attachAd(); - window.addEventListener('popstate', function () { - attachAd(); - }); + var currentPath = window.location.pathname; + + setInterval(function () { + if (currentPath !== window.location.pathname) { + currentPath = window.location.pathname; + attachAd(); + } + }, 1000); }, 1000); })();