Execute JS function before scanning #38
Answered
by
harlan-zw
felixranesberger
asked this question in
Q&A
-
Hi, is there any way I can call a JS function before scanning? I need to disable a cookie popup via JS. Thanks for any help :) |
Beta Was this translation helpful? Give feedback.
Answered by
harlan-zw
Nov 20, 2022
Replies: 1 comment 2 replies
-
Sorry about the delay, you can indeed using the hook system. You'll need to make a config file and load it export default {
hooks: {
'puppeteer:before-goto': async (page) => {
const deleteSelector= ".class-to-delete";
await page.waitForSelector(deleteSelector)
await page.evaluate((sel) => {
const elements = document.querySelectorAll(sel);
for(let i=0; i< elements.length; i++){
elements[i].parentNode.removeChild(elements[i]);
}
}, deleteSelector)
}
},
} |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
felixranesberger
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey @felixranesberger
Sorry about the delay, you can indeed using the hook system. You'll need to make a config file and load it