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
18
content.js
18
content.js
|
|
@ -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();
|
||||
|
||||
window.Optanon.AllowAll();
|
||||
document.body.style.overflow = '';
|
||||
overlay.remove();
|
||||
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 = '';
|
||||
w.remove();
|
||||
}
|
||||
})();
|
||||
`;
|
||||
document.body.appendChild(script);
|
||||
script.remove();
|
||||
}
|
||||
|
||||
const observer = new MutationObserver(dismissPaywall);
|
||||
|
|
|
|||
Loading…
Reference in a new issue