Skip to content

Support injecting scriptlets in one shared scope - #64

Draft
chrmod wants to merge 2 commits into
mainfrom
shared-scope-injection
Draft

chrmod wants to merge 2 commits into
mainfrom
shared-scope-injection

Conversation

@chrmod

@chrmod chrmod commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

Each scriptlet func inlined its own safeSelf(), so stacked hooks compounded (2^n). #63 shared 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 gives the extension what it needs for that, and drops the per-scriptlet func wrappers together with the global:

  • 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

Bundle goes from 2.2 MB to 0.5 MB.

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