/* CJXG: preserve legacy document.write advertising while keeping the content parser free. */ (function () { 'use strict'; function loadAds() { var slots = document.querySelectorAll('script[data-cjxg-ad-src]'); if (!slots.length) { return; } if (typeof window.postscribe !== 'function') { console.warn('CJXG: the local legacy-ad loader did not load.'); return; } Array.prototype.forEach.call(slots, function (slot) { if (slot.getAttribute('data-cjxg-started')) { return; } slot.setAttribute('data-cjxg-started', '1'); var src = slot.getAttribute('data-cjxg-ad-src'); if (!src || !/^(?:https?:)?\/\/(?:a\.wifi33\.com|a\.192ly\.com)\//i.test(src)) { return; } var container = document.createElement('div'); container.className = 'cjxg-deferred-ad'; slot.parentNode.insertBefore(container, slot); var script = document.createElement('script'); script.src = src; var charset = slot.getAttribute('charset'); if (charset) { script.charset = charset; } var type = slot.getAttribute('data-cjxg-ad-type'); if (type) { script.type = type; } window.postscribe(container, script.outerHTML, { releaseAsync: true, done: function () { slot.setAttribute('data-cjxg-finished', '1'); }, error: function () { slot.setAttribute('data-cjxg-error', '1'); } }); }); } function schedule() { window.requestAnimationFrame(function () { window.setTimeout(loadAds, 120); }); } if (document.readyState === 'complete') { schedule(); } else { window.addEventListener('load', schedule, {once: true}); } }());