Dynamically change preload script

Is there a way to set/change the preload option in webPreferences after BrowserWindow has been created?

What I would like to do is make a webcrawler that changes its preload script whenever the BrowserWindow redirects to a new URL.

The issue that I am trying to solve is that the webcrawler needs to collect different information on different sites.

The only 2 solutions I can think of are:

  1. make 1 massive preload script that covers every website or
  2. create a new BrowserWindow with a different preload script each time it redirects,

but neither seems resource efficient.

Is it possible to change or use different preload scripts without using multiple instances of the BrowserWindow?