1

I'm writing an extension that overrides the default Chrome history page.

The custom history page makes a few db calls when it's loaded.

I'm finding that the history.js file I have in the background.html override page is getting called with every page load (ie, not just when the user opens the history page)

This is problematic because it leads to unnecessary db calls and sometimes other errors that result from the history page being called but not being displayed.

Can anyone verify that this is Chrome's intended behavior (for some reason I don't understand), and I need to find a way to prevent history.js from making db calls when the history page isn't being displayed?

Alternately, does anyone know what I might be doing wrong that would cause history.js to be called with every page load?

1 Answer 1

0

Sigh, this was happening because I misunderstood how to configure my manifest.json file.

Per the instructions for Override Pages, I had:

  "chrome_url_overrides": {"history": "history.html"}

...but I also had history.js listed as a "content_scripts" member. Anything in "content_scripts" gets called on page load (if, of course, the page in question matches the "matches" regex you specified...mine is set to fire on any non-https page)

Sorry for the confusion!

AKA

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.