I am working with third-party code (npm package) which uses opn (another npm package) to open default user browser during authorization. Instead of this, I want to open a new tab in the existing browser by sending some kind of request to the frontend. As I don't want to rewrite/copy all third-party code to actually change only one line inside, do you have any ideas how can I achieve this other way?
- Will it be possible to detect action like opening browser and send the request to frontend instead? I know that opn spawns node child process.
- Do you know if I can somehow efficiently change one of the third party code files so other files from this package will use my code instead? I could edit code inside node_modules to fulfil my requirements and never update this npm package but this sounds like a terrible idea.
If you want to open a new tab you should use Chrome DevTools Protocol.
You can read more here https://github.com/cyrus-and/chrome-remote-interface
I guess you can't catch an 'open browser' event. But it should be possible to ask periodicaly the browser by something like 'chrome-remote-interface' npm package.