0

Is there a way to pause chrome until all plugins are loaded?

I'd like to block a request to a certain url using chrome.webRequest.onBeforeRequest.

It's working fine if a chrome instance is already running, but If no instance is running and I open chrome by clicking on a link from within, for example, outlook, the extension is loaded to slow to be able to block the request.

Is there way to make sure the extension is loaded before the request happens?

Christian
  • 22,585
  • 9
  • 80
  • 106
  • Chrome doesn't wait for the background pages of extensions to load, it is reported quite regularly on their bugtracker, but the decision doesn't change since https://crbug.com/99450. IIUC back then they suggested declarativeWebRequest could help or they'll make it so in some distant future i.e. it's possible there's no solution yet. There's also an abandoned https://crbug.com/523634 – wOxxOm Sep 08 '18 at 14:25
  • @wOxxOm I've already seen that. And it's, at least in my opinion, incredible, they aren't providing a workaround. onBeforeRequest is clearly made to block certain sites but it's only working for an already started chrome? That's not reliable at all. – Christian Sep 08 '18 at 14:27
  • You can add "background" in "permissions" in your manifest.json so Chrome will continue running with no windows in the shell tray unless the user has disabled this option in browser settings. – wOxxOm Sep 08 '18 at 14:51
  • @wOxxOm I know, but that doesn't work on the initial start. – Christian Sep 08 '18 at 14:51
  • Well, content scripts run at startup AFAIK so you might be able to override XHR in the [page context](https://stackoverflow.com/a/9517879) (also `fetch` and its satellites). And as for the top tab URL just use `location`, `window.stop()`, etc. – wOxxOm Sep 08 '18 at 15:21
  • @wOxxOm I will take a look into that. But to make it work, I need to stop the request before it is sent to any server. – Christian Sep 08 '18 at 15:26

0 Answers0