-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#7255: Remove data-pb-ready
attribute
#8120
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,10 +23,9 @@ import "./contentScript.scss"; | |
import { addContentScriptIndicator } from "@/development/visualInjection"; | ||
import { uuidv4 } from "@/types/helpers"; | ||
import { | ||
isInstalledInThisSession, | ||
setInstalledInThisSession, | ||
setReadyInThisDocument, | ||
unsetReadyInThisDocument, | ||
isContentScriptInstalled, | ||
setContentScriptInstalled, | ||
setContentScriptReady, | ||
} from "@/contentScript/ready"; | ||
import { onContextInvalidated } from "webext-events"; | ||
import { logPromiseDuration } from "@/utils/promiseUtils"; | ||
|
@@ -57,7 +56,7 @@ async function initContentScript() { | |
const urlInfo = top === self ? "" : `in frame ${location.href}`; | ||
const uuid = uuidv4(); | ||
|
||
if (isInstalledInThisSession()) { | ||
if (isContentScriptInstalled()) { | ||
// Must prevent multiple injection because repeat messenger registration causes message handling errors: | ||
// https://github.com/pixiebrix/webext-messenger/issues/88 | ||
// Prior to 1.7.31 we had been using `webext-dynamic-content-scripts` which can inject the same content script | ||
|
@@ -84,7 +83,7 @@ async function initContentScript() { | |
|
||
console.debug(`contentScript: importing ${uuid} ${urlInfo}`); | ||
|
||
setInstalledInThisSession(); | ||
setContentScriptInstalled(); | ||
|
||
// Keeping the import separate ensures that no side effects are run until this point | ||
const contentScriptPromise = import( | ||
|
@@ -96,10 +95,9 @@ async function initContentScript() { | |
|
||
const { init } = await contentScriptPromise; | ||
await logPromiseDuration("contentScript: ready", init()); | ||
setReadyInThisDocument(uuid); | ||
setContentScriptReady(); | ||
|
||
onContextInvalidated.addListener(() => { | ||
unsetReadyInThisDocument(uuid); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Refer to the updated In short, "readiness" is not part of the document anymore, so it does not need to be unset. Each content script remains forever "ready" yet unconnectable. |
||
console.debug("contentScript: invalidated", uuid); | ||
}); | ||
|
||
|
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was the content-script-based messenger we had to implement because Firefox lacks
onConnectExternal
Should have been dropped with
Dropped here because it awaited the
data-pb-ready
attribute