This seems to work fine on Chrome-like browsers (as others have noted in the bug report linked below). However, on Firefox, sometimes when going back/forward, the content script doesn't bootstrap again. This is because the page was only hidden, not destroyed and re-loaded, so the content script was not re-injected. Therefore the method for detecting that situation, proposed in the bug report, should be adopted.
This seems to work fine on Chrome-like browsers (as others have noted in the bug report linked below). However, on Firefox, sometimes when going back/forward, the content script doesn't bootstrap again. This is because the page was only hidden, not destroyed and re-loaded, so the content script was not re-injected. Therefore the method for detecting that situation, proposed in the bug report, should be adopted.