// This is the file you created on the Cloudflare Worker
const SCRIPT_URL = 'https://cw-ecwid-js.biblioplan.workers.dev/cw-ecwid.js?v=1';
function loadEcwidNukeScript() {
// Check for a key Ecwid element that only exists when the store is loaded.
// The main cart wrapper element is a good target.
if (document.querySelector('.ec-cart__wrapper')) {
// If the Ecwid cart is found, load the script immediately.
if (!document.getElementById("cw-ecwid-loader")) {
const s = document.createElement('script');
s.id = "cw-ecwid-loader";
s.src = SCRIPT_URL;
document.head.appendChild(s);
console.log('CW Ecwid Script Loaded via Polling.');
}
// Stop checking once it's loaded
return true;
}
return false;
}
// 1. Try to load it right away
if (loadEcwidNukeScript()) {
return;
}
// 2. If the Ecwid element isn't there yet, poll every 500ms for up to 10 seconds.
let attempts = 0;
const maxAttempts = 20; // 20 * 500ms = 10 seconds
const intervalId = setInterval(() => {
if (loadEcwidNukeScript() || attempts >= maxAttempts) {
clearInterval(intervalId);
}
attempts++;
}, 500);
October Specials:
Enter code “OCTOBER$10” at checkout to get $10 off any order over $75, including self-paced courses!
Enter code “OCTOBERAUDIO$5” to get $5 off any BP audio book!
Enter code “OCTOBERAUDIO$5” to get $5 off any BP audio book!


