fix: inject script tag to access Optanon in page context
This commit is contained in:
parent
c31fb3d617
commit
3254b48a3e
1 changed files with 13 additions and 5 deletions
14
content.js
14
content.js
|
|
@ -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();
|
||||||
|
|
||||||
|
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();
|
window.Optanon.AllowAll();
|
||||||
document.body.style.overflow = '';
|
document.body.style.overflow = '';
|
||||||
overlay.remove();
|
w.remove();
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
`;
|
||||||
|
document.body.appendChild(script);
|
||||||
|
script.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
const observer = new MutationObserver(dismissPaywall);
|
const observer = new MutationObserver(dismissPaywall);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue