Skip to content

Execute JS function before scanning #38

Answered by harlan-zw
felixranesberger asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @felixranesberger

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)
    }
  },
}

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@harlan-zw
Comment options

@harlan-zw
Comment options

Answer selected by felixranesberger
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants