fix: use world:MAIN to bypass CSP and access Optanon directly

This commit is contained in:
Eddy de Vink 2026-05-20 05:00:51 +02:00
commit 11d40ca67b
2 changed files with 21 additions and 29 deletions

View file

@ -1,5 +1,4 @@
console.log('[Buienradar Clicker] Content script loaded'); (function() {
let handled = false; let handled = false;
function dismissPaywall() { function dismissPaywall() {
@ -7,24 +6,15 @@ function dismissPaywall() {
const overlay = document.querySelector('.payok__wrap'); const overlay = document.querySelector('.payok__wrap');
if (!overlay) return; if (!overlay) return;
console.log('[Buienradar Clicker] Dismissing paywall'); if (typeof window.Optanon?.AllowAll !== 'function') return;
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 = '';
w.remove(); overlay.remove();
}
})();
`;
document.body.appendChild(script);
script.remove();
} }
const observer = new MutationObserver(dismissPaywall); const observer = new MutationObserver(dismissPaywall);
@ -33,3 +23,4 @@ observer.observe(document.body, { childList: true, subtree: true });
const pollInterval = setInterval(dismissPaywall, 500); const pollInterval = setInterval(dismissPaywall, 500);
dismissPaywall(); dismissPaywall();
})();

View file

@ -7,7 +7,8 @@
{ {
"matches": ["*://*.buienradar.nl/*"], "matches": ["*://*.buienradar.nl/*"],
"js": ["content.js"], "js": ["content.js"],
"run_at": "document_end" "run_at": "document_end",
"world": "MAIN"
} }
], ],
"icons": { "icons": {