fix: inject script tag to access Optanon in page context

This commit is contained in:
Eddy de Vink 2026-05-20 04:52:30 +02:00
commit 3254b48a3e

View file

@ -7,16 +7,24 @@ function dismissPaywall() {
const overlay = document.querySelector('.payok__wrap'); const overlay = document.querySelector('.payok__wrap');
if (!overlay) return; if (!overlay) return;
if (typeof window.Optanon?.AllowAll !== 'function') return;
console.log('[Buienradar Clicker] Dismissing paywall'); console.log('[Buienradar Clicker] Dismissing paywall');
handled = true; handled = true;
clearInterval(pollInterval); clearInterval(pollInterval);
observer.disconnect(); observer.disconnect();
window.Optanon.AllowAll(); const script = document.createElement('script');
document.body.style.overflow = ''; script.textContent = `
overlay.remove(); (function() {
var w = document.querySelector('.payok__wrap');
if (w && window.Optanon && typeof window.Optanon.AllowAll === 'function') {
window.Optanon.AllowAll();
document.body.style.overflow = '';
w.remove();
}
})();
`;
document.body.appendChild(script);
script.remove();
} }
const observer = new MutationObserver(dismissPaywall); const observer = new MutationObserver(dismissPaywall);