Skip to content

Support injecting scriptlets in one shared scope - #64

Draft
chrmod wants to merge 1 commit into
mainfrom
shared-scope-injection
Draft

chrmod wants to merge 1 commit into
mainfrom
shared-scope-injection

Conversation

@chrmod

@chrmod chrmod commented Oct 5, 2026

Copy link
Copy Markdown
Member

Each scriptlet func inlines its own safeSelf(), so stacked hooks compound (2^n). #63 shares the cache through a Symbol.for property on globalThis, which pages can enumerate and use to reach the unhooked natives.

uBO avoids this by running all scriptlets of a frame in one scope with each dependency declared once. This adds what the extension needs for that:

  • functions: every function once; each scriptlet gets fn and dependencies
  • compose(calls, scriptletGlobals): one code string per injection, for registered scripts and chrome.userScripts.execute
  • run(scriptletGlobals, calls): one self-contained function for chrome.scripting.executeScript

func stays for now. Once ghostery-extension uses the new exports it is unused and can go together with the Symbol.for cache.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant