content-scripts-register-polyfill
content-scripts-register-polyfill copied to clipboard
Content script doesn't inject on page load from shorthand url
Step to Reproduce
- Version 3.2.2 (imported via webext-dynamic-content-scripts version 9.2.2)
- Grant optional permissions to
https://www.linkedin.com/*
- Open a new tab and type: linkedin.com
- If you're logged in, page will redirect to https://www.linkedin.com/feed/
- Content script is not injected 😞
Discussion/Investigation
-
browser.webNavigation.onHistoryStateUpdated
is fired for the frame -
browser.webNavigation.onCommitted
is fired for the frame: - ~~Somehow
previouslyLoaded
is coming back as true~~: my debug logging might have messed this up. It's confusing thatwasPreviouslyLoaded
mutates the state - There's something fishy going on with the frameIds/variable namespace. Somehow
https://www.linkedin.com
first appears as being in a frame, and then the top-level inject fails due towasPreviouslyLoaded
coming back as true
- The bug appears to be fixed if I pass tabId and frameId in the wasPreviouslyLoaded check
|| await wasPreviouslyLoaded({ tabId, frameId }, { js, css, tabId, frameId }) // Avoid double-injection
Other History
- The history includes the SPA redirect to /feed/
Related
- https://github.com/fregante/content-scripts-register-polyfill/pull/60