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