Fix support for strict CSP and page visibility function

Demo with CSP: https://little.my/tests/bp-csp/